Documentation
¶
Index ¶
- Constants
- Variables
- type CreateTokenCommand
- type CreateTokenErr
- type ExternalSession
- type ExternalSessionStore
- type IDClaims
- type IDService
- type IDSigner
- type JWTVerifierService
- type ListExternalSessionQuery
- type RevokeAuthTokenCmd
- type RotateCommand
- type TokenExpiredError
- type TokenRevokedError
- type UpdateExternalSessionCommand
- type UserToken
- type UserTokenBackgroundService
- type UserTokenService
Constants ¶
View Source
const ( QuotaTargetSrv quota.TargetSrv = "auth" QuotaTarget quota.Target = "session" )
Variables ¶
View Source
var ( ErrUserTokenNotFound = errors.New("user token not found") ErrInvalidSessionToken = usertoken.ErrInvalidSessionToken ErrExternalSessionNotFound = errors.New("external session not found") )
Typed errors
Functions ¶
This section is empty.
Types ¶
type CreateTokenCommand ¶
type CreateTokenErr ¶
CreateTokenErr represents a token creation error; used in Enterprise
func (*CreateTokenErr) Error ¶
func (e *CreateTokenErr) Error() string
type ExternalSession ¶
type ExternalSession struct {
ID int64 `xorm:"pk autoincr 'id'"`
UserID int64 `xorm:"user_id"`
UserAuthID int64 `xorm:"user_auth_id"`
AuthModule string `xorm:"auth_module"`
AccessToken string `xorm:"access_token"`
IDToken string `xorm:"id_token"`
RefreshToken string `xorm:"refresh_token"`
SessionID string `xorm:"session_id"`
SessionIDHash string `xorm:"session_id_hash"`
NameID string `xorm:"name_id"`
NameIDHash string `xorm:"name_id_hash"`
ExpiresAt time.Time `xorm:"expires_at"`
CreatedAt time.Time `xorm:"created 'created_at'"`
}
func (*ExternalSession) Clone ¶
func (e *ExternalSession) Clone() *ExternalSession
func (*ExternalSession) TableName ¶
func (e *ExternalSession) TableName() string
type ExternalSessionStore ¶
type ExternalSessionStore interface {
// Get returns the external session
Get(ctx context.Context, ID int64) (*ExternalSession, error)
// List returns all external sessions fπor the given query
List(ctx context.Context, query *ListExternalSessionQuery) ([]*ExternalSession, error)
// Create creates a new external session for a user
Create(ctx context.Context, extSesion *ExternalSession) error
// Update updates an external session
Update(ctx context.Context, ID int64, cmd *UpdateExternalSessionCommand) error
// Delete deletes an external session
Delete(ctx context.Context, ID int64) error
// DeleteExternalSessionsByUserID deletes an external session
DeleteExternalSessionsByUserID(ctx context.Context, userID int64) error
// BatchDeleteExternalSessionsByUserIDs deletes external sessions by user IDs
BatchDeleteExternalSessionsByUserIDs(ctx context.Context, userIDs []int64) error
}
type IDService ¶
type IDService interface {
// SignIdentity signs a id token for provided identity that can be forwarded to plugins and external services
SignIdentity(ctx context.Context, id identity.Requester) (string, *authnlib.Claims[authnlib.IDTokenClaims], error)
// RemoveIDToken removes any locally stored id tokens for key
RemoveIDToken(ctx context.Context, identity identity.Requester) error
}
type JWTVerifierService ¶
type JWTVerifierService = jwt.JWTService
type RevokeAuthTokenCmd ¶
type RevokeAuthTokenCmd struct {
AuthTokenId int64 `json:"authTokenId"`
}
type RotateCommand ¶
type TokenExpiredError ¶
func (*TokenExpiredError) Error ¶
func (e *TokenExpiredError) Error() string
func (*TokenExpiredError) Unwrap ¶
func (e *TokenExpiredError) Unwrap() error
type TokenRevokedError ¶
type TokenRevokedError = usertoken.TokenRevokedError
type UserTokenBackgroundService ¶
type UserTokenBackgroundService interface {
registry.BackgroundService
}
type UserTokenService ¶
type UserTokenService interface {
CreateToken(ctx context.Context, cmd *CreateTokenCommand) (*UserToken, error)
LookupToken(ctx context.Context, unhashedToken string) (*UserToken, error)
GetTokenByExternalSessionID(ctx context.Context, externalSessionID int64) (*UserToken, error)
GetExternalSession(ctx context.Context, externalSessionID int64) (*ExternalSession, error)
FindExternalSessions(ctx context.Context, query *ListExternalSessionQuery) ([]*ExternalSession, error)
UpdateExternalSession(ctx context.Context, externalSessionID int64, cmd *UpdateExternalSessionCommand) error
// RotateToken will always rotate a valid token
RotateToken(ctx context.Context, cmd RotateCommand) (*UserToken, error)
RevokeToken(ctx context.Context, token *UserToken, soft bool) error
RevokeAllUserTokens(ctx context.Context, userID int64) error
GetUserToken(ctx context.Context, userID, userTokenID int64) (*UserToken, error)
GetUserTokens(ctx context.Context, userID int64) ([]*UserToken, error)
ActiveTokenCount(ctx context.Context, userID *int64) (int64, error)
GetUserRevokedTokens(ctx context.Context, userID int64) ([]*UserToken, error)
}
UserTokenService are used for generating and validating user tokens
Click to show internal directories.
Click to hide internal directories.