Documentation ¶
Index ¶
Constants ¶
View Source
const (
// OpenIDScopes the key used in the context for openid scopes.
OpenIDScopes = "OpenId.Scopes"
)
View Source
const (
// UserKey the key used in the context for the user.
UserKey = "Auth.User"
)
Variables ¶
View Source
var ( // ErrScopesNotFound scopes for this operation not found in context. ErrScopesNotFound = errors.New("scopes not found in context") // ErrScopesTypeMismatch failed to retrieve scopes, type mismatch. ErrScopesTypeMismatch = errors.New("failed to retrieve scopes, type mismatch") )
View Source
var ( // ErrUserNotFound user not found in context. ErrUserNotFound = errors.New("user not found in context") // ErrUserTypeMismatch failed to retrieve user, type mismatch. ErrUserTypeMismatch = errors.New("failed to retrieve user, type mismatch") )
Functions ¶
func LoadOperationScopesFromContext ¶
LoadOperationScopesFromContext load the scopes for a given operation from the context.
Types ¶
type AuthenticatedUser ¶
type AuthenticatedUser struct { ID string `json:"id,omitempty"` Scopes []string `json:"scopes,omitempty"` }
AuthenticatedUser authenticated user used to validate access.
func LoadUserFromContext ¶
func LoadUserFromContext(ctx echo.Context) (AuthenticatedUser, error)
LoadUserFromContext load the authenticated user from the context.
func (*AuthenticatedUser) HasScope ¶
func (au *AuthenticatedUser) HasScope(allowedScopes []string) bool
HasScope check if the authenticated user has one of the allowed scopes.
func (*AuthenticatedUser) MarshalZerologObject ¶
func (au *AuthenticatedUser) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject used to print user in logs.
Click to show internal directories.
Click to hide internal directories.