Documentation ¶
Index ¶
- Constants
- type AuthManager
- func (am *AuthManager) Auth(c context.Context, session *sessions.Session) (domain.Auth, error)
- func (am *AuthManager) ExtractRawIDToken(oauth2Token *oauth2.Token) (string, error)
- func (am *AuthManager) GetRawIDToken(c context.Context, session *sessions.Session) (string, error)
- func (am *AuthManager) HTTPClient(c context.Context, session *sessions.Session) (*http.Client, error)
- func (am *AuthManager) IDToken(c context.Context, session *sessions.Session) (*oidc.IDToken, error)
- func (am *AuthManager) Inject(logger flamingo.Logger, router *router.Router, config ...)
- func (am *AuthManager) OAuth2Config(ctx context.Context) *oauth2.Config
- func (am *AuthManager) OAuth2Token(session *sessions.Session) (*oauth2.Token, error)
- func (am *AuthManager) OpenIDProvider() *oidc.Provider
- func (am *AuthManager) TokenSource(c context.Context, session *sessions.Session) (oauth2.TokenSource, error)
- func (am *AuthManager) URL(ctx context.Context, path string) (*url.URL, error)
- func (am *AuthManager) Verifier() *oidc.IDTokenVerifier
- type EventPublisher
- type Synchronizer
- type SynchronizerImpl
- type UserService
- func (us *UserService) GetUser(c context.Context, session *sessions.Session) *domain.User
- func (us *UserService) InitUser(c context.Context, session *sessions.Session) error
- func (us *UserService) Inject(manager *AuthManager, ums *domain.UserMappingService, s Synchronizer, cfg ...)
- func (us *UserService) IsLoggedIn(c context.Context, session *sessions.Session) bool
- type UserServiceInterface
Constants ¶
const ( // KeyToken defines where the authentication token is saved KeyToken = "auth.token" // KeyRawIDToken defines where the raw ID token is saved KeyRawIDToken = "auth.rawidtoken" // KeyAuthstate defines the current internal authentication state KeyAuthstate = "auth.state" // KeyToken defines where the authentication token extras are saved KeyTokenExtras = "auth.token.extras" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthManager ¶
type AuthManager struct {
// contains filtered or unexported fields
}
authManager handles authentication related operations
func (*AuthManager) ExtractRawIDToken ¶
func (am *AuthManager) ExtractRawIDToken(oauth2Token *oauth2.Token) (string, error)
ExtractRawIDToken from the provided (fresh) oatuh2token
func (*AuthManager) GetRawIDToken ¶
GetRawIDToken gets the raw IDToken from session
func (*AuthManager) HTTPClient ¶
func (am *AuthManager) HTTPClient(c context.Context, session *sessions.Session) (*http.Client, error)
HTTPClient to retrieve a client with automatic tokensource
func (*AuthManager) Inject ¶
func (am *AuthManager) Inject(logger flamingo.Logger, router *router.Router, config *struct { Server string `inject:"config:auth.server"` Secret string `inject:"config:auth.secret"` ClientID string `inject:"config:auth.clientid"` MyHost string `inject:"config:auth.myhost"` AllowHostFromReq bool `inject:"config:auth.allowHostFromReq,optional"` DisableOfflineToken bool `inject:"config:auth.disableOfflineToken"` Scopes config.Slice `inject:"config:auth.scopes"` IdTokenMapping config.Slice `inject:"config:auth.claims.idToken"` UserInfoMapping config.Slice `inject:"config:auth.claims.userInfo"` })
Inject authManager dependencies
func (*AuthManager) OAuth2Config ¶
func (am *AuthManager) OAuth2Config(ctx context.Context) *oauth2.Config
OAuth2Config is lazy setup oauth2config
func (*AuthManager) OAuth2Token ¶
OAuth2Token retrieves the oauth2 token from the session
func (*AuthManager) OpenIDProvider ¶
func (am *AuthManager) OpenIDProvider() *oidc.Provider
OpenIDProvider is a lazy initialized OID provider
func (*AuthManager) TokenSource ¶
func (am *AuthManager) TokenSource(c context.Context, session *sessions.Session) (oauth2.TokenSource, error)
TokenSource to be used in situations where you need it
func (*AuthManager) Verifier ¶
func (am *AuthManager) Verifier() *oidc.IDTokenVerifier
Verifier creates an OID verifier
type EventPublisher ¶
type EventPublisher struct {
// contains filtered or unexported fields
}
EventPublisher struct
func (*EventPublisher) Inject ¶
func (e *EventPublisher) Inject(router event.Router)
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 Synchronizer ¶
type SynchronizerImpl ¶
type SynchronizerImpl struct {
// contains filtered or unexported fields
}
func (*SynchronizerImpl) Inject ¶
func (s *SynchronizerImpl) Inject(store store.Store, logger flamingo.Logger)
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
userService helps to use the authenticated user information
func (*UserService) Inject ¶
func (us *UserService) Inject(manager *AuthManager, ums *domain.UserMappingService, s Synchronizer, cfg *struct { PreventSimultaneousSessions bool `inject:"config:auth.preventSimultaneousSessions"` })
func (*UserService) IsLoggedIn ¶
IsLoggedIn determines the user's login status
type UserServiceInterface ¶
type UserServiceInterface interface { InitUser(ctx context.Context, session *sessions.Session) error GetUser(ctx context.Context, session *sessions.Session) *domain.User IsLoggedIn(ctx context.Context, session *sessions.Session) bool }
UserServiceInterface to mock in tests