auth

package
v0.0.0-...-4c11209 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

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

func LoadOperationScopesFromContext(ctx echo.Context, provider string) ([]string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL