auth

package
v0.0.0-...-66e4c3a Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessTokenFromContext

func AccessTokenFromContext(ctx context.Context) *string

AccessTokenFromContext returns the access token model of the token used to authentication from a context. If no authentication was provided or the current context does not carry any access token information, nil will be returned instead.

func AccessTokenFromEchoContext

func AccessTokenFromEchoContext(c echo.Context) *string

AccessTokenFromEchoContext returns the access token model of the token used to authentication from an echo context. If no authentication was provided or the current context does not carry any access token information, nil will be returned instead.

func EnrichContextWithCredentials

func EnrichContextWithCredentials(ctx context.Context, result AuthenticationResult) context.Context

EnrichContextWithCredentials stores the provided credentials in the form of user and access token used for authentication in the give context and updates the logger associated with ctx to include the user's ID.

func EnrichEchoContextWithCredentials

func EnrichEchoContextWithCredentials(c echo.Context, result AuthenticationResult) echo.Context

EnrichEchoContextWithCredentials stores the provided credentials in the form of user and access token user for authentication in the given echo context's request and updates the logger associated with c to include the user's ID.

func UserFromContext

func UserFromContext(ctx context.Context) *models.User

UserFromContext returns the user model of the currently authenticated user from a context. If no authentication was provided or the current context does not carry any user information, nil will be returned instead.

func UserFromEchoContext

func UserFromEchoContext(c echo.Context) *models.User

UserFromEchoContext returns the user model of the currently authenticated user from an echo context. If no authentication was provided or the current echo context does not carry any user information, nil will be returned instead.

Types

type AuthenticationResult

type AuthenticationResult struct {
	Token      string
	User       *models.User
	ValidUntil time.Time
	Scopes     []string
}

type Scope

type Scope string
const (
	AuthScopeApp Scope = "app"
)

func (Scope) String

func (s Scope) String() string

Jump to

Keyboard shortcuts

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