Back to godoc.org

Package auth

v0.0.0-...-542b13e
Latest Go to latest

The highest tagged major version is .

Published: Oct 24, 2019 | License: Apache-2.0 | Module: github.com/wolfeidau/exitus

Index

Constants

const (
	// OpenIDScopes the key used in the context for openid scopes
	OpenIDScopes = "OpenId.Scopes"
)
const (
	// UserKey the key used in the context for the user
	UserKey = "Auth.User"
)

Variables

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")
)
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")
)

func LoadOperationScopesFromContext

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

LoadOperationScopesFromContext load the scopes for a given operation from the context

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier