Keycloak handler & middleware for echo
This project is still WiP and the interfaces might change pretty often
Supported authentication flows:
- Direct Grant Flow
Use this together with the keycloak client gocloak
- Install the package
go get "github.com/Nerzal/gocloak/v8"
// AuthenticationHandler is used to authenticate with the api
type AuthenticationHandler interface {
AuthenticateClient(Authenticate) (*gocloak.JWT, error)
AuthenticateUser(Authenticate) (*gocloak.JWT, error)
RefreshToken(Refresh) (*gocloak.JWT, error)
}
// AuthenticationMiddleWare is used to validate the JWT
type AuthenticationMiddleWare interface {
CheckToken(next echo.HandlerFunc) echo.HandlerFunc
CheckTokenCustomHeader(next echo.HandlerFunc) echo.HandlerFunc
CheckScope(next echo.HandlerFunc) echo.HandlerFunc
DecodeAndValidateToken(next echo.HandlerFunc) echo.HandlerFunc
}
This middleware uses echo and gocloak. Choose the right version for you
Versions | Compatibility |
---|---|
gockloak-echo/v3 | gocloak/v3, echo/v3 |
gockloak-echo/v4 | gocloak/v3, echo/v4 |
gockloak-echo/v7 | gocloak/v7, echo/v4 |
gockloak-echo/v8 | gocloak/v8, echo/v4 |