application

package
v3.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: OSL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
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) Auth

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

Auth tries to retrieve the authentication context for a active 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 *sessions.Session) (string, error)

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

func (am *AuthManager) IDToken(c context.Context, session *sessions.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 *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

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

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

func (am *AuthManager) URL(ctx context.Context, path string) (*url.URL, error)

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 Synchronizer interface {
	Insert(user domain.User, session *sessions.Session) error
	IsActive(user domain.User, session *sessions.Session) (bool, error)
}

type SynchronizerImpl

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

func (*SynchronizerImpl) Inject

func (s *SynchronizerImpl) Inject(store store.Store, logger flamingo.Logger)

func (*SynchronizerImpl) Insert

func (s *SynchronizerImpl) Insert(user domain.User, session *sessions.Session) error

func (*SynchronizerImpl) IsActive

func (s *SynchronizerImpl) IsActive(user domain.User, session *sessions.Session) (bool, error)

type UserService

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

userService helps to use the authenticated user information

func (*UserService) GetUser

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

GetUser returns the current user information

func (*UserService) InitUser

func (us *UserService) InitUser(c context.Context, session *sessions.Session) error

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

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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