auth_token

package
v0.0.0-...-7edcfce Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AccessTokenName = "access-token"
View Source
const CheckTokenProtocol = "check_token"
View Source
const ErrorCodeInvalidToken = "auth_token_invalid"
View Source
const ErrorCodeRefreshDisabled = "refresh_disabled"
View Source
const ErrorCodeSessionExpired = "session_expired"
View Source
const ErrorCodeTokenExpired = "auth_token_expired"
View Source
const ErrorCodeUnknownUser = "unknown_user"
View Source
const NewTokenProtocol = "new_token"
View Source
const RefreshTokenName = "refresh-token"
View Source
const TokenProtocol = "token"

Variables

View Source
var ErrorDescriptions = map[string]string{
	ErrorCodeTokenExpired:    "Provided authentication token expired",
	ErrorCodeInvalidToken:    "Invalid authentication token",
	ErrorCodeSessionExpired:  "Session expired",
	ErrorCodeUnknownUser:     "Unknown user",
	ErrorCodeRefreshDisabled: "Refresh disabled",
}

Functions

func AddManualSession

func AddManualSession(ctx op_context.Context, cipher auth.AuthParameterEncryption, tenancyID string, users auth_session.WithUserSessionManager, login string, ttlSeconds int, tokenName ...string) (auth_session.Session, string, error)

func GenManualToken

func GenManualToken(ctx op_context.Context, cipher auth.AuthParameterEncryption, tenancyID string, user auth.User, sesisonID string, expirationSeconds int, tokenType string) (string, error)

func RefreshRequired

func RefreshRequired(code string) bool

func ReloginRequired

func ReloginRequired(code string) bool

Types

type AuthNewTokenHandler

type AuthNewTokenHandler struct {
	AuthTokenHandler
}

func (*AuthNewTokenHandler) Handle

func (a *AuthNewTokenHandler) Handle(ctx auth.AuthContext) (bool, error)

func (*AuthNewTokenHandler) Init

func (a *AuthNewTokenHandler) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

func (*AuthNewTokenHandler) Process

func (a *AuthNewTokenHandler) Process(ctx auth.AuthContext) (bool, *Token, error)

type AuthTokenHandler

type AuthTokenHandler struct {
	auth.AuthHandlerBase
	AuthTokenHandlerConfig
	// contains filtered or unexported fields
}

func (*AuthTokenHandler) Config

func (a *AuthTokenHandler) Config() interface{}

func (*AuthTokenHandler) ErrorDescriptions

func (a *AuthTokenHandler) ErrorDescriptions() map[string]string

func (*AuthTokenHandler) ErrorProtocolCodes

func (a *AuthTokenHandler) ErrorProtocolCodes() map[string]int

func (*AuthTokenHandler) GenAccessToken

func (a *AuthTokenHandler) GenAccessToken(ctx auth.AuthContext) (*Token, error)

func (*AuthTokenHandler) GenRefreshToken

func (a *AuthTokenHandler) GenRefreshToken(ctx auth.AuthContext, session auth_session.Session) (*Token, error)

func (*AuthTokenHandler) GenToken

func (a *AuthTokenHandler) GenToken(ctx auth.AuthContext, paramName string, expirationSeconds int) (*Token, error)

func (*AuthTokenHandler) Handle

func (a *AuthTokenHandler) Handle(ctx auth.AuthContext) (bool, error)

func (*AuthTokenHandler) Init

func (a *AuthTokenHandler) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

func (*AuthTokenHandler) SessionExpiration

func (a *AuthTokenHandler) SessionExpiration() time.Time

func (*AuthTokenHandler) SetAuthManager

func (a *AuthTokenHandler) SetAuthManager(manager auth.AuthManager)

type AuthTokenHandlerConfig

type AuthTokenHandlerConfig struct {
	ACCESS_TOKEN_TTL_SECONDS        int    `default:"900" validate:"gt=0"`
	REFRESH_TOKEN_TTL_SECONDS       int    `default:"43200" validate:"gt=0"`
	ACCESS_TOKEN_GEN_BEFORE_SECONDS int    `default:"60" validate:"gt=0"`
	AUTO_PROLONGATE_ACCESS          bool   `default:"true"`
	AUTO_PROLONGATE_REFRESH         bool   `default:"true"`
	REFRESH_PATH                    string `default:"/auth/refresh"`
	LOGOUT_PATH                     string `default:"/auth/logout"`

	ACCESS_TOKEN_NAME string `default:"access-token"`
	DIRECT_TOKEN_NAME bool

	DISABLE_REFRESH bool
}

type Token

type Token struct {
	auth.ExpireToken
	Id          string `json:"id"`
	UserId      string `json:"user_id"`
	UserDisplay string `json:"user_display"`
	SessionId   string `json:"session_id"`
	Tenancy     string `json:"tenancy"`
	Type        string `json:"type"`
}

type TokenSchema

type TokenSchema struct {
	auth.AuthSchema

	Token *AuthTokenHandler
}

func (*TokenSchema) Handlers

func (t *TokenSchema) Handlers() []auth.AuthHandler

func (*TokenSchema) Init

func (t *TokenSchema) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

func (*TokenSchema) SetAuthManager

func (t *TokenSchema) SetAuthManager(manager auth.AuthManager)

Jump to

Keyboard shortcuts

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