Documentation
¶
Overview ¶
Package auth exists to ease the difficult to handle authentication and to some extent authorization. auth do not implement the token creation, third-party software like keycloak, casdoor etc should be used as issuer.
Index ¶
- func GetRootClaim(ctx context.Context, claim string) interface{}
- func HasRole(ctx context.Context, role string) bool
- func HasRoleMiddleware(role string) func(next http.Handler) http.Handler
- func HasScope(ctx context.Context, scope string) bool
- func HasScopeMiddleware(scope string) func(next http.Handler) http.Handler
- type Claims
- type OIDC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRootClaim ¶
GetRootClaim return claim from ctx. ctx should be populated before calling GetRootClaim with the token claims, generally using OIDC.Auth method.
func HasRole ¶
HasRole inspect ctx for role claim, if present returns true. Before using this function ctx should be populated with the token claims, generally using OIDC.Auth method.
func HasRoleMiddleware ¶
HasRoleMiddleware wrap HasRole inside an http middleware to prevent access to handlers after. OIDC.Auth must be present before this middleware, otherwise claims will not be present at http.Request.Context.
func HasScope ¶
HasScope inspect ctx for scope claim, if present returns true. Before using this function ctx should be populated with the token claims, generally using OIDC.Auth method.
func HasScopeMiddleware ¶
HasScopeMiddleware wrap HasRole inside an http middleware to prevent access to handlers after. OIDC.Auth must be present before this middleware, otherwise claims will not be present at http.Request.Context.
Types ¶
type OIDC ¶
type OIDC struct {
// contains filtered or unexported fields
}
OIDC represents our authentication using openid connect and required dependencies like logger.