authentication

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoadConsumerOptions = struct {
	Default                          LoadConsumerOptionFunc
	WithAuthentifiedUser             LoadConsumerOptionFunc
	WithAuthentifiedUserWithContacts LoadConsumerOptionFunc
	WithConsumerGroups               LoadConsumerOptionFunc
}{
	Default:                          loadDefault,
	WithAuthentifiedUser:             loadAuthentifiedUser,
	WithAuthentifiedUserWithContacts: loadAuthentifiedUserWithContacts,
	WithConsumerGroups:               loadConsumerGroups,
}

LoadConsumerOptions provides all options on auth consumer loads functions.

Functions

func CheckDefaultSigninStateToken

func CheckDefaultSigninStateToken(signature string) error

CheckDefaultSigninStateToken checks if a given signature is a valid signin state.

func CheckSession

func CheckSession(ctx context.Context, db gorp.SqlExecutor, store cache.Store, sessionID string) (*sdk.AuthSession, error)

CheckSession returns the session if valid for given id.

func CheckSessionWithCustomMFADuration

func CheckSessionWithCustomMFADuration(ctx context.Context, db gorp.SqlExecutor, store cache.Store, sessionID string, durationMFA time.Duration) (*sdk.AuthSession, error)

CheckSessionWithCustomMFADuration returns the session if valid for given id.

func ConsumerInvalidateGroupForUser

func ConsumerInvalidateGroupForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, g *sdk.Group, u *sdk.AuthentifiedUser) error

ConsumerInvalidateGroupForUser set group as invalid in all user's consumers and set warning.

func ConsumerInvalidateGroupsForUser

func ConsumerInvalidateGroupsForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string, userGroupIDs sdk.Int64Slice) error

ConsumerInvalidateGroupsForUser set groups as invalid if the user is not a member in all user's consumers and set warning.

func ConsumerRegen

func ConsumerRegen(ctx context.Context, db gorpmapper.SqlExecutorWithTx, consumer *sdk.AuthConsumer, overlapDuration, newDuration time.Duration) error

ConsumerRegen updates a consumer issue date to invalidate old signin token.

func ConsumerRemoveGroup

func ConsumerRemoveGroup(ctx context.Context, db gorpmapper.SqlExecutorWithTx, g *sdk.Group) error

ConsumerRemoveGroup removes given group from all consumers that using it, set warning and disabled state if needed.

func ConsumerRestoreInvalidatedGroupForUser

func ConsumerRestoreInvalidatedGroupForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, groupID int64, userID string) error

ConsumerRestoreInvalidatedGroupForUser checks if there are consumers for given user where the group was invalidated, then restore it and remove warning.

func ConsumerRestoreInvalidatedGroupsForUser

func ConsumerRestoreInvalidatedGroupsForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string) error

ConsumerRestoreInvalidatedGroupsForUser restore invalidated group for all user's consumer, this should be used only for a admin user.

func DeleteConsumerByID

func DeleteConsumerByID(db gorp.SqlExecutor, id string) error

DeleteConsumerByID removes a auth consumer in database for given id.

func DeleteSessionByID

func DeleteSessionByID(db gorp.SqlExecutor, id string) error

DeleteSessionByID removes a auth session in database for given id.

func GetIssuerName

func GetIssuerName() string

func GetSessionActivity

func GetSessionActivity(store cache.Store, sessionID string) (exists bool, lastActivity time.Time, err error)

GetSessionActivity returns if given session is active.

func GetSessionXSRFToken

func GetSessionXSRFToken(store cache.Store, sessionID string) (string, bool)

GetSessionXSRFToken returns a XSRF token from cache if exists for given session.

func GetSigningKey

func GetSigningKey() *rsa.PrivateKey

func Init

func Init(issuer string, k []byte) error

Init the package by passing the signing key

func InsertConsumer

func InsertConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sdk.AuthConsumer) error

InsertConsumer in database.

func InsertSession

func InsertSession(ctx context.Context, db gorpmapper.SqlExecutorWithTx, as *sdk.AuthSession) error

InsertSession in database.

func LoadConsumerByID

func LoadConsumerByID(ctx context.Context, db gorp.SqlExecutor, id string, opts ...LoadConsumerOptionFunc) (*sdk.AuthConsumer, error)

LoadConsumerByID returns an auth consumer from database.

func LoadConsumerByTypeAndUserExternalID

func LoadConsumerByTypeAndUserExternalID(ctx context.Context, db gorp.SqlExecutor, consumerType sdk.AuthConsumerType, userExternalID string, opts ...LoadConsumerOptionFunc) (*sdk.AuthConsumer, error)

LoadConsumerByTypeAndUserExternalID returns an auth consumer from database for given type and user id.

func LoadConsumerByTypeAndUserID

func LoadConsumerByTypeAndUserID(ctx context.Context, db gorp.SqlExecutor, consumerType sdk.AuthConsumerType, userID string, opts ...LoadConsumerOptionFunc) (*sdk.AuthConsumer, error)

LoadConsumerByTypeAndUserID returns an auth consumer from database for given type and user id.

func LoadConsumersByGroupID

func LoadConsumersByGroupID(ctx context.Context, db gorp.SqlExecutor, groupID int64, opts ...LoadConsumerOptionFunc) (sdk.AuthConsumers, error)

LoadConsumersByGroupID returns all consumers from database that refer to given group id.

func LoadConsumersByUserID

func LoadConsumersByUserID(ctx context.Context, db gorp.SqlExecutor, id string, opts ...LoadConsumerOptionFunc) (sdk.AuthConsumers, error)

LoadConsumersByUserID returns auth consumers from database for given user id.

func LoadExpiredSessions

func LoadExpiredSessions(ctx context.Context, db gorp.SqlExecutor, opts ...LoadSessionOptionFunc) ([]sdk.AuthSession, error)

LoadExpiredSessions returns all expired session

func LoadSessionByID

func LoadSessionByID(ctx context.Context, db gorp.SqlExecutor, id string, opts ...LoadSessionOptionFunc) (*sdk.AuthSession, error)

LoadSessionByID returns an auth session from database.

func LoadSessionsByConsumerIDs

func LoadSessionsByConsumerIDs(ctx context.Context, db gorp.SqlExecutor, consumerIDs []string, opts ...LoadSessionOptionFunc) ([]sdk.AuthSession, error)

LoadSessionsByConsumerIDs returns all auth sessions from database for given consumer ids.

func NewConsumerExternal

func NewConsumerExternal(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string, consumerType sdk.AuthConsumerType, userInfo sdk.AuthDriverUserInfo) (*sdk.AuthConsumer, error)

NewConsumerExternal returns a new local consumer for given data.

func NewConsumerWorker

func NewConsumerWorker(ctx context.Context, db gorpmapper.SqlExecutorWithTx, name string, hatcherySrv *sdk.Service, hatcheryConsumer *sdk.AuthConsumer, groupIDs []int64) (*sdk.AuthConsumer, error)

func NewDefaultSigninStateToken

func NewDefaultSigninStateToken(origin, redirectURI string, isFirstConnection bool) (string, error)

NewDefaultSigninStateToken returns a jws used for signin request.

func NewSession

NewSession returns a new session for a given auth consumer.

func NewSessionJWT

func NewSessionJWT(s *sdk.AuthSession, externalSessionID string) (string, error)

NewSessionJWT generate a signed token for given auth session.

func NewSessionWithMFA

func NewSessionWithMFA(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, c *sdk.AuthConsumer, duration time.Duration) (*sdk.AuthSession, error)

NewSessionWithMFA returns a new session for a given auth consumer with MFA.

func NewSessionWithMFACustomDuration

func NewSessionWithMFACustomDuration(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, c *sdk.AuthConsumer, duration, durationMFA time.Duration) (*sdk.AuthSession, error)

NewSessionWithMFACustomDuration returns a new session for a given auth consumer with MFA and custom MFA duration.

func NewSessionXSRFToken

func NewSessionXSRFToken(store cache.Store, sessionID string, sessionExpirationDelaySecond int) (string, error)

NewSessionXSRFToken generate and store a XSRF token for a given session id.

func SessionCleaner

func SessionCleaner(ctx context.Context, dbFunc func() *gorp.DbMap, tickerDuration time.Duration)

SessionCleaner must be run as a goroutine

func SetSessionActivity

func SetSessionActivity(store cache.Store, durationMFA time.Duration, sessionID string) error

SetSessionActivity store activity in cache for given session.

func SignJWS

func SignJWS(content interface{}, now time.Time, duration time.Duration) (string, error)

func SignJWT

func SignJWT(jwtToken *jwt.Token) (string, error)

func UnsafeLoadCorruptedSessions

func UnsafeLoadCorruptedSessions(ctx context.Context, db gorp.SqlExecutor) ([]sdk.AuthSession, error)

UnsafeLoadCorruptedSessions should not be used

func UpdateConsumer

func UpdateConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sdk.AuthConsumer) error

UpdateConsumer in database.

func UpdateConsumerLastAuthentication

func UpdateConsumerLastAuthentication(ctx context.Context, db gorp.SqlExecutor, ac *sdk.AuthConsumer) error

UpdateConsumerLastAuthentication updates only the column last_authentication

func VerifyJWS

func VerifyJWS(signature string, content interface{}) error

func VerifyJWT

func VerifyJWT(token *jwt.Token) (interface{}, error)

Types

type LoadConsumerOptionFunc

type LoadConsumerOptionFunc func(context.Context, gorp.SqlExecutor, ...*sdk.AuthConsumer) error

LoadConsumerOptionFunc for auth consumer.

type LoadSessionOptionFunc

type LoadSessionOptionFunc func(context.Context, gorp.SqlExecutor, ...*sdk.AuthSession) error

LoadSessionOptionFunc for auth session.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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