gocloak-echo

January 27, 2021 ยท View on GitHub

FOSSA Status

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

Usage examples

  • 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
}

Compatibility Matrix

This middleware uses echo and gocloak. Choose the right version for you

VersionsCompatibility
gockloak-echo/v3gocloak/v3, echo/v3
gockloak-echo/v4gocloak/v3, echo/v4
gockloak-echo/v7gocloak/v7, echo/v4
gockloak-echo/v8gocloak/v8, echo/v4

License

FOSSA Status