application

package
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManager

type AuthManager struct {
	AuthCodeOptions []oauth2.AuthCodeOption
	// contains filtered or unexported fields
}

AuthManager handles authentication related operations Deprecated: use core/auth instead

func (*AuthManager) AccessToken

func (am *AuthManager) AccessToken(ctx context.Context, session *web.Session) (string, error)

AccessToken - used to get access token

func (*AuthManager) Auth

func (am *AuthManager) Auth(c context.Context, session *web.Session) (domain.Auth, error)

Auth tries to retrieve the authentication context for a active session - this is used to pass Authentication to services

  • if the stored token for the Auth is not valid anymore it will refresh the token before

func (*AuthManager) DeleteAuthState

func (am *AuthManager) DeleteAuthState(session *web.Session)

DeleteAuthState deletes auth state from session

func (*AuthManager) DeleteTokenDetails

func (am *AuthManager) DeleteTokenDetails(session *web.Session)

DeleteTokenDetails deletes all token related data from session

func (*AuthManager) ExtractRawIDToken

func (am *AuthManager) ExtractRawIDToken(oauth2Token *oauth2.Token) (string, error)

ExtractRawIDToken from the provided (fresh) oatuh2token

func (*AuthManager) GetRawIDToken

func (am *AuthManager) GetRawIDToken(c context.Context, session *web.Session) (string, error)

GetRawIDToken gets the raw IDToken from session

func (*AuthManager) HTTPClient

func (am *AuthManager) HTTPClient(c context.Context, session *web.Session) (*http.Client, error)

HTTPClient to retrieve a client with automatic tokensource

func (*AuthManager) IDToken

func (am *AuthManager) IDToken(c context.Context, session *web.Session) (*oidc.IDToken, error)

IDToken retrieves and validates the ID Token from the session

func (*AuthManager) Inject

func (am *AuthManager) Inject(logger flamingo.Logger, router *web.Router, config *struct {
	Server              string       `inject:"config:core.oauth.server"`
	Secret              string       `inject:"config:core.oauth.secret"`
	ClientID            string       `inject:"config:core.oauth.clientid"`
	DisableOfflineToken bool         `inject:"config:core.oauth.disableOfflineToken"`
	Scopes              config.Slice `inject:"config:core.oauth.scopes"`
	IDTokenMapping      config.Slice `inject:"config:core.oauth.claims.idToken"`
	UserInfoMapping     config.Slice `inject:"config:core.oauth.claims.userInfo"`
	TokenExtras         config.Slice `inject:"config:core.oauth.tokenExtras"`
	DebugMode           bool         `inject:"config:flamingo.debug.mode"`
	Enabled             bool         `inject:"config:core.oauth.enabled"`
	OverrideIssuerURL   string       `inject:"config:core.oauth.overrideIssuerURL"`
})

Inject authManager dependencies

func (*AuthManager) LoadAuthState

func (am *AuthManager) LoadAuthState(session *web.Session) (string, bool)

LoadAuthState loads auth state from session

func (*AuthManager) OAuth2Config

func (am *AuthManager) OAuth2Config(_ context.Context, req *web.Request) *oauth2.Config

OAuth2Config is lazy setup oauth2config

func (*AuthManager) OAuth2Token

func (am *AuthManager) OAuth2Token(session *web.Session) (*oauth2.Token, error)

OAuth2Token retrieves the oauth2 token from the session

func (*AuthManager) OAuthCtx

func (am *AuthManager) OAuthCtx(ctx context.Context) context.Context

OAuthCtx - returns ctx that should be used to pass to oauth2 lib - it enables logging for Debug reasons

func (*AuthManager) OpenIDProvider

func (am *AuthManager) OpenIDProvider() *oidc.Provider

OpenIDProvider is a lazy initialized OID provider

func (*AuthManager) StoreAuthState

func (am *AuthManager) StoreAuthState(session *web.Session, state string)

StoreAuthState stores auth state into session, used to connect passed state id in auth callback with the one stored in session

func (*AuthManager) StoreTokenDetails

func (am *AuthManager) StoreTokenDetails(ctx context.Context, session *web.Session, oauth2Token *oauth2.Token) error

StoreTokenDetails stores all token related data into session

func (*AuthManager) TokenSource

func (am *AuthManager) TokenSource(c context.Context, session *web.Session) (oauth2.TokenSource, error)

TokenSource - return oauth2.TokenSource initialized with the Refreshtoken stored in the to be used in situations where you need it

func (*AuthManager) Verifier

func (am *AuthManager) Verifier() *oidc.IDTokenVerifier

Verifier creates an OID verifier

type AuthRoleProvider

type AuthRoleProvider struct {
	// contains filtered or unexported fields
}

AuthRoleProvider implements the RoleProvider interface for authenticated users

func (*AuthRoleProvider) All

func (p *AuthRoleProvider) All(ctx context.Context, session *web.Session) []securityDomain.Role

All return all associated roles

func (*AuthRoleProvider) Inject

func (p *AuthRoleProvider) Inject(us UserServiceInterface)

Inject userService dependency

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

EventHandler for logout events

func (*EventHandler) Inject

func (e *EventHandler) Inject(authManager *AuthManager)

Inject dependencies

func (*EventHandler) Notify

func (e *EventHandler) Notify(_ context.Context, event flamingo.Event)

Notify calls AuthManager on each logout, so it can destroy data stored for previously logged in user

type EventPublisher

type EventPublisher struct {
	// contains filtered or unexported fields
}

EventPublisher struct

func (*EventPublisher) Inject

func (e *EventPublisher) Inject(router flamingo.EventRouter)

Inject dependencies

func (*EventPublisher) PublishLoginEvent

func (e *EventPublisher) PublishLoginEvent(ctx context.Context, event *domain.LoginEvent)

PublishLoginEvent dispatches the login event on the contexts event router

func (*EventPublisher) PublishLogoutEvent

func (e *EventPublisher) PublishLogoutEvent(ctx context.Context, event *domain.LogoutEvent)

PublishLogoutEvent dispatches the logout event on the contexts event router

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService helps to use the authenticated user information Deprecated: use core/auth instead

func (*UserService) GetUser

func (us *UserService) GetUser(c context.Context, session *web.Session) *domain.User

GetUser returns the current user information

func (*UserService) Inject

func (us *UserService) Inject(manager *AuthManager, ums *domain.UserMappingService)

Inject dependencies

func (*UserService) IsLoggedIn

func (us *UserService) IsLoggedIn(c context.Context, session *web.Session) bool

IsLoggedIn determines the user's login status

type UserServiceInterface

type UserServiceInterface interface {
	GetUser(ctx context.Context, session *web.Session) *domain.User
	IsLoggedIn(ctx context.Context, session *web.Session) bool
}

UserServiceInterface to mock in tests Deprecated: use core/auth instead

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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