Documentation
¶
Index ¶
- Variables
- func CheckDefaultSigninStateToken(signature string) error
- func CheckSession(ctx context.Context, db gorp.SqlExecutor, store cache.Store, sessionID string) (*sdk.AuthSession, error)
- func CheckSessionWithCustomMFADuration(ctx context.Context, db gorp.SqlExecutor, store cache.Store, sessionID string, ...) (*sdk.AuthSession, error)
- func ConsumerInvalidateGroupForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, g *sdk.Group, ...) error
- func ConsumerInvalidateGroupsForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string, ...) error
- func ConsumerRegen(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ...) error
- func ConsumerRemoveGroup(ctx context.Context, db gorpmapper.SqlExecutorWithTx, g *sdk.Group) error
- func ConsumerRestoreInvalidatedGroupForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, groupID int64, ...) error
- func ConsumerRestoreInvalidatedGroupsForUser(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string) error
- func DeleteConsumerByID(db gorp.SqlExecutor, id string) error
- func DeleteSessionByID(db gorp.SqlExecutor, id string) error
- func GetIssuerName() string
- func GetSessionActivity(store cache.Store, sessionID string) (exists bool, lastActivity time.Time, err error)
- func GetSessionXSRFToken(store cache.Store, sessionID string) (string, bool)
- func GetSigningKey() *rsa.PrivateKey
- func Init(issuer string, k []byte) error
- func InsertConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sdk.AuthConsumer) error
- func InsertSession(ctx context.Context, db gorpmapper.SqlExecutorWithTx, as *sdk.AuthSession) error
- func LoadConsumerByID(ctx context.Context, db gorp.SqlExecutor, id string, ...) (*sdk.AuthConsumer, error)
- func LoadConsumerByTypeAndUserExternalID(ctx context.Context, db gorp.SqlExecutor, consumerType sdk.AuthConsumerType, ...) (*sdk.AuthConsumer, error)
- func LoadConsumerByTypeAndUserID(ctx context.Context, db gorp.SqlExecutor, consumerType sdk.AuthConsumerType, ...) (*sdk.AuthConsumer, error)
- func LoadConsumersByGroupID(ctx context.Context, db gorp.SqlExecutor, groupID int64, ...) (sdk.AuthConsumers, error)
- func LoadConsumersByUserID(ctx context.Context, db gorp.SqlExecutor, id string, ...) (sdk.AuthConsumers, error)
- func LoadExpiredSessions(ctx context.Context, db gorp.SqlExecutor, opts ...LoadSessionOptionFunc) ([]sdk.AuthSession, error)
- func LoadSessionByID(ctx context.Context, db gorp.SqlExecutor, id string, ...) (*sdk.AuthSession, error)
- func LoadSessionsByConsumerIDs(ctx context.Context, db gorp.SqlExecutor, consumerIDs []string, ...) ([]sdk.AuthSession, error)
- func NewConsumerExternal(ctx context.Context, db gorpmapper.SqlExecutorWithTx, userID string, ...) (*sdk.AuthConsumer, error)
- func NewConsumerWorker(ctx context.Context, db gorpmapper.SqlExecutorWithTx, name string, ...) (*sdk.AuthConsumer, error)
- func NewDefaultSigninStateToken(origin, redirectURI string, isFirstConnection bool) (string, error)
- func NewSession(ctx context.Context, db gorpmapper.SqlExecutorWithTx, c *sdk.AuthConsumer, ...) (*sdk.AuthSession, error)
- func NewSessionJWT(s *sdk.AuthSession, externalSessionID string) (string, error)
- func NewSessionWithMFA(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, ...) (*sdk.AuthSession, error)
- func NewSessionWithMFACustomDuration(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, ...) (*sdk.AuthSession, error)
- func NewSessionXSRFToken(store cache.Store, sessionID string, sessionExpirationDelaySecond int) (string, error)
- func SessionCleaner(ctx context.Context, dbFunc func() *gorp.DbMap, tickerDuration time.Duration)
- func SetSessionActivity(store cache.Store, durationMFA time.Duration, sessionID string) error
- func SignJWS(content interface{}, now time.Time, duration time.Duration) (string, error)
- func SignJWT(jwtToken *jwt.Token) (string, error)
- func UnsafeLoadCorruptedSessions(ctx context.Context, db gorp.SqlExecutor) ([]sdk.AuthSession, error)
- func UpdateConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sdk.AuthConsumer) error
- func UpdateConsumerLastAuthentication(ctx context.Context, db gorp.SqlExecutor, ac *sdk.AuthConsumer) error
- func VerifyJWS(signature string, content interface{}) error
- func VerifyJWT(token *jwt.Token) (interface{}, error)
- type LoadConsumerOptionFunc
- type LoadSessionOptionFunc
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
GetSessionXSRFToken returns a XSRF token from cache if exists for given session.
func GetSigningKey ¶
func GetSigningKey() *rsa.PrivateKey
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 ¶
NewDefaultSigninStateToken returns a jws used for signin request.
func NewSession ¶
func NewSession(ctx context.Context, db gorpmapper.SqlExecutorWithTx, c *sdk.AuthConsumer, duration time.Duration) (*sdk.AuthSession, error)
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 ¶
SessionCleaner must be run as a goroutine
func SetSessionActivity ¶
SetSessionActivity store activity in cache for given session.
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
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.