chi

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2025/12/22 15:56:00

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2026/06/05

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

@Author daixk 2025/12/22 15:56:00

Index

Constants

View Source
const (
	Version                        = corepkg.Version
	SameSiteStrict                 = config.SameSiteStrict
	SameSiteLax                    = config.SameSiteLax
	SameSiteNone                   = config.SameSiteNone
	ConcurrencyScopeAccount        = config.ConcurrencyScopeAccount
	ConcurrencyScopeDevice         = config.ConcurrencyScopeDevice
	ReplacedLoginModeOldDevice     = config.ReplacedLoginExitModeOldDevice
	ReplacedLoginModeNewDevice     = config.ReplacedLoginExitModeNewDevice
	ReplacedLoginExitModeOldDevice = config.ReplacedLoginExitModeOldDevice
	ReplacedLoginExitModeNewDevice = config.ReplacedLoginExitModeNewDevice
	LogoutModeLogout               = config.LogoutModeLogout
	LogoutModeKickout              = config.LogoutModeKickout
	LogoutModeReplaced             = config.LogoutModeReplaced
	DefaultTokenName               = config.DefaultTokenName
	DefaultKeyPrefix               = config.DefaultKeyPrefix
	DefaultAuthType                = config.DefaultAuthType
	TokenKeyPrefix                 = config.TokenKeyPrefix
	DefaultTimeout                 = config.DefaultTimeout
	DefaultRefreshTokenTimeout     = config.DefaultRefreshTokenTimeout
	DefaultJWTSecretKey            = config.DefaultJWTSecretKey
	DefaultMaxLoginCount           = config.DefaultMaxLoginCount
	DefaultCookiePath              = config.DefaultCookiePath
	NoLimit                        = config.NoLimit
	DefaultNonceTTL                = nonce.DefaultNonceTTL
	NonceLength                    = nonce.NonceLength
	NonceKeySuffix                 = nonce.NonceKeySuffix
	DefaultAccessTTL               = nonce.DefaultAccessTTL
	TokenStyleUUID                 = adapter.TokenStyleUUID
	TokenStyleSimple               = adapter.TokenStyleSimple
	TokenStyleRandom32             = adapter.TokenStyleRandom32
	TokenStyleRandom64             = adapter.TokenStyleRandom64
	TokenStyleRandom128            = adapter.TokenStyleRandom128
	TokenStyleJWT                  = adapter.TokenStyleJWT
	TokenStyleHash                 = adapter.TokenStyleHash
	TokenStyleTimestamp            = adapter.TokenStyleTimestamp
	TokenStyleTik                  = adapter.TokenStyleTik
	LogLevelDebug                  = adapter.LogLevelDebug
	LogLevelInfo                   = adapter.LogLevelInfo
	LogLevelWarn                   = adapter.LogLevelWarn
	LogLevelError                  = adapter.LogLevelError
	EventLogin                     = listener.EventLogin
	EventLogout                    = listener.EventLogout
	EventKickout                   = listener.EventKickout
	EventReplace                   = listener.EventReplace
	EventDisable                   = listener.EventDisable
	EventUntie                     = listener.EventUntie
	EventRenew                     = listener.EventRenew
	EventCreateSession             = listener.EventCreateSession
	EventDestroySession            = listener.EventDestroySession
	EventPermissionCheck           = listener.EventPermissionCheck
	EventPermissionChange          = listener.EventPermissionChange
	EventRoleCheck                 = listener.EventRoleCheck
	EventRoleChange                = listener.EventRoleChange
	EventDisableService            = listener.EventDisableService
	EventUntieService              = listener.EventUntieService
	EventDisableDevice             = listener.EventDisableDevice
	EventUntieDevice               = listener.EventUntieDevice
	EventRefreshTokenCreate        = listener.EventRefreshTokenCreate
	EventRefreshTokenRotate        = listener.EventRefreshTokenRotate
	EventRefreshTokenRevoke        = listener.EventRefreshTokenRevoke
	EventNonceGenerate             = listener.EventNonceGenerate
	EventNonceVerify               = listener.EventNonceVerify
	EventTicketCreate              = listener.EventTicketCreate
	EventTicketValidate            = listener.EventTicketValidate
	EventTicketConsume             = listener.EventTicketConsume
	EventTicketRevoke              = listener.EventTicketRevoke
	EventShortKeyCreate            = listener.EventShortKeyCreate
	EventShortKeyConfirm           = listener.EventShortKeyConfirm
	EventShortKeyValidate          = listener.EventShortKeyValidate
	EventShortKeyConsume           = listener.EventShortKeyConsume
	EventShortKeyRevoke            = listener.EventShortKeyRevoke
	EventOAuth2ClientRegister      = listener.EventOAuth2ClientRegister
	EventOAuth2ClientUnregister    = listener.EventOAuth2ClientUnregister
	EventOAuth2CodeGenerate        = listener.EventOAuth2CodeGenerate
	EventOAuth2TokenIssue          = listener.EventOAuth2TokenIssue
	EventOAuth2TokenRefresh        = listener.EventOAuth2TokenRefresh
	EventOAuth2TokenValidate       = listener.EventOAuth2TokenValidate
	EventOAuth2TokenRevoke         = listener.EventOAuth2TokenRevoke
	EventAll                       = listener.EventAll
	ExtraKeyPermission             = listener.ExtraKeyPermission
	ExtraKeyPermissions            = listener.ExtraKeyPermissions
	ExtraKeyRole                   = listener.ExtraKeyRole
	ExtraKeyRoles                  = listener.ExtraKeyRoles
	ExtraKeyLogic                  = listener.ExtraKeyLogic
	ExtraKeyResult                 = listener.ExtraKeyResult
	ExtraKeyAction                 = listener.ExtraKeyAction
	ExtraKeyShared                 = listener.ExtraKeyShared
	ExtraKeyService                = listener.ExtraKeyService
	ExtraKeyLevel                  = listener.ExtraKeyLevel
	ExtraKeyTokenType              = listener.ExtraKeyTokenType
	ExtraKeyClientID               = listener.ExtraKeyClientID
	ExtraKeyUserID                 = listener.ExtraKeyUserID
	ExtraKeyScopes                 = listener.ExtraKeyScopes
	ExtraKeySource                 = listener.ExtraKeySource
	ExtraKeySourceApp              = listener.ExtraKeySourceApp
	ExtraKeyTargetApp              = listener.ExtraKeyTargetApp
	ExtraKeyScene                  = listener.ExtraKeyScene
	ExtraKeyStatus                 = listener.ExtraKeyStatus
	ExtraKeyTTL                    = listener.ExtraKeyTTL
	ExtraKeyRefreshToken           = listener.ExtraKeyRefreshToken
	ExtraKeyGrantType              = listener.ExtraKeyGrantType
	EventLogicAnd                  = listener.LogicAnd
	EventLogicOr                   = listener.LogicOr
	ActionAdd                      = listener.ActionAdd
	ActionRemove                   = listener.ActionRemove
	ActionCreate                   = listener.ActionCreate
	ActionValidate                 = listener.ActionValidate
	ActionConsume                  = listener.ActionConsume
	ActionRevoke                   = listener.ActionRevoke
	ActionConfirm                  = listener.ActionConfirm
	ActionRotate                   = listener.ActionRotate
	ActionRegister                 = listener.ActionRegister
	ActionUnregister               = listener.ActionUnregister
	ActionIssue                    = listener.ActionIssue
	ActionRefresh                  = listener.ActionRefresh
	DisableKeyPrefix               = manager.DisableKeyPrefix
	DisableServiceKeyPrefix        = manager.DisableServiceKeyPrefix
	DisableDeviceKeyPrefix         = manager.DisableDeviceKeyPrefix
	DisableDeviceIDKeyPrefix       = manager.DisableDeviceIDKeyPrefix
	SessionKeyPrefix               = manager.SessionKeyPrefix
	RenewKeyPrefix                 = manager.RenewKeyPrefix
	ActivePrefix                   = manager.ActivePrefix
	RefreshTokenKeyPrefix          = manager.RefreshTokenKeyPrefix
	TokenRefreshKeyPrefix          = manager.TokenRefreshKeyPrefix
	SessionKeyLoginID              = manager.SessionKeyLoginID
	SessionKeyDevice               = manager.SessionKeyDevice
	SessionKeyLoginTime            = manager.SessionKeyLoginTime
	SessionKeyPermissions          = manager.SessionKeyPermissions
	SessionKeyRoles                = manager.SessionKeyRoles
	PermissionWildcard             = manager.PermissionWildcard
	PermissionSeparator            = manager.PermissionSeparator
	TokenStateLogout               = manager.TokenStateLogout
	TokenStateKickOut              = manager.TokenStateKickOut
	TokenStateReplaced             = manager.TokenStateReplaced
	TokenStateActiveTimeout        = manager.TokenStateActiveTimeout
	DefaultCodeExpiration          = oauth2.DefaultCodeExpiration
	DefaultTokenExpiration         = oauth2.DefaultTokenExpiration
	DefaultRefreshTTL              = oauth2.DefaultRefreshTTL
	CodeLength                     = oauth2.CodeLength
	AccessTokenLength              = oauth2.AccessTokenLength
	RefreshTokenLength             = oauth2.RefreshTokenLength
	CodeKeySuffix                  = oauth2.CodeKeySuffix
	OAuth2TokenKeySuffix           = oauth2.TokenKeySuffix
	OAuth2RefreshKeySuffix         = oauth2.RefreshKeySuffix
	ClientKeySuffix                = oauth2.ClientKeySuffix
	GrantTypeAuthorizationCode     = oauth2.GrantTypeAuthorizationCode
	GrantTypeRefreshToken          = oauth2.GrantTypeRefreshToken
	GrantTypeClientCredentials     = oauth2.GrantTypeClientCredentials
	GrantTypePassword              = oauth2.GrantTypePassword
	CodeChallengeMethodPlain       = oauth2.CodeChallengeMethodPlain
	CodeChallengeMethodS256        = oauth2.CodeChallengeMethodS256
	TokenTypeBearer                = oauth2.TokenTypeBearer
	TTLNoExpire                    = adapter.TTLNoExpire
	TTLNotFound                    = adapter.TTLNotFound
)

Common constants forward core configuration values. Common 常量转发核心配置值。 Common 常量转发核心配置值。

View Source
const (
	CodeSuccess          = derror.CodeSuccess
	CodeBadRequest       = derror.CodeBadRequest
	CodeNotLogin         = derror.CodeNotLogin
	CodePermissionDenied = derror.CodePermissionDenied
	CodeNotFound         = derror.CodeNotFound
	CodeServerError      = derror.CodeServerError
	CodeTokenInvalid     = derror.CodeTokenInvalid
	CodeTokenExpired     = derror.CodeTokenExpired
	CodeAccountDisabled  = derror.CodeAccountDisabled
	CodeKickedOut        = derror.CodeKickedOut
	CodeActiveTimeout    = derror.CodeActiveTimeout
	CodeMaxLoginCount    = derror.CodeMaxLoginCount
	CodeStorageError     = derror.CodeStorageError
	CodeInvalidParameter = derror.CodeInvalidParameter
)

DToken error codes.

Variables

View Source
var (
	New                            = dtoken.New
	Default                        = dtoken.Default
	MustDefault                    = dtoken.MustDefault
	NewByAuthType                  = dtoken.NewByAuthType
	LoginWithOptions               = dtoken.LoginWithOptions
	LoginWithRefreshTokenOptions   = dtoken.LoginWithRefreshTokenOptions
	LogoutWithOptions              = dtoken.LogoutWithOptions
	KickoutWithOptions             = dtoken.KickoutWithOptions
	ReplaceWithOptions             = dtoken.ReplaceWithOptions
	DisableWithOptions             = dtoken.DisableWithOptions
	DisableServiceWithOptions      = dtoken.DisableServiceWithOptions
	DisableDeviceWithOptions       = dtoken.DisableDeviceWithOptions
	AddPermissionsWithOptions      = dtoken.AddPermissionsWithOptions
	RemovePermissionsWithOptions   = dtoken.RemovePermissionsWithOptions
	CheckPermissionWithOptions     = dtoken.CheckPermissionWithOptions
	CheckPermissionsAndWithOptions = dtoken.CheckPermissionsAndWithOptions
	CheckPermissionsOrWithOptions  = dtoken.CheckPermissionsOrWithOptions
	AddRolesWithOptions            = dtoken.AddRolesWithOptions
	RemoveRolesWithOptions         = dtoken.RemoveRolesWithOptions
	CheckRoleWithOptions           = dtoken.CheckRoleWithOptions
	CheckRolesAndWithOptions       = dtoken.CheckRolesAndWithOptions
	CheckRolesOrWithOptions        = dtoken.CheckRolesOrWithOptions
)

Instance and typed global operations.

View Source
var (
	NewDTokenBuilder               = dtoken.NewBuilder
	BuildAndSetManager             = dtoken.BuildAndSetManager
	DefaultConfig                  = config.DefaultConfig
	DefaultCookieConfig            = config.DefaultCookieConfig
	NewContext                     = corecontext.NewContext
	NewManager                     = manager.NewManager
	WithNonceManager               = manager.WithNonceManager
	WithOAuth2Manager              = manager.WithOAuth2Manager
	NewEventManager                = listener.NewManager
	DefaultNonceConfig             = nonce.DefaultConfig
	NewDefaultNonceManager         = nonce.NewDefaultNonceManager
	NewNonceManagerWithConfig      = nonce.NewNonceManagerWithConfig
	NewNonceManager                = nonce.NewNonceManager
	DefaultOAuth2Config            = oauth2.DefaultConfig
	NewDefaultOAuth2Server         = oauth2.NewDefaultOAuth2Server
	NewOAuth2ServerWithConfig      = oauth2.NewOAuth2ServerWithConfig
	NewOAuth2Server                = oauth2.NewOAuth2Server
	NewRedisStorage                = redisstorage.NewStorage
	NewRedisStorageFromConfig      = redisstorage.NewStorageFromConfig
	NewRedisStorageFromClient      = redisstorage.NewStorageFromClient
	NewStorageFromConfig           = redisstorage.NewStorageFromConfig
	NewStorageFromClient           = redisstorage.NewStorageFromClient
	NewMemoryStorage               = memorystorage.NewStorage
	NewJSONSerializer              = jsoncodec.NewJSONSerializer
	NewBase64Serializer            = base64codec.NewBase64Serializer
	NewMsgPackSerializer           = msgpackcodec.NewMsgPackSerializer
	NewDefaultTokenGenerator       = dgenerator.NewDefaultGenerator
	NewTokenGenerator              = dgenerator.NewGenerator
	DefaultLoggerConfig            = dlog.DefaultLoggerConfig
	NewLoggerWithConfig            = dlog.NewLoggerWithConfig
	DefaultRenewPoolConfig         = ants.DefaultRenewPoolConfig
	NewRenewPoolManagerWithDefault = ants.NewRenewPoolManagerWithDefaultConfig
	NewRenewPoolManagerWithConfig  = ants.NewRenewPoolManagerWithConfig
	NewNopLogger                   = nop.NewNopLogger
	NewAdapterNopLogger            = adapter.NewNopLogger
)

Component constructors forward bundled implementations. Component 构造器转发内置实现。

View Source
var (
	NewDTokenError                  = derror.NewDTokenError
	ErrStorageUnavailable           = derror.ErrStorageUnavailable
	ErrKeyNotFound                  = derror.ErrKeyNotFound
	ErrSerializeFailed              = derror.ErrSerializeFailed
	ErrTypeConvert                  = derror.ErrTypeConvert
	ErrManagerNotFound              = derror.ErrManagerNotFound
	ErrManagerInvalidType           = derror.ErrManagerInvalidType
	ErrInvalidParam                 = derror.ErrInvalidParam
	ErrStorageCapabilityUnsupported = derror.ErrStorageCapabilityUnsupported
	ErrIDIsEmpty                    = derror.ErrIDIsEmpty
	ErrEmptyLoginID                 = derror.ErrEmptyLoginID
	ErrAccountDisabled              = derror.ErrAccountDisabled
	ErrAccountNotDisabled           = derror.ErrAccountNotDisabled
	ErrLoginLimitExceeded           = derror.ErrLoginLimitExceeded
	ErrNotLogin                     = derror.ErrNotLogin
	ErrInvalidToken                 = derror.ErrInvalidToken
	ErrTokenExpired                 = derror.ErrTokenExpired
	ErrActiveTimeout                = derror.ErrActiveTimeout
	ErrTokenKickout                 = derror.ErrTokenKickout
	ErrTokenReplaced                = derror.ErrTokenReplaced
	ErrInvalidDevice                = derror.ErrInvalidDevice
	ErrPermissionDenied             = derror.ErrPermissionDenied
	ErrRoleDenied                   = derror.ErrRoleDenied
	ErrServiceDisabled              = derror.ErrServiceDisabled
	ErrServiceNotDisabled           = derror.ErrServiceNotDisabled
	ErrDeviceDisabled               = derror.ErrDeviceDisabled
	ErrDeviceNotDisabled            = derror.ErrDeviceNotDisabled
	ErrDisableLevelNotReached       = derror.ErrDisableLevelNotReached
	ErrSessionNotFound              = derror.ErrSessionNotFound
	ErrInvalidNonce                 = derror.ErrInvalidNonce
	ErrClientOrClientIDEmpty        = derror.ErrClientOrClientIDEmpty
	ErrClientNotFound               = derror.ErrClientNotFound
	ErrInvalidClientCredentials     = derror.ErrInvalidClientCredentials
	ErrInvalidGrantType             = derror.ErrInvalidGrantType
	ErrInvalidRedirectURI           = derror.ErrInvalidRedirectURI
	ErrInvalidScope                 = derror.ErrInvalidScope
	ErrUserIDEmpty                  = derror.ErrUserIDEmpty
	ErrInvalidAuthCode              = derror.ErrInvalidAuthCode
	ErrAuthCodeUsed                 = derror.ErrAuthCodeUsed
	ErrAuthCodeExpired              = derror.ErrAuthCodeExpired
	ErrClientMismatch               = derror.ErrClientMismatch
	ErrRedirectURIMismatch          = derror.ErrRedirectURIMismatch
	ErrInvalidRefreshToken          = derror.ErrInvalidRefreshToken
	ErrInvalidAccessToken           = derror.ErrInvalidAccessToken
	ErrInvalidUserCredentials       = derror.ErrInvalidUserCredentials
	ErrInvalidCodeVerifier          = derror.ErrInvalidCodeVerifier
)

DToken error helpers and values.

View Source
var (
	SetManager                                = dtoken.SetManager
	GetManager                                = dtoken.GetManager
	GetEventManager                           = dtoken.GetEventManager
	DeleteManager                             = dtoken.DeleteManager
	DeleteAllManager                          = dtoken.DeleteAllManager
	Login                                     = dtoken.Login
	LoginWithTimeout                          = dtoken.LoginWithTimeout
	LoginWithRefreshToken                     = dtoken.LoginWithRefreshToken
	RefreshToken                              = dtoken.RefreshToken
	RevokeRefreshToken                        = dtoken.RevokeRefreshToken
	GetRefreshTokenTTL                        = dtoken.GetRefreshTokenTTL
	IntrospectToken                           = dtoken.IntrospectToken
	LoginByToken                              = dtoken.LoginByToken
	Logout                                    = dtoken.Logout
	LogoutByDeviceAndDeviceId                 = dtoken.LogoutByDeviceAndDeviceId
	LogoutByDevice                            = dtoken.LogoutByDevice
	LogoutByLoginID                           = dtoken.LogoutByLoginID
	Kickout                                   = dtoken.Kickout
	Replace                                   = dtoken.Replace
	KickoutByDeviceAndDeviceId                = dtoken.KickoutByDeviceAndDeviceId
	KickoutByDevice                           = dtoken.KickoutByDevice
	KickoutByLoginID                          = dtoken.KickoutByLoginID
	ReplaceByDeviceAndDeviceId                = dtoken.ReplaceByDeviceAndDeviceId
	ReplaceByDevice                           = dtoken.ReplaceByDevice
	ReplaceByLoginID                          = dtoken.ReplaceByLoginID
	IsLogin                                   = dtoken.IsLogin
	CheckLogin                                = dtoken.CheckLogin
	GetLoginID                                = dtoken.GetLoginID
	GetTokenInfo                              = dtoken.GetTokenInfo
	GetDevice                                 = dtoken.GetDevice
	GetDeviceId                               = dtoken.GetDeviceId
	GetTokenCreateTime                        = dtoken.GetTokenCreateTime
	GetTokenTTL                               = dtoken.GetTokenTTL
	GetOnlineTerminalCount                    = dtoken.GetOnlineTerminalCount
	GetOnlineTerminalCountByDevice            = dtoken.GetOnlineTerminalCountByDevice
	GetOnlineTerminalCountByDeviceAndDeviceId = dtoken.GetOnlineTerminalCountByDeviceAndDeviceId
	Disable                                   = dtoken.Disable
	Untie                                     = dtoken.Untie
	IsDisable                                 = dtoken.IsDisable
	GetDisableInfo                            = dtoken.GetDisableInfo
	GetDisableTTL                             = dtoken.GetDisableTTL
	DisableService                            = dtoken.DisableService
	DisableServiceWithReason                  = dtoken.DisableServiceWithReason
	DisableServiceLevel                       = dtoken.DisableServiceLevel
	DisableServiceLevelWithReason             = dtoken.DisableServiceLevelWithReason
	UntieService                              = dtoken.UntieService
	IsDisableService                          = dtoken.IsDisableService
	IsDisableServiceLevel                     = dtoken.IsDisableServiceLevel
	CheckDisableService                       = dtoken.CheckDisableService
	CheckDisableServiceLevel                  = dtoken.CheckDisableServiceLevel
	GetDisableServiceInfo                     = dtoken.GetDisableServiceInfo
	GetDisableServiceTTL                      = dtoken.GetDisableServiceTTL
	DisableDevice                             = dtoken.DisableDevice
	DisableDeviceWithReason                   = dtoken.DisableDeviceWithReason
	DisableDeviceAndDeviceId                  = dtoken.DisableDeviceAndDeviceId
	DisableDeviceAndDeviceIdWithReason        = dtoken.DisableDeviceAndDeviceIdWithReason
	UntieDevice                               = dtoken.UntieDevice
	UntieDeviceAndDeviceId                    = dtoken.UntieDeviceAndDeviceId
	IsDisableDevice                           = dtoken.IsDisableDevice
	IsDisableDeviceAndDeviceId                = dtoken.IsDisableDeviceAndDeviceId
	CheckDisableDevice                        = dtoken.CheckDisableDevice
	CheckDisableDeviceAndDeviceId             = dtoken.CheckDisableDeviceAndDeviceId
	GetDisableDeviceInfo                      = dtoken.GetDisableDeviceInfo
	GetDisableDeviceAndDeviceIdInfo           = dtoken.GetDisableDeviceAndDeviceIdInfo
	GetDisableDeviceTTL                       = dtoken.GetDisableDeviceTTL
	GetDisableDeviceAndDeviceIdTTL            = dtoken.GetDisableDeviceAndDeviceIdTTL
	CheckPermission                           = dtoken.CheckPermission
	CheckPermissionAnd                        = dtoken.CheckPermissionAnd
	CheckPermissionOr                         = dtoken.CheckPermissionOr
	CheckRole                                 = dtoken.CheckRole
	CheckRoleAnd                              = dtoken.CheckRoleAnd
	CheckRoleOr                               = dtoken.CheckRoleOr
	CheckDisable                              = dtoken.CheckDisable
	RenewTimeout                              = dtoken.RenewTimeout
	ForEachTerminal                           = dtoken.ForEachTerminal
	ForEachTerminalByDevice                   = dtoken.ForEachTerminalByDevice
	GetSession                                = dtoken.GetSession
	GetSessionByToken                         = dtoken.GetSessionByToken
	GetTokenValueListByLoginID                = dtoken.GetTokenValueListByLoginID
	GetTokenValueListByDeviceAndDeviceId      = dtoken.GetTokenValueListByDeviceAndDeviceId
	GetTokenValueListByDevice                 = dtoken.GetTokenValueListByDevice
	GetTerminalListByLoginID                  = dtoken.GetTerminalListByLoginID
	GetTerminalListByLoginIDAndDevice         = dtoken.GetTerminalListByLoginIDAndDevice
	GetTerminalInfoByToken                    = dtoken.GetTerminalInfoByToken
	GetTokenValueByLoginID                    = dtoken.GetTokenValueByLoginID
	GetTokenValueByLoginIDAndDevice           = dtoken.GetTokenValueByLoginIDAndDevice
	SearchTokenValue                          = dtoken.SearchTokenValue
	SearchSessionId                           = dtoken.SearchSessionId
	AddPermissions                            = dtoken.AddPermissions
	AddPermissionsByToken                     = dtoken.AddPermissionsByToken
	RemovePermissions                         = dtoken.RemovePermissions
	RemovePermissionsByToken                  = dtoken.RemovePermissionsByToken
	GetPermissions                            = dtoken.GetPermissions
	GetPermissionsByToken                     = dtoken.GetPermissionsByToken
	HasPermission                             = dtoken.HasPermission
	HasPermissionByToken                      = dtoken.HasPermissionByToken
	HasPermissionsAnd                         = dtoken.HasPermissionsAnd
	HasPermissionsAndByToken                  = dtoken.HasPermissionsAndByToken
	HasPermissionsOr                          = dtoken.HasPermissionsOr
	HasPermissionsOrByToken                   = dtoken.HasPermissionsOrByToken
	AddRoles                                  = dtoken.AddRoles
	AddRolesByToken                           = dtoken.AddRolesByToken
	RemoveRoles                               = dtoken.RemoveRoles
	RemoveRolesByToken                        = dtoken.RemoveRolesByToken
	GetRoles                                  = dtoken.GetRoles
	GetRolesByToken                           = dtoken.GetRolesByToken
	HasRole                                   = dtoken.HasRole
	HasRoleByToken                            = dtoken.HasRoleByToken
	HasRolesAnd                               = dtoken.HasRolesAnd
	HasRolesAndByToken                        = dtoken.HasRolesAndByToken
	HasRolesOr                                = dtoken.HasRolesOr
	HasRolesOrByToken                         = dtoken.HasRolesOrByToken
	GenerateNonce                             = dtoken.GenerateNonce
	GenerateNonceWithTimeout                  = dtoken.GenerateNonceWithTimeout
	VerifyNonce                               = dtoken.VerifyNonce
	VerifyAndConsumeNonce                     = dtoken.VerifyAndConsumeNonce
	IsNonceValid                              = dtoken.IsNonceValid
	GetNonceTTL                               = dtoken.GetNonceTTL
	RegisterOAuth2Client                      = dtoken.RegisterOAuth2Client
	UnregisterOAuth2Client                    = dtoken.UnregisterOAuth2Client
	GetOAuth2Client                           = dtoken.GetOAuth2Client
	OAuth2Token                               = dtoken.OAuth2Token
	GenerateOAuth2AuthorizationCode           = dtoken.GenerateOAuth2AuthorizationCode
	GenerateOAuth2AuthorizationCodeWithPKCE   = dtoken.GenerateOAuth2AuthorizationCodeWithPKCE
	ExchangeOAuth2CodeForToken                = dtoken.ExchangeOAuth2CodeForToken
	ExchangeOAuth2CodeForTokenWithPKCE        = dtoken.ExchangeOAuth2CodeForTokenWithPKCE
	OAuth2ClientCredentialsToken              = dtoken.OAuth2ClientCredentialsToken
	OAuth2PasswordGrantToken                  = dtoken.OAuth2PasswordGrantToken
	RefreshOAuth2AccessToken                  = dtoken.RefreshOAuth2AccessToken
	ValidateOAuth2AccessToken                 = dtoken.ValidateOAuth2AccessToken
	ValidateOAuth2AccessTokenAndGetInfo       = dtoken.ValidateOAuth2AccessTokenAndGetInfo
	RevokeOAuth2Token                         = dtoken.RevokeOAuth2Token
)

DToken operations forward all exported dtoken APIs DToken 鎿嶄綔杞彂 dtoken 鐨勫叏閮ㄥ叕寮€ API銆?

View Source
var (
	CheckPermissionByToken      = dtoken.CheckPermissionByToken
	CheckPermissionAndByToken   = dtoken.CheckPermissionAndByToken
	CheckPermissionOrByToken    = dtoken.CheckPermissionOrByToken
	CheckRoleByToken            = dtoken.CheckRoleByToken
	CheckRoleAndByToken         = dtoken.CheckRoleAndByToken
	CheckRoleOrByToken          = dtoken.CheckRoleOrByToken
	SetSessionValue             = dtoken.SetSessionValue
	GetSessionValue             = dtoken.GetSessionValue
	DeleteSessionValue          = dtoken.DeleteSessionValue
	CreateTicket                = dtoken.CreateTicket
	CreateTicketWithOptions     = dtoken.CreateTicketWithOptions
	ValidateTicket              = dtoken.ValidateTicket
	ValidateTicketWithOptions   = dtoken.ValidateTicketWithOptions
	ConsumeTicket               = dtoken.ConsumeTicket
	ConsumeTicketWithOptions    = dtoken.ConsumeTicketWithOptions
	RevokeTicket                = dtoken.RevokeTicket
	GetTicketStatus             = dtoken.GetTicketStatus
	GetTicketTTL                = dtoken.GetTicketTTL
	CreateShortKey              = dtoken.CreateShortKey
	CreateShortKeyWithOptions   = dtoken.CreateShortKeyWithOptions
	ConfirmShortKey             = dtoken.ConfirmShortKey
	ConfirmShortKeyWithOptions  = dtoken.ConfirmShortKeyWithOptions
	ValidateShortKey            = dtoken.ValidateShortKey
	ValidateShortKeyWithOptions = dtoken.ValidateShortKeyWithOptions
	ConsumeShortKey             = dtoken.ConsumeShortKey
	ConsumeShortKeyWithOptions  = dtoken.ConsumeShortKeyWithOptions
	RevokeShortKey              = dtoken.RevokeShortKey
	GetShortKeyStatus           = dtoken.GetShortKeyStatus
	GetShortKeyTTL              = dtoken.GetShortKeyTTL
)

Additional facade operations keep framework imports self-contained. Additional facade 操作保持框架包自包含。

Functions

func AccessMiddleware added in v0.0.3

func AccessMiddleware(opts ...AuthOption) func(http.Handler) http.Handler

AccessMiddleware resolves route rules and checks login, permissions, and roles AccessMiddleware 解析路由规则并校验登录、权限、角色

func AddPermissionsByCtx

func AddPermissionsByCtx(ctx context.Context, permissions []string) error

AddPermissionsByCtx adds permissions to current token AddPermissionsByCtx 为当前 token 添加权限。

func AddRolesByCtx

func AddRolesByCtx(ctx context.Context, roles []string) error

AddRolesByCtx adds roles to current token AddRolesByCtx 为当前 token 添加角色。

func AuthGroup

func AuthGroup(group chiRouter.Router, opts ...AuthOption) chiRouter.Router

AuthGroup creates auth route group AuthGroup 创建认证路由组

func AuthMiddleware

func AuthMiddleware(opts ...AuthOption) func(http.Handler) http.Handler

AuthMiddleware checks login status AuthMiddleware 校验登录状态

func CheckAllHandler

func CheckAllHandler(roles []string, perms []string) http.HandlerFunc

CheckAllHandler creates combined auth handler CheckAllHandler 创建组合认证检查处理器

func CheckDisableByCtx added in v0.0.3

func CheckDisableByCtx(ctx context.Context) error

CheckDisableByCtx checks current account disable state CheckDisableByCtx ?

func CheckDisableDeviceAndDeviceIDByCtx added in v0.0.3

func CheckDisableDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string) error

CheckDisableDeviceAndDeviceIDByCtx checks current account device ID disable state CheckDisableDeviceAndDeviceIDByCtx ID ?

func CheckDisableDeviceByCtx added in v0.0.3

func CheckDisableDeviceByCtx(ctx context.Context, device string) error

CheckDisableDeviceByCtx checks current account device disable state CheckDisableDeviceByCtx ?

func CheckDisableHandler

func CheckDisableHandler(authType ...string) http.HandlerFunc

CheckDisableHandler creates disable check handler CheckDisableHandler 创建封禁检查处理器

func CheckDisableServiceByCtx added in v0.0.3

func CheckDisableServiceByCtx(ctx context.Context, services ...string) error

CheckDisableServiceByCtx checks current account service disable state CheckDisableServiceByCtx ?

func CheckDisableServiceLevelByCtx added in v0.0.3

func CheckDisableServiceLevelByCtx(ctx context.Context, service string, level int) error

CheckDisableServiceLevelByCtx checks current account service level disable state CheckDisableServiceLevelByCtx ?

func CheckLoginAndPermissionHandler

func CheckLoginAndPermissionHandler(perms ...string) http.HandlerFunc

CheckLoginAndPermissionHandler creates login and permission handler CheckLoginAndPermissionHandler 创建登录与权限检查处理器

func CheckLoginAndRoleHandler

func CheckLoginAndRoleHandler(roles ...string) http.HandlerFunc

CheckLoginAndRoleHandler creates login and role handler CheckLoginAndRoleHandler 创建登录与角色检查处理器

func CheckLoginByCtx

func CheckLoginByCtx(ctx context.Context) error

CheckLoginByCtx checks current request login state CheckLoginByCtx 校验当前请求登录状态。

func CheckLoginHandler

func CheckLoginHandler(authType ...string) http.HandlerFunc

CheckLoginHandler creates login check handler CheckLoginHandler 创建登录检查处理器

func CheckPermissionByCtx added in v0.0.3

func CheckPermissionByCtx(ctx context.Context, permission string) error

CheckPermissionByCtx checks current user permission CheckPermissionByCtx

func CheckPermissionHandler

func CheckPermissionHandler(perms ...string) http.HandlerFunc

CheckPermissionHandler creates permission check handler CheckPermissionHandler 创建权限检查处理器

func CheckPermissionHandlerWithAuthType

func CheckPermissionHandlerWithAuthType(authType string, perms ...string) http.HandlerFunc

CheckPermissionHandlerWithAuthType creates permission check handler CheckPermissionHandlerWithAuthType 创建带认证类型的权限检查处理器

func CheckPermissionsAndByCtx added in v0.0.3

func CheckPermissionsAndByCtx(ctx context.Context, permissions []string) error

CheckPermissionsAndByCtx delegates to DToken context CheckPermissionsAndByCtx 转发到 DToken 上下文。

func CheckPermissionsOrByCtx added in v0.0.3

func CheckPermissionsOrByCtx(ctx context.Context, permissions []string) error

CheckPermissionsOrByCtx delegates to DToken context CheckPermissionsOrByCtx 转发到 DToken 上下文。

func CheckRoleByCtx added in v0.0.3

func CheckRoleByCtx(ctx context.Context, role string) error

CheckRoleByCtx checks current user role CheckRoleByCtx

func CheckRoleHandler

func CheckRoleHandler(roles ...string) http.HandlerFunc

CheckRoleHandler creates role check handler CheckRoleHandler 创建角色检查处理器

func CheckRoleHandlerWithAuthType

func CheckRoleHandlerWithAuthType(authType string, roles ...string) http.HandlerFunc

CheckRoleHandlerWithAuthType creates role check handler CheckRoleHandlerWithAuthType 创建带认证类型的角色检查处理器

func CheckRolesAndByCtx added in v0.0.3

func CheckRolesAndByCtx(ctx context.Context, roles []string) error

CheckRolesAndByCtx delegates to DToken context CheckRolesAndByCtx 转发到 DToken 上下文。

func CheckRolesOrByCtx added in v0.0.3

func CheckRolesOrByCtx(ctx context.Context, roles []string) error

CheckRolesOrByCtx delegates to DToken context CheckRolesOrByCtx 转发到 DToken 上下文。

func ClearTokenCookieByCtx added in v0.0.3

func ClearTokenCookieByCtx(ctx context.Context) error

ClearTokenCookieByCtx clears token cookie ClearTokenCookieByCtx ?Token Cookie

func ConfirmShortKeyByCtx added in v0.0.3

func ConfirmShortKeyByCtx(ctx context.Context, key string, opts shortkey.ConfirmOptions) (*shortkey.ShortKey, error)

ConfirmShortKeyByCtx confirms short key ConfirmShortKeyByCtx ?Key

func ConfirmShortKeyForCurrentLoginByCtx added in v0.0.3

func ConfirmShortKeyForCurrentLoginByCtx(ctx context.Context, key string, opts shortkey.ConfirmOptions) (*shortkey.ShortKey, error)

ConfirmShortKeyForCurrentLoginByCtx confirms short key for current user ConfirmShortKeyForCurrentLoginByCtx ?Key

func ConsumeShortKeyByCtx added in v0.0.3

func ConsumeShortKeyByCtx(ctx context.Context, key string, opts ...shortkey.ValidateOptions) (*shortkey.ConsumeResult, error)

ConsumeShortKeyByCtx consumes short key ConsumeShortKeyByCtx ?Key

func ConsumeTicketByCtx added in v0.0.3

func ConsumeTicketByCtx(ctx context.Context, ticketValue string, opts ...ticket.ValidateOptions) (*ticket.ConsumeResult, error)

ConsumeTicketByCtx consumes ticket ConsumeTicketByCtx ?Ticket

func CreateShortKeyByCtx added in v0.0.3

func CreateShortKeyByCtx(ctx context.Context, opts shortkey.CreateOptions) (*shortkey.ShortKey, error)

CreateShortKeyByCtx creates short key CreateShortKeyByCtx ?Key

func CreateShortKeyWithTimeoutByCtx added in v0.0.3

func CreateShortKeyWithTimeoutByCtx(ctx context.Context, opts shortkey.CreateOptions, timeout time.Duration) (*shortkey.ShortKey, error)

CreateShortKeyWithTimeoutByCtx creates short key with timeout CreateShortKeyWithTimeoutByCtx ?Key

func CreateTicketByCtx added in v0.0.3

func CreateTicketByCtx(ctx context.Context, opts ticket.CreateOptions) (*ticket.Ticket, error)

CreateTicketByCtx creates ticket CreateTicketByCtx ?Ticket

func CreateTicketForCurrentLoginByCtx added in v0.0.3

func CreateTicketForCurrentLoginByCtx(ctx context.Context, opts ticket.CreateOptions) (*ticket.Ticket, error)

CreateTicketForCurrentLoginByCtx creates ticket for current user CreateTicketForCurrentLoginByCtx ?Ticket

func CreateTicketWithTimeoutByCtx added in v0.0.3

func CreateTicketWithTimeoutByCtx(ctx context.Context, opts ticket.CreateOptions, timeout time.Duration) (*ticket.Ticket, error)

CreateTicketWithTimeoutByCtx creates ticket with timeout CreateTicketWithTimeoutByCtx ?Ticket

func DeleteSessionValueByCtx added in v0.0.3

func DeleteSessionValueByCtx(ctx context.Context, key string) error

DeleteSessionValueByCtx deletes current session value DeleteSessionValueByCtx ?

func DisableByCtx

func DisableByCtx(ctx context.Context, duration time.Duration, reason ...string) error

DisableByCtx disables current user DisableByCtx 封禁当前用户。

func DisableDeviceAndDeviceIDByCtx added in v0.0.3

func DisableDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string, duration time.Duration, reason ...string) error

DisableDeviceAndDeviceIDByCtx delegates to DToken context DisableDeviceAndDeviceIDByCtx 转发到 DToken 上下文。

func DisableDeviceByCtx added in v0.0.3

func DisableDeviceByCtx(ctx context.Context, device string, duration time.Duration, reason ...string) error

DisableDeviceByCtx disables current account device DisableDeviceByCtx

func DisableServiceByCtx added in v0.0.3

func DisableServiceByCtx(ctx context.Context, service string, duration time.Duration, reason ...string) error

DisableServiceByCtx disables current account service DisableServiceByCtx

func DisableServiceLevelByCtx added in v0.0.3

func DisableServiceLevelByCtx(ctx context.Context, service string, level int, duration time.Duration, reason ...string) error

DisableServiceLevelByCtx disables current account service level DisableServiceLevelByCtx ?

func ExchangeOAuth2CodeForTokenByCtx added in v0.0.3

func ExchangeOAuth2CodeForTokenByCtx(ctx context.Context, code, clientID, clientSecret, redirectURI string) (*oauth2.AccessToken, error)

ExchangeOAuth2CodeForTokenByCtx exchanges OAuth2 code for token ExchangeOAuth2CodeForTokenByCtx OAuth2 ?Token

func ExchangeOAuth2CodeForTokenWithPKCEByCtx added in v0.0.3

func ExchangeOAuth2CodeForTokenWithPKCEByCtx(ctx context.Context, code, clientID, clientSecret, redirectURI, codeVerifier string) (*oauth2.AccessToken, error)

ExchangeOAuth2CodeForTokenWithPKCEByCtx exchanges OAuth2 code for token with PKCE ExchangeOAuth2CodeForTokenWithPKCEByCtx PKCE ?Token

func ForEachTerminalByCtx added in v0.0.3

func ForEachTerminalByCtx(ctx context.Context, visitor manager.TerminalVisitor) error

ForEachTerminalByCtx visits current user terminals ForEachTerminalByCtx

func ForEachTerminalByDeviceByCtx added in v0.0.3

func ForEachTerminalByDeviceByCtx(ctx context.Context, device string, visitor manager.TerminalVisitor) error

ForEachTerminalByDeviceByCtx visits current user terminals by device ForEachTerminalByDeviceByCtx ?

func GenerateNonceByCtx

func GenerateNonceByCtx(ctx context.Context) (string, error)

GenerateNonceByCtx generates nonce with current manager GenerateNonceByCtx 使用当前管理器生成 nonce。

func GenerateNonceWithTimeoutByCtx added in v0.0.3

func GenerateNonceWithTimeoutByCtx(ctx context.Context, timeout time.Duration) (string, error)

GenerateNonceWithTimeoutByCtx generates nonce with timeout GenerateNonceWithTimeoutByCtx ?Nonce

func GenerateOAuth2AuthorizationCodeByCtx added in v0.0.3

func GenerateOAuth2AuthorizationCodeByCtx(ctx context.Context, clientID, userID, redirectURI string, scopes []string) (*oauth2.AuthorizationCode, error)

GenerateOAuth2AuthorizationCodeByCtx delegates to DToken context GenerateOAuth2AuthorizationCodeByCtx 转发到 DToken 上下文。

func GenerateOAuth2AuthorizationCodeWithPKCEByCtx added in v0.0.3

func GenerateOAuth2AuthorizationCodeWithPKCEByCtx(ctx context.Context, clientID, userID, redirectURI string, scopes []string, codeChallenge, codeChallengeMethod string) (*oauth2.AuthorizationCode, error)

GenerateOAuth2AuthorizationCodeWithPKCEByCtx delegates to DToken context GenerateOAuth2AuthorizationCodeWithPKCEByCtx 转发到 DToken 上下文。

func GetDTokenContext

func GetDTokenContext(r *http.Request) (*DContext.DTokenContext, bool)

GetDTokenContext gets cached DToken context GetDTokenContext 获取缓存的 DToken 上下文

func GetDTokenContextByCtx

func GetDTokenContextByCtx(ctx context.Context) (*DContext.DTokenContext, bool)

GetDTokenContextByCtx gets DToken context by context GetDTokenContextByCtx 从上下文获取 DToken 上下文

func GetDeviceByCtx

func GetDeviceByCtx(ctx context.Context) (string, error)

GetDeviceByCtx gets current token device GetDeviceByCtx 获取当前 token 设备类型。

func GetDeviceIDByCtx

func GetDeviceIDByCtx(ctx context.Context) (string, error)

GetDeviceIDByCtx gets current token device id GetDeviceIDByCtx 获取当前 token 设备 ID。

func GetDisableDeviceAndDeviceIDInfoByCtx added in v0.0.3

func GetDisableDeviceAndDeviceIDInfoByCtx(ctx context.Context, device, deviceId string) (*manager.DeviceDisableInfo, error)

GetDisableDeviceAndDeviceIDInfoByCtx gets current account device ID disable info GetDisableDeviceAndDeviceIDInfoByCtx ID

func GetDisableDeviceAndDeviceIDTTLByCtx added in v0.0.3

func GetDisableDeviceAndDeviceIDTTLByCtx(ctx context.Context, device, deviceId string) (int64, error)

GetDisableDeviceAndDeviceIDTTLByCtx gets current account device ID disable TTL GetDisableDeviceAndDeviceIDTTLByCtx ID

func GetDisableDeviceInfoByCtx added in v0.0.3

func GetDisableDeviceInfoByCtx(ctx context.Context, device string) (*manager.DeviceDisableInfo, error)

GetDisableDeviceInfoByCtx gets current account device disable info GetDisableDeviceInfoByCtx

func GetDisableDeviceTTLByCtx added in v0.0.3

func GetDisableDeviceTTLByCtx(ctx context.Context, device string) (int64, error)

GetDisableDeviceTTLByCtx gets current account device disable TTL GetDisableDeviceTTLByCtx

func GetDisableInfoByCtx

func GetDisableInfoByCtx(ctx context.Context) (*manager.DisableInfo, error)

GetDisableInfoByCtx gets current user disable info GetDisableInfoByCtx 获取当前用户封禁信息。

func GetDisableServiceInfoByCtx added in v0.0.3

func GetDisableServiceInfoByCtx(ctx context.Context, service string) (*manager.ServiceDisableInfo, error)

GetDisableServiceInfoByCtx gets current account service disable info GetDisableServiceInfoByCtx

func GetDisableServiceTTLByCtx added in v0.0.3

func GetDisableServiceTTLByCtx(ctx context.Context, service string) (int64, error)

GetDisableServiceTTLByCtx gets current account service disable TTL GetDisableServiceTTLByCtx

func GetDisableTTLByCtx

func GetDisableTTLByCtx(ctx context.Context) (int64, error)

GetDisableTTLByCtx gets current user disable ttl GetDisableTTLByCtx 获取当前用户封禁剩余时间。

func GetHandler

func GetHandler(handler http.HandlerFunc, annotations ...*Annotation) http.HandlerFunc

GetHandler gets annotation handler GetHandler 获取注解处理器

func GetLatestTokenValueByCtx added in v0.0.3

func GetLatestTokenValueByCtx(ctx context.Context, device ...string) (string, error)

GetLatestTokenValueByCtx gets latest current user token GetLatestTokenValueByCtx ?Token

func GetLoginIDByCtx

func GetLoginIDByCtx(ctx context.Context) (string, error)

GetLoginIDByCtx gets login ID by context GetLoginIDByCtx 从上下文获取登录 ID

func GetLoginIDFromRequest

func GetLoginIDFromRequest(w http.ResponseWriter, r *http.Request, authType ...string) (string, error)

GetLoginIDFromRequest gets login ID from request GetLoginIDFromRequest 从请求获取登录 ID

func GetManagerByCtx added in v0.0.3

func GetManagerByCtx(ctx context.Context) (*manager.Manager, error)

GetManagerByCtx gets current DToken manager GetManagerByCtx 获取当前 DToken 管理器。

func GetNonceTTLByCtx added in v0.0.3

func GetNonceTTLByCtx(ctx context.Context, nonce string) (int64, error)

GetNonceTTLByCtx gets nonce TTL GetNonceTTLByCtx ?Nonce ?

func GetOAuth2ClientByCtx added in v0.0.3

func GetOAuth2ClientByCtx(ctx context.Context, clientID string) (*oauth2.Client, error)

GetOAuth2ClientByCtx delegates to DToken context GetOAuth2ClientByCtx 转发到 DToken 上下文。

func GetOnlineTerminalCountByCtx

func GetOnlineTerminalCountByCtx(ctx context.Context) (int, error)

GetOnlineTerminalCountByCtx gets current user online terminal count GetOnlineTerminalCountByCtx 获取当前用户在线终端数量。

func GetOnlineTerminalCountByDeviceAndDeviceIDByCtx added in v0.0.3

func GetOnlineTerminalCountByDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string) (int, error)

GetOnlineTerminalCountByDeviceAndDeviceIDByCtx gets online count by device ID GetOnlineTerminalCountByDeviceAndDeviceIDByCtx ?ID ?

func GetOnlineTerminalCountByDeviceByCtx added in v0.0.3

func GetOnlineTerminalCountByDeviceByCtx(ctx context.Context, device string) (int, error)

GetOnlineTerminalCountByDeviceByCtx delegates to DToken context GetOnlineTerminalCountByDeviceByCtx 转发到 DToken 上下文。

func GetPermissionsByCtx

func GetPermissionsByCtx(ctx context.Context) ([]string, error)

GetPermissionsByCtx gets current user permissions GetPermissionsByCtx 获取当前用户权限列表。

func GetPermissionsByTokenByCtx

func GetPermissionsByTokenByCtx(ctx context.Context) ([]string, error)

GetPermissionsByTokenByCtx gets current token permissions GetPermissionsByTokenByCtx 使用当前 token 获取权限列表。

func GetRefreshTokenTTLByCtx added in v0.0.3

func GetRefreshTokenTTLByCtx(ctx context.Context, refreshToken string) (int64, error)

GetRefreshTokenTTLByCtx gets refresh token TTL GetRefreshTokenTTLByCtx Token ?

func GetRequestContextByCtx added in v0.0.3

func GetRequestContextByCtx(ctx context.Context) (adapter.RequestContext, error)

GetRequestContextByCtx gets raw request context GetRequestContextByCtx 获取原始请求上下文。

func GetRolesByCtx

func GetRolesByCtx(ctx context.Context) ([]string, error)

GetRolesByCtx gets current user roles GetRolesByCtx 获取当前用户角色列表。

func GetRolesByTokenByCtx

func GetRolesByTokenByCtx(ctx context.Context) ([]string, error)

GetRolesByTokenByCtx gets current token roles GetRolesByTokenByCtx 使用当前 token 获取角色列表。

func GetSessionByCtx

func GetSessionByCtx(ctx context.Context) (*manager.Session, error)

GetSessionByCtx gets current user session GetSessionByCtx 获取当前用户会话。

func GetSessionByTokenByCtx

func GetSessionByTokenByCtx(ctx context.Context) (*manager.Session, error)

GetSessionByTokenByCtx gets current token session GetSessionByTokenByCtx 获取当前 token 会话。

func GetSessionValueByCtx added in v0.0.3

func GetSessionValueByCtx(ctx context.Context, key string) (any, bool, error)

GetSessionValueByCtx gets current session value GetSessionValueByCtx ?

func GetShortKeyStatusByCtx added in v0.0.3

func GetShortKeyStatusByCtx(ctx context.Context, key string) (shortkey.Status, error)

GetShortKeyStatusByCtx gets short key status GetShortKeyStatusByCtx ?Key ?

func GetShortKeyTTLByCtx added in v0.0.3

func GetShortKeyTTLByCtx(ctx context.Context, key string) (int64, error)

GetShortKeyTTLByCtx gets short key TTL GetShortKeyTTLByCtx ?Key ?

func GetTerminalInfoByCtx added in v0.0.3

func GetTerminalInfoByCtx(ctx context.Context) (*manager.TerminalInfo, error)

GetTerminalInfoByCtx gets current terminal info GetTerminalInfoByCtx

func GetTerminalListByCtx added in v0.0.3

func GetTerminalListByCtx(ctx context.Context, device ...string) ([]manager.TerminalInfo, error)

GetTerminalListByCtx delegates to DToken context GetTerminalListByCtx 转发到 DToken 上下文。

func GetTicketStatusByCtx added in v0.0.3

func GetTicketStatusByCtx(ctx context.Context, ticketValue string) (ticket.Status, error)

GetTicketStatusByCtx gets ticket status GetTicketStatusByCtx ?Ticket ?

func GetTicketTTLByCtx added in v0.0.3

func GetTicketTTLByCtx(ctx context.Context, ticketValue string) (int64, error)

GetTicketTTLByCtx gets ticket TTL GetTicketTTLByCtx ?Ticket ?

func GetTokenCreateTimeByCtx

func GetTokenCreateTimeByCtx(ctx context.Context) (int64, error)

GetTokenCreateTimeByCtx gets current token create time GetTokenCreateTimeByCtx 获取当前 token 创建时间。

func GetTokenFromRequest

func GetTokenFromRequest(w http.ResponseWriter, r *http.Request, authType ...string) string

GetTokenFromRequest gets token from request GetTokenFromRequest 从请求获取 Token

func GetTokenInfoByCtx

func GetTokenInfoByCtx(ctx context.Context) (*manager.TokenInfo, error)

GetTokenInfoByCtx gets token info by context GetTokenInfoByCtx 从上下文获取 Token 信息

func GetTokenTTLByCtx

func GetTokenTTLByCtx(ctx context.Context) (int64, error)

GetTokenTTLByCtx gets current token TTL GetTokenTTLByCtx 获取当前 token 剩余有效期。

func GetTokenValueByCtx

func GetTokenValueByCtx(ctx context.Context) (string, error)

GetTokenValueByCtx gets token value from current Chi context GetTokenValueByCtx 从当前 Chi 上下文获取 token 值。

func GetTokenValueListByCtx

func GetTokenValueListByCtx(ctx context.Context, checkAlive ...bool) ([]string, error)

GetTokenValueListByCtx gets current user token list GetTokenValueListByCtx 获取当前用户 token 列表。

func GetTokenValueListByDeviceAndDeviceIDByCtx added in v0.0.3

func GetTokenValueListByDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string, checkAlive ...bool) ([]string, error)

GetTokenValueListByDeviceAndDeviceIDByCtx delegates to DToken context GetTokenValueListByDeviceAndDeviceIDByCtx 转发到 DToken 上下文。

func GetTokenValueListByDeviceByCtx added in v0.0.3

func GetTokenValueListByDeviceByCtx(ctx context.Context, device string, checkAlive ...bool) ([]string, error)

GetTokenValueListByDeviceByCtx delegates to DToken context GetTokenValueListByDeviceByCtx 转发到 DToken 上下文。

func HasPermissionByCtx

func HasPermissionByCtx(ctx context.Context, permission string) bool

HasPermissionByCtx checks current user permission HasPermissionByCtx 检查当前用户权限。

func HasPermissionsAndByCtx

func HasPermissionsAndByCtx(ctx context.Context, permissions []string) bool

HasPermissionsAndByCtx checks whether current user has all permissions HasPermissionsAndByCtx 检查当前用户是否拥有全部权限。

func HasPermissionsByCtx

func HasPermissionsByCtx(ctx context.Context, permissions []string) bool

HasPermissionsByCtx checks whether current user has any permission HasPermissionsByCtx 检查当前用户是否拥有任一权限。

func HasPermissionsOrByCtx

func HasPermissionsOrByCtx(ctx context.Context, permissions []string) bool

HasPermissionsOrByCtx checks whether current user has any permission HasPermissionsOrByCtx 检查当前用户是否拥有任一权限。

func HasRoleByCtx

func HasRoleByCtx(ctx context.Context, role string) bool

HasRoleByCtx checks current user role HasRoleByCtx 检查当前用户角色。

func HasRolesAndByCtx

func HasRolesAndByCtx(ctx context.Context, roles []string) bool

HasRolesAndByCtx checks whether current user has all roles HasRolesAndByCtx 检查当前用户是否拥有全部角色。

func HasRolesByCtx

func HasRolesByCtx(ctx context.Context, roles []string) bool

HasRolesByCtx checks whether current user has any role HasRolesByCtx 检查当前用户是否拥有任一角色。

func HasRolesOrByCtx

func HasRolesOrByCtx(ctx context.Context, roles []string) bool

HasRolesOrByCtx checks whether current user has any role HasRolesOrByCtx 检查当前用户是否拥有任一角色。

func IgnoreHandler

func IgnoreHandler() http.HandlerFunc

IgnoreHandler creates ignore auth handler IgnoreHandler 创建忽略认证处理器

func IntrospectTokenByCtx added in v0.0.3

func IntrospectTokenByCtx(ctx context.Context) (*manager.TokenIntrospection, error)

IntrospectTokenByCtx inspects current token without renewal side effects IntrospectTokenByCtx 无续期副作用地检查当前 token 状态

func IsDisableByCtx

func IsDisableByCtx(ctx context.Context) bool

IsDisableByCtx checks whether current user is disabled IsDisableByCtx 检查当前用户是否被封禁。

func IsDisableDeviceAndDeviceIDByCtx added in v0.0.3

func IsDisableDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string) bool

IsDisableDeviceAndDeviceIDByCtx checks current account device ID disable state IsDisableDeviceAndDeviceIDByCtx ?ID ?

func IsDisableDeviceByCtx added in v0.0.3

func IsDisableDeviceByCtx(ctx context.Context, device string) bool

IsDisableDeviceByCtx checks current account device disable state IsDisableDeviceByCtx ?

func IsDisableServiceByCtx added in v0.0.3

func IsDisableServiceByCtx(ctx context.Context, service string) bool

IsDisableServiceByCtx checks current account service disable state IsDisableServiceByCtx ?

func IsDisableServiceLevelByCtx added in v0.0.3

func IsDisableServiceLevelByCtx(ctx context.Context, service string, level int) bool

IsDisableServiceLevelByCtx checks current account service level disable state IsDisableServiceLevelByCtx ?

func IsLoginByCtx

func IsLoginByCtx(ctx context.Context) bool

IsLoginByCtx checks current request login state IsLoginByCtx 检查当前请求登录状态。

func IsLoginFromRequest

func IsLoginFromRequest(w http.ResponseWriter, r *http.Request, authType ...string) bool

IsLoginFromRequest checks login state from request IsLoginFromRequest 从请求检查登录状态

func IsValidNonceByCtx added in v0.0.3

func IsValidNonceByCtx(ctx context.Context, nonce string) bool

IsValidNonceByCtx checks nonce state IsValidNonceByCtx ?Nonce ?

func KickoutByCtx

func KickoutByCtx(ctx context.Context) error

KickoutByCtx kicks out current request token KickoutByCtx 踢出当前请求 token。

func KickoutByDeviceAndDeviceIDByCtx added in v0.0.3

func KickoutByDeviceAndDeviceIDByCtx(ctx context.Context, deviceAndDeviceId ...string) error

KickoutByDeviceAndDeviceIDByCtx delegates to DToken context KickoutByDeviceAndDeviceIDByCtx 转发到 DToken 上下文。

func KickoutByDeviceByCtx added in v0.0.3

func KickoutByDeviceByCtx(ctx context.Context, device string) error

KickoutByDeviceByCtx kicks out current user by device KickoutByDeviceByCtx ?

func KickoutByLoginIDByCtx added in v0.0.3

func KickoutByLoginIDByCtx(ctx context.Context) error

KickoutByLoginIDByCtx delegates to DToken context KickoutByLoginIDByCtx 转发到 DToken 上下文。

func LoginByCtx added in v0.0.3

func LoginByCtx(ctx context.Context, loginID string, deviceAndDeviceId ...string) (string, error)

LoginByCtx logs in current Chi request LoginByCtx Chi

func LoginByTokenByCtx

func LoginByTokenByCtx(ctx context.Context) error

LoginByTokenByCtx renews current token login state LoginByTokenByCtx 使用当前 token 续期登录态。

func LoginWithCookieByCtx added in v0.0.3

func LoginWithCookieByCtx(ctx context.Context, loginID string, deviceAndDeviceId ...string) (string, error)

LoginWithCookieByCtx logs in and writes token cookie LoginWithCookieByCtx ?Token Cookie

func LoginWithCookieOptionsByCtx added in v0.0.3

func LoginWithCookieOptionsByCtx(ctx context.Context, opts manager.LoginOptions) (string, error)

LoginWithCookieOptionsByCtx logs in with options and writes token cookie LoginWithCookieOptionsByCtx ?Token Cookie

func LoginWithCookieTimeoutByCtx added in v0.0.3

func LoginWithCookieTimeoutByCtx(ctx context.Context, loginID string, timeout time.Duration, deviceAndDeviceId ...string) (string, error)

LoginWithCookieTimeoutByCtx logs in with timeout and writes token cookie LoginWithCookieTimeoutByCtx Token Cookie

func LoginWithOptionsByCtx added in v0.0.3

func LoginWithOptionsByCtx(ctx context.Context, opts manager.LoginOptions) (string, error)

LoginWithOptionsByCtx logs in current Chi request with options LoginWithOptionsByCtx Chi

func LoginWithRefreshTokenByCtx added in v0.0.3

func LoginWithRefreshTokenByCtx(ctx context.Context, loginID string, deviceAndDeviceId ...string) (*manager.RefreshTokenPair, error)

LoginWithRefreshTokenByCtx logs in and issues refresh token LoginWithRefreshTokenByCtx ?Token

func LoginWithRefreshTokenOptionsByCtx added in v0.0.3

func LoginWithRefreshTokenOptionsByCtx(ctx context.Context, opts manager.RefreshTokenOptions) (*manager.RefreshTokenPair, error)

LoginWithRefreshTokenOptionsByCtx logs in with refresh token options LoginWithRefreshTokenOptionsByCtx Token

func LoginWithTimeoutByCtx added in v0.0.3

func LoginWithTimeoutByCtx(ctx context.Context, loginID string, timeout time.Duration, deviceAndDeviceId ...string) (string, error)

LoginWithTimeoutByCtx logs in current Chi request with timeout LoginWithTimeoutByCtx Chi

func LogoutByCtx

func LogoutByCtx(ctx context.Context) error

LogoutByCtx logs out current request token LogoutByCtx 登出当前请求 token。

func LogoutByDeviceAndDeviceIdByCtx

func LogoutByDeviceAndDeviceIdByCtx(ctx context.Context, deviceAndDeviceId ...string) error

LogoutByDeviceAndDeviceIdByCtx logs out current user by device and id LogoutByDeviceAndDeviceIdByCtx 按设备和设备 ID 登出当前用户。

func LogoutByDeviceByCtx

func LogoutByDeviceByCtx(ctx context.Context, device string) error

LogoutByDeviceByCtx logs out current user by device LogoutByDeviceByCtx 按设备登出当前用户。

func LogoutByLoginIDByCtx

func LogoutByLoginIDByCtx(ctx context.Context) error

LogoutByLoginIDByCtx logs out all terminals of current user LogoutByLoginIDByCtx 登出当前用户所有终端。

func LogoutWithCookieByCtx added in v0.0.3

func LogoutWithCookieByCtx(ctx context.Context) error

LogoutWithCookieByCtx logs out and clears token cookie LogoutWithCookieByCtx ?Token Cookie

func NewBuilder

func NewBuilder() *builder.Builder

NewBuilder creates a default DToken builder NewBuilder 鍒涘缓榛樿 DToken 鏋勫缓鍣ㄣ€?

func NewChiContext

NewChiContext creates request context adapter NewChiContext 创建请求上下文适配器

func OAuth2ClientCredentialsTokenByCtx added in v0.0.3

func OAuth2ClientCredentialsTokenByCtx(ctx context.Context, clientID, clientSecret string, scopes []string) (*oauth2.AccessToken, error)

OAuth2ClientCredentialsTokenByCtx gets OAuth2 token by client credentials OAuth2ClientCredentialsTokenByCtx ?OAuth2 Token

func OAuth2PasswordGrantTokenByCtx added in v0.0.3

func OAuth2PasswordGrantTokenByCtx(ctx context.Context, clientID, clientSecret, username, password string, scopes []string, validateUser oauth2.UserValidator) (*oauth2.AccessToken, error)

OAuth2PasswordGrantTokenByCtx gets OAuth2 token by password grant OAuth2PasswordGrantTokenByCtx OAuth2 Token

func OAuth2TokenByCtx added in v0.0.3

func OAuth2TokenByCtx(ctx context.Context, req *oauth2.TokenRequest, validateUser oauth2.UserValidator) (*oauth2.AccessToken, error)

OAuth2TokenByCtx handles OAuth2 token request OAuth2TokenByCtx OAuth2 Token

func PermissionGroup

func PermissionGroup(group chiRouter.Router, perms []string, opts ...AuthOption) chiRouter.Router

PermissionGroup creates permission route group PermissionGroup 创建权限路由组

func PermissionMiddleware

func PermissionMiddleware(permissions []string, opts ...AuthOption) func(http.Handler) http.Handler

PermissionMiddleware checks permissions PermissionMiddleware 校验权限

func PermissionPathMiddleware

func PermissionPathMiddleware(permissions []string, opts ...AuthOption) func(http.Handler) http.Handler

PermissionPathMiddleware checks path permissions PermissionPathMiddleware 基于路径校验权限

func RefreshOAuth2AccessTokenByCtx added in v0.0.3

func RefreshOAuth2AccessTokenByCtx(ctx context.Context, clientID, refreshToken, clientSecret string) (*oauth2.AccessToken, error)

RefreshOAuth2AccessTokenByCtx refreshes OAuth2 access token RefreshOAuth2AccessTokenByCtx OAuth2 Token

func RefreshTokenByCtx added in v0.0.3

func RefreshTokenByCtx(ctx context.Context, refreshToken string) (*manager.RefreshTokenPair, error)

RefreshTokenByCtx refreshes access token RefreshTokenByCtx Token

func RegisterDTokenContextMiddleware

func RegisterDTokenContextMiddleware(opts ...AuthOption) func(http.Handler) http.Handler

RegisterDTokenContextMiddleware registers DToken context middleware RegisterDTokenContextMiddleware 注册 DToken 上下文中间件

func RegisterOAuth2ClientByCtx added in v0.0.3

func RegisterOAuth2ClientByCtx(ctx context.Context, client *oauth2.Client) error

RegisterOAuth2ClientByCtx delegates to DToken context RegisterOAuth2ClientByCtx 转发到 DToken 上下文。

func RemovePermissionsByCtx

func RemovePermissionsByCtx(ctx context.Context, permissions []string) error

RemovePermissionsByCtx removes permissions from current token RemovePermissionsByCtx 从当前 token 移除权限。

func RemoveRolesByCtx

func RemoveRolesByCtx(ctx context.Context, roles []string) error

RemoveRolesByCtx removes roles from current token RemoveRolesByCtx 从当前 token 移除角色。

func RenewTimeoutByCtx

func RenewTimeoutByCtx(ctx context.Context, timeout time.Duration) error

RenewTimeoutByCtx renews current token timeout RenewTimeoutByCtx 续期当前 token 过期时间。

func ReplaceByCtx

func ReplaceByCtx(ctx context.Context) error

ReplaceByCtx replaces current request token ReplaceByCtx 顶替当前请求 token。

func ReplaceByDeviceAndDeviceIDByCtx added in v0.0.3

func ReplaceByDeviceAndDeviceIDByCtx(ctx context.Context, deviceAndDeviceId ...string) error

ReplaceByDeviceAndDeviceIDByCtx delegates to DToken context ReplaceByDeviceAndDeviceIDByCtx 转发到 DToken 上下文。

func ReplaceByDeviceByCtx added in v0.0.3

func ReplaceByDeviceByCtx(ctx context.Context, device string) error

ReplaceByDeviceByCtx replaces current user by device ReplaceByDeviceByCtx ?

func ReplaceByLoginIDByCtx added in v0.0.3

func ReplaceByLoginIDByCtx(ctx context.Context) error

ReplaceByLoginIDByCtx delegates to DToken context ReplaceByLoginIDByCtx 转发到 DToken 上下文。

func RevokeOAuth2TokenByCtx added in v0.0.3

func RevokeOAuth2TokenByCtx(ctx context.Context, accessToken string) error

RevokeOAuth2TokenByCtx revokes OAuth2 token RevokeOAuth2TokenByCtx OAuth2 Token

func RevokeRefreshTokenByCtx added in v0.0.3

func RevokeRefreshTokenByCtx(ctx context.Context, refreshToken string) error

RevokeRefreshTokenByCtx revokes refresh token RevokeRefreshTokenByCtx Token

func RevokeShortKeyByCtx added in v0.0.3

func RevokeShortKeyByCtx(ctx context.Context, key string) error

RevokeShortKeyByCtx revokes short key RevokeShortKeyByCtx ?Key

func RevokeTicketByCtx added in v0.0.3

func RevokeTicketByCtx(ctx context.Context, ticketValue string) error

RevokeTicketByCtx revokes ticket RevokeTicketByCtx ?Ticket

func RoleAndPermissionGroup

func RoleAndPermissionGroup(group chiRouter.Router, roles []string, perms []string, opts ...AuthOption) chiRouter.Router

RoleAndPermissionGroup creates role and permission route group RoleAndPermissionGroup 创建角色与权限路由组

func RoleGroup

func RoleGroup(group chiRouter.Router, roles []string, opts ...AuthOption) chiRouter.Router

RoleGroup creates role route group RoleGroup 创建角色路由组

func RoleMiddleware

func RoleMiddleware(roles []string, opts ...AuthOption) func(http.Handler) http.Handler

RoleMiddleware checks roles RoleMiddleware 校验角色

func SearchSessionIDByCtx added in v0.0.3

func SearchSessionIDByCtx(ctx context.Context, keyword string, start, size int) ([]string, error)

SearchSessionIDByCtx searches session ids SearchSessionIDByCtx ?Session ID

func SearchTokenValueByCtx added in v0.0.3

func SearchTokenValueByCtx(ctx context.Context, keyword string, start, size int) ([]string, error)

SearchTokenValueByCtx searches token values SearchTokenValueByCtx ?Token ?

func SetSessionValueByCtx added in v0.0.3

func SetSessionValueByCtx(ctx context.Context, key string, value any) error

SetSessionValueByCtx sets current session value SetSessionValueByCtx ?

func SetTokenCookieByCtx added in v0.0.3

func SetTokenCookieByCtx(ctx context.Context, token string) error

SetTokenCookieByCtx writes token cookie SetTokenCookieByCtx ?Token Cookie

func TerminateByCtx added in v0.0.3

func TerminateByCtx(ctx context.Context, opts manager.TerminateOptions) error

TerminateByCtx terminates current or specified terminal TerminateByCtx ?

func UnregisterOAuth2ClientByCtx added in v0.0.3

func UnregisterOAuth2ClientByCtx(ctx context.Context, clientID string) error

UnregisterOAuth2ClientByCtx delegates to DToken context UnregisterOAuth2ClientByCtx 转发到 DToken 上下文。

func UntieByCtx

func UntieByCtx(ctx context.Context) error

UntieByCtx removes current user disable state UntieByCtx 解封当前用户。

func UntieDeviceAndDeviceIDByCtx added in v0.0.3

func UntieDeviceAndDeviceIDByCtx(ctx context.Context, device, deviceId string) error

UntieDeviceAndDeviceIDByCtx removes current account device ID disable state UntieDeviceAndDeviceIDByCtx ID

func UntieDeviceByCtx added in v0.0.3

func UntieDeviceByCtx(ctx context.Context, device string) error

UntieDeviceByCtx removes current account device disable state UntieDeviceByCtx

func UntieServiceByCtx added in v0.0.3

func UntieServiceByCtx(ctx context.Context, service string) error

UntieServiceByCtx removes current account service disable state UntieServiceByCtx

func ValidateOAuth2AccessTokenAndGetInfoByCtx added in v0.0.3

func ValidateOAuth2AccessTokenAndGetInfoByCtx(ctx context.Context, accessToken string) (*oauth2.AccessToken, error)

ValidateOAuth2AccessTokenAndGetInfoByCtx delegates to DToken context ValidateOAuth2AccessTokenAndGetInfoByCtx 转发到 DToken 上下文。

func ValidateOAuth2AccessTokenByCtx added in v0.0.3

func ValidateOAuth2AccessTokenByCtx(ctx context.Context, accessToken string) bool

ValidateOAuth2AccessTokenByCtx validates OAuth2 access token ValidateOAuth2AccessTokenByCtx OAuth2 Token

func ValidateShortKeyByCtx added in v0.0.3

func ValidateShortKeyByCtx(ctx context.Context, key string, opts ...shortkey.ValidateOptions) (*shortkey.ShortKey, error)

ValidateShortKeyByCtx validates short key ValidateShortKeyByCtx ?Key

func ValidateTicketByCtx added in v0.0.3

func ValidateTicketByCtx(ctx context.Context, ticketValue string, opts ...ticket.ValidateOptions) (*ticket.Ticket, error)

ValidateTicketByCtx validates ticket ValidateTicketByCtx ?Ticket

func VerifyAndConsumeNonceByCtx

func VerifyAndConsumeNonceByCtx(ctx context.Context, nonce string) error

VerifyAndConsumeNonceByCtx verifies and consumes nonce with current manager VerifyAndConsumeNonceByCtx 使用当前管理器验证并消费 nonce。

func VerifyNonceByCtx

func VerifyNonceByCtx(ctx context.Context, nonce string) bool

VerifyNonceByCtx verifies nonce with current manager VerifyNonceByCtx 使用当前管理器验证 nonce。

func WithContext

func WithContext(r *http.Request, authType ...string) context.Context

WithContext returns request context WithContext 返回请求上下文

Types

type AccessProvider

type AccessProvider = manager.AccessProvider

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type AccessProviderFunc

type AccessProviderFunc = manager.AccessProviderFunc

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type AccessSubject

type AccessSubject = manager.AccessSubject

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type AccessToken

type AccessToken = oauth2.AccessToken

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type AdminStorage

type AdminStorage = adapter.AdminStorage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Annotation

type Annotation struct {
	// AuthType specifies auth type AuthType 指定认证类型
	AuthType string `json:"authType"`
	// CheckLogin indicates login check CheckLogin 表示是否检查登录
	CheckLogin bool `json:"checkLogin"`
	// CheckRole lists required roles CheckRole 列出需要校验的角色
	CheckRole []string `json:"checkRole"`
	// CheckPermission lists required permissions CheckPermission 列出需要校验的权限
	CheckPermission []string `json:"checkPermission"`
	// CheckDisable indicates disable check CheckDisable 表示是否检查封禁
	CheckDisable bool `json:"checkDisable"`
	// Ignore bypasses authentication Ignore 表示是否忽略认证
	Ignore bool `json:"ignore"`
	// LogicType sets logic mode LogicType 指定逻辑类型
	LogicType LogicType `json:"logicType"`
}

Annotation defines annotation config Annotation 定义注解配置

type AtomicStorage

type AtomicStorage = adapter.AtomicStorage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Auth

type Auth = dtoken.Auth

Auth exposes the instance-oriented dtoken facade.

type AuthHandleRequest

type AuthHandleRequest struct {
	AuthType     string
	CheckLogin   bool
	CheckDisable bool
	Permissions  []string
	Roles        []string
	LogicType    LogicType
	// contains filtered or unexported fields
}

AuthHandleRequest carries auth check metadata AuthHandleRequest 携带认证校验元数据

func (*AuthHandleRequest) Exit

func (req *AuthHandleRequest) Exit()

Exit stops dtoken checks after custom handling Exit 自定义处理后停止 dtoken 校验

func (*AuthHandleRequest) IsHandled

func (req *AuthHandleRequest) IsHandled() bool

IsHandled reports whether request has been handled IsHandled 判断请求是否已处理

func (*AuthHandleRequest) Next

func (req *AuthHandleRequest) Next()

Next continues request and stops dtoken checks Next 放行请求并停止 dtoken 校验

type AuthOption

type AuthOption func(*AuthOptions)

AuthOption defines auth option setter AuthOption 定义认证选项设置器

func WithAuthType

func WithAuthType(authType string) AuthOption

WithAuthType sets auth type WithAuthType 设置认证类型

func WithBeforeAuthHandler

func WithBeforeAuthHandler(fn BeforeAuthHandler) AuthOption

WithBeforeAuthHandler sets pre auth handler WithBeforeAuthHandler 设置认证前置处理器

func WithFailFunc

func WithFailFunc(fn func(w http.ResponseWriter, r *http.Request, err error)) AuthOption

WithFailFunc sets auth failure callback WithFailFunc 设置认证失败回调

func WithLogicType

func WithLogicType(logicType LogicType) AuthOption

WithLogicType sets logic type WithLogicType 设置逻辑类型

func WithRouteAccessHandler added in v0.0.3

func WithRouteAccessHandler(fn RouteAccessHandler) AuthOption

WithRouteAccessHandler sets route access handler WithRouteAccessHandler 设置路由访问处理器

type AuthOptions

type AuthOptions struct {
	AuthType           string
	LogicType          LogicType
	FailFunc           func(w http.ResponseWriter, r *http.Request, err error)
	BeforeAuthHandler  BeforeAuthHandler
	RouteAccessHandler RouteAccessHandler
}

AuthOptions defines middleware auth options AuthOptions 定义中间件认证选项

type AuthorizationCode

type AuthorizationCode = oauth2.AuthorizationCode

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Base64Serializer

type Base64Serializer = base64codec.Base64Serializer

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type BeforeAuthHandler

type BeforeAuthHandler func(w http.ResponseWriter, r *http.Request, req *AuthHandleRequest)

BeforeAuthHandler handles request before dtoken checks BeforeAuthHandler 在 dtoken 校验前处理请求

type Builder

type Builder = builder.Builder

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ChiContext

type ChiContext struct {
	// contains filtered or unexported fields
}

ChiContext adapts request context ChiContext 适配 Chi 请求上下文

func (*ChiContext) Abort

func (c *ChiContext) Abort()

Abort implements adapter.RequestContext Abort 实现 adapter.RequestContext 接口

func (*ChiContext) Get

func (c *ChiContext) Get(key string) (interface{}, bool)

Get implements adapter.RequestContext Get 实现 adapter.RequestContext 接口

func (*ChiContext) GetBody

func (c *ChiContext) GetBody() ([]byte, error)

GetBody implements adapter.RequestContext GetBody 实现 adapter.RequestContext 接口

func (*ChiContext) GetClientIP

func (c *ChiContext) GetClientIP() string

GetClientIP implements adapter.RequestContext GetClientIP 实现 adapter.RequestContext 接口

func (*ChiContext) GetCookie

func (c *ChiContext) GetCookie(key string) string

GetCookie implements adapter.RequestContext GetCookie 实现 adapter.RequestContext 接口

func (*ChiContext) GetHeader

func (c *ChiContext) GetHeader(key string) string

GetHeader implements adapter.RequestContext GetHeader 实现 adapter.RequestContext 接口

func (*ChiContext) GetHeaders

func (c *ChiContext) GetHeaders() map[string][]string

GetHeaders implements adapter.RequestContext GetHeaders 实现 adapter.RequestContext 接口

func (*ChiContext) GetMethod

func (c *ChiContext) GetMethod() string

GetMethod implements adapter.RequestContext GetMethod 实现 adapter.RequestContext 接口

func (*ChiContext) GetPath

func (c *ChiContext) GetPath() string

GetPath implements adapter.RequestContext GetPath 实现 adapter.RequestContext 接口

func (*ChiContext) GetPostForm

func (c *ChiContext) GetPostForm(key string) string

GetPostForm implements adapter.RequestContext GetPostForm 实现 adapter.RequestContext 接口

func (*ChiContext) GetQuery

func (c *ChiContext) GetQuery(key string) string

GetQuery implements adapter.RequestContext GetQuery 实现 adapter.RequestContext 接口

func (*ChiContext) GetQueryAll

func (c *ChiContext) GetQueryAll() map[string][]string

GetQueryAll implements adapter.RequestContext GetQueryAll 实现 adapter.RequestContext 接口

func (*ChiContext) GetRawRequest

func (c *ChiContext) GetRawRequest() *http.Request

GetRawRequest implements adapter.RequestContextExt GetRawRequest 实现 adapter.RequestContextExt 接口

func (*ChiContext) GetRawResponseWriter

func (c *ChiContext) GetRawResponseWriter() http.ResponseWriter

GetRawResponseWriter implements adapter.RequestContextExt GetRawResponseWriter 实现 adapter.RequestContextExt 接口

func (*ChiContext) GetString

func (c *ChiContext) GetString(key string) string

GetString implements adapter.RequestContext GetString 实现 adapter.RequestContext 接口

func (*ChiContext) GetURL

func (c *ChiContext) GetURL() string

GetURL implements adapter.RequestContext GetURL 实现 adapter.RequestContext 接口

func (*ChiContext) GetUserAgent

func (c *ChiContext) GetUserAgent() string

GetUserAgent implements adapter.RequestContext GetUserAgent 实现 adapter.RequestContext 接口

func (*ChiContext) IsAborted

func (c *ChiContext) IsAborted() bool

IsAborted implements adapter.RequestContext IsAborted 实现 adapter.RequestContext 接口

func (*ChiContext) IsTLS

func (c *ChiContext) IsTLS() bool

IsTLS implements adapter.RequestContext IsTLS 实现 adapter.RequestContext 接口

func (*ChiContext) JSON

func (c *ChiContext) JSON(code int, v any) error

JSON implements adapter.RequestContextExt JSON 实现 adapter.RequestContextExt 接口

func (*ChiContext) MustGet

func (c *ChiContext) MustGet(key string) any

MustGet implements adapter.RequestContext MustGet 实现 adapter.RequestContext 接口

func (*ChiContext) Set

func (c *ChiContext) Set(key string, value interface{})

Set implements adapter.RequestContext Set 实现 adapter.RequestContext 接口

func (*ChiContext) SetCookie

func (c *ChiContext) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)

SetCookie implements adapter.RequestContext SetCookie 实现 adapter.RequestContext 接口

func (*ChiContext) SetCookieWithOptions

func (c *ChiContext) SetCookieWithOptions(options *adapter.CookieOptions)

SetCookieWithOptions implements adapter.RequestContext SetCookieWithOptions 实现 adapter.RequestContext 接口

func (*ChiContext) SetHeader

func (c *ChiContext) SetHeader(key, value string)

SetHeader implements adapter.RequestContext SetHeader 实现 adapter.RequestContext 接口

func (*ChiContext) SetStatusCode

func (c *ChiContext) SetStatusCode(code int)

SetStatusCode implements adapter.RequestContext SetStatusCode 实现 adapter.RequestContext 接口

func (*ChiContext) Write

func (c *ChiContext) Write(data []byte) (int, error)

Write implements adapter.RequestContext Write 实现 adapter.RequestContext 接口

type Codec

type Codec = adapter.Codec

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type CodecFactory

type CodecFactory = builder.CodecFactory

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ComponentFactories

type ComponentFactories = builder.ComponentFactories

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Components

type Components = builder.Components

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ConcurrencyScope

type ConcurrencyScope = config.ConcurrencyScope

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Config

type Config = config.Config

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type CookieConfig

type CookieConfig = config.CookieConfig

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type CookieOptions

type CookieOptions = adapter.CookieOptions

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type DTokenBuilder

type DTokenBuilder = dtoken.Builder

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type DTokenContext

type DTokenContext = corecontext.DTokenContext

DTokenContext exposes request scoped DToken context DTokenContext 鏆撮湶璇锋眰绾?DToken 涓婁笅鏂囩被鍨嬨€?

type DTokenError

type DTokenError = derror.DTokenError

DTokenError exposes the core DToken error type.

type DefaultGenerator

type DefaultGenerator = dgenerator.Generator

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type DeviceDisableInfo

type DeviceDisableInfo = manager.DeviceDisableInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type DeviceDisableOptions

type DeviceDisableOptions = dtoken.DeviceDisableOptions

Typed option aliases keep framework imports self-contained.

type DisableInfo

type DisableInfo = manager.DisableInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type DisableOptions

type DisableOptions = dtoken.DisableOptions

Typed option aliases keep framework imports self-contained.

type Event

type Event = listener.Event

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type EventData

type EventData = listener.EventData

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type EventFilter

type EventFilter = listener.EventFilter

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type EventManager

type EventManager = listener.Manager

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type EventStats

type EventStats = listener.EventStats

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type FullStorage

type FullStorage = adapter.FullStorage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Generator

type Generator = adapter.Generator

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type GeneratorFactory

type GeneratorFactory = builder.GeneratorFactory

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type GrantType

type GrantType = oauth2.GrantType

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type JSONSerializer

type JSONSerializer = jsoncodec.JSONSerializer

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Listener

type Listener = listener.Listener

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ListenerConfig

type ListenerConfig = listener.ListenerConfig

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ListenerFunc

type ListenerFunc = listener.ListenerFunc

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Log

type Log = adapter.Log

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LogControl

type LogControl = adapter.LogControl

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LogFactory

type LogFactory = builder.LogFactory

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LogLevel

type LogLevel = adapter.LogLevel

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Logger

type Logger = dlog.Logger

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LoggerConfig

type LoggerConfig = dlog.LoggerConfig

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LogicType

type LogicType = authcheck.LogicType

LogicType defines middleware logic type LogicType 定义中间件逻辑类型

const (
	// DTokenCtxKey stores request scoped DToken context DTokenCtxKey 存储请求级 DToken 上下文
	DTokenCtxKey = "DCtx"

	// LogicOr represents OR logic LogicOr 表示或逻辑
	LogicOr LogicType = authcheck.LogicOr
	// LogicAnd represents AND logic LogicAnd 表示与逻辑
	LogicAnd LogicType = authcheck.LogicAnd
)

type LoginOptions

type LoginOptions = dtoken.LoginOptions

Typed option aliases keep framework imports self-contained.

type LogoutMode

type LogoutMode = config.LogoutMode

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type LogoutOptions

type LogoutOptions = dtoken.LogoutOptions

Typed option aliases keep framework imports self-contained.

type Manager

type Manager = manager.Manager

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ManagerOption

type ManagerOption = manager.Option

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ManagerRefreshTokenOptions added in v0.0.3

type ManagerRefreshTokenOptions = manager.RefreshTokenOptions

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type MemoryStorage

type MemoryStorage = memorystorage.Storage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type MsgPackSerializer

type MsgPackSerializer = msgpackcodec.MsgPackSerializer

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type NonceConfig

type NonceConfig = nonce.Config

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type NonceManager

type NonceManager = nonce.NonceManager

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type NopLogger

type NopLogger = nop.NopLogger

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type OAuth2Client

type OAuth2Client = oauth2.Client

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type OAuth2Config

type OAuth2Config = oauth2.Config

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type OAuth2Server

type OAuth2Server = oauth2.OAuth2Server

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type PermissionOptions

type PermissionOptions = dtoken.PermissionOptions

Typed option aliases keep framework imports self-contained.

type Pool

type Pool = adapter.Pool

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type PoolFactory

type PoolFactory = builder.PoolFactory

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RedisConfig

type RedisConfig = redisstorage.Config

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RedisStorage

type RedisStorage = redisstorage.Storage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RefreshTokenInfo added in v0.0.3

type RefreshTokenInfo = manager.RefreshTokenInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RefreshTokenOptions added in v0.0.3

type RefreshTokenOptions = dtoken.RefreshTokenOptions

Typed option aliases keep framework imports self-contained.

type RefreshTokenPair added in v0.0.3

type RefreshTokenPair = manager.RefreshTokenPair

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RenewPoolConfig

type RenewPoolConfig = ants.RenewPoolConfig

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RenewPoolManager

type RenewPoolManager = ants.RenewPoolManager

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ReplacedLoginExitMode

type ReplacedLoginExitMode = config.ReplacedLoginExitMode

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ReplacedLoginMode

type ReplacedLoginMode = config.ReplacedLoginExitMode

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RequestContext

type RequestContext = adapter.RequestContext

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RequestContextExt

type RequestContextExt = adapter.RequestContextExt

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type RoleOptions

type RoleOptions = dtoken.RoleOptions

Typed option aliases keep framework imports self-contained.

type RouteAccessHandler added in v0.0.3

type RouteAccessHandler func(w http.ResponseWriter, r *http.Request, req *RouteAccessRequest)

RouteAccessHandler resolves route auth, permission, and role rules RouteAccessHandler 解析路由认证、权限、角色规则

type RouteAccessRequest added in v0.0.3

type RouteAccessRequest struct {
	AuthType     string
	LogicType    LogicType
	CheckDisable bool
	Permissions  []string
	Roles        []string
	// contains filtered or unexported fields
}

RouteAccessRequest carries route access rules RouteAccessRequest 携带路由访问规则

func (*RouteAccessRequest) RequirePermissions added in v0.0.3

func (req *RouteAccessRequest) RequirePermissions(permissions ...string)

RequirePermissions appends required permissions RequirePermissions 追加当前路由所需权限

func (*RouteAccessRequest) RequireRoles added in v0.0.3

func (req *RouteAccessRequest) RequireRoles(roles ...string)

RequireRoles appends required roles RequireRoles 追加当前路由所需角色

func (*RouteAccessRequest) SetLogicType added in v0.0.3

func (req *RouteAccessRequest) SetLogicType(logicType LogicType)

SetLogicType sets permission and role logic type SetLogicType 设置权限和角色逻辑类型

func (*RouteAccessRequest) SkipAuth added in v0.0.3

func (req *RouteAccessRequest) SkipAuth()

SkipAuth skips login, permission, and role checks SkipAuth 跳过登录、权限、角色校验

func (*RouteAccessRequest) SkipPermission added in v0.0.3

func (req *RouteAccessRequest) SkipPermission()

SkipPermission skips permission and role checks after login SkipPermission 登录后跳过权限和角色校验

type SameSiteMode

type SameSiteMode = config.SameSiteMode

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ScannerStorage

type ScannerStorage = adapter.ScannerStorage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ServiceDisableInfo

type ServiceDisableInfo = manager.ServiceDisableInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type ServiceDisableOptions

type ServiceDisableOptions = dtoken.ServiceDisableOptions

Typed option aliases keep framework imports self-contained.

type Session

type Session = manager.Session

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type Storage

type Storage = adapter.Storage

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type StorageFactory

type StorageFactory = builder.StorageFactory

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TerminalInfo

type TerminalInfo = manager.TerminalInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TerminalRemovalFunc

type TerminalRemovalFunc = manager.TerminalRemovalFunc

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TerminalVisitor

type TerminalVisitor = manager.TerminalVisitor

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TokenInfo

type TokenInfo = manager.TokenInfo

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TokenIntrospection added in v0.0.3

type TokenIntrospection = manager.TokenIntrospection

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TokenRequest

type TokenRequest = oauth2.TokenRequest

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TokenState

type TokenState = manager.TokenState

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type TokenStyle

type TokenStyle = adapter.TokenStyle

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

type UserValidator

type UserValidator = oauth2.UserValidator

Core aliases keep framework imports self-contained. Core 别名让框架包可以独立使用 dtoken。

Jump to

Keyboard shortcuts

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