auth

package
v0.0.0-cloud Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: AGPL-3.0 Imports: 9 Imported by: 85

Documentation

Index

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
)

Typed errors

Functions

This section is empty.

Types

type CreateTokenErr

type CreateTokenErr struct {
	StatusCode  int
	InternalErr error
	ExternalErr string
}

CreateTokenErr represents a token creation error; used in Enterprise

func (*CreateTokenErr) Error

func (e *CreateTokenErr) Error() string

type JWTVerifierService

type JWTVerifierService = jwt.JWTService

type RevokeAuthTokenCmd

type RevokeAuthTokenCmd struct {
	AuthTokenId int64 `json:"authTokenId"`
}

type RotateCommand

type RotateCommand struct {
	// token is the un-hashed token
	UnHashedToken string
	IP            net.IP
	UserAgent     string
}

type TokenExpiredError

type TokenExpiredError struct {
	UserID  int64
	TokenID int64
}

func (*TokenExpiredError) Error

func (e *TokenExpiredError) Error() string

func (*TokenExpiredError) Unwrap

func (e *TokenExpiredError) Unwrap() error

type TokenRevokedError

type TokenRevokedError = usertoken.TokenRevokedError

type UserToken

type UserToken = usertoken.UserToken

type UserTokenBackgroundService

type UserTokenBackgroundService interface {
	registry.BackgroundService
}

type UserTokenService

type UserTokenService interface {
	CreateToken(ctx context.Context, user *user.User, clientIP net.IP, userAgent string) (*UserToken, error)
	LookupToken(ctx context.Context, unhashedToken string) (*UserToken, error)
	// RotateToken will always rotate a valid token
	RotateToken(ctx context.Context, cmd RotateCommand) (*UserToken, error)
	TryRotateToken(ctx context.Context, token *UserToken, clientIP net.IP, userAgent string) (bool, *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)
	GetUserRevokedTokens(ctx context.Context, userId int64) ([]*UserToken, error)
}

UserTokenService are used for generating and validating user tokens

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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