Documentation
¶
Index ¶
- Constants
- func EncryptEndpoint(endpoint *Endpoint) (string, error)
- func GetSessionTimeOutValue() time.Duration
- func GetSessionValue[T any](session Session, key string) (ret T, ok bool)
- func ReadSessionTokenFromCookie(req *http.Request) string
- func SignatureEndpoint(endpoint string, authToken string) (string, error)
- func SignatureJWT(mc jwt.MapClaims) (string, error)
- func WriteSessionTokenToCookie(res http.ResponseWriter, sessionToken string)
- type AuthSecret
- type BaseClient
- func (s *BaseClient) AttachAuthorization(authorization string)
- func (s *BaseClient) AttachContext(ctx Context)
- func (s *BaseClient) BindAuthSecret(authSecret *AuthSecret)
- func (s *BaseClient) DetachAuthorization()
- func (s *BaseClient) DetachContext()
- func (s *BaseClient) GetContextValues() url.Values
- func (s *BaseClient) GetHTTPClient() *http.Client
- func (s *BaseClient) GetServerURL() string
- func (s *BaseClient) Release()
- func (s *BaseClient) UnBindAuthSecret()
- type Client
- type Context
- type Endpoint
- type Observer
- type Registry
- type Session
- type Status
Constants ¶
View Source
const ( Credential = "Credential" Signature = "Signature" )
View Source
const ( HMAC_SECRET_KEY = "HMAC_SECRET" SESSION_TIMEOUT_VALUE_KEY = "SESSION_TIMEOUT_VALUE" )
View Source
const ( StatusUpdate = iota StatusTerminate )
View Source
const ( // InnerRemoteAccessAddr 会话来源地址 InnerRemoteAccessAddr = "_remoteAccessAddr" // InnerUseAgent 会话来源UA InnerUseAgent = "_userAgent" // account/endpoint 认证方式 InnerAuthType = "_authType" // innserSessionStartTime 会话开始时间 InnerStartTime = "innerSessionStartTime" // AuthExpireTime 会话强制有效期,该有效期通过session Option进行强制设置,与innerExpireTime在使用时,取两者之间最大值为实际会话有效期 AuthExpireTime = "authExpireTime" // Authorization info, from request header Authorization = "Authorization" )
View Source
const ( SessionToken = "session_token" AuthJWTSession = "jwt" AuthEndpointSession = "endpoint" )
View Source
const (
DefaultSessionTimeOutValue = 10 * time.Minute // 10 minute
)
Variables ¶
This section is empty.
Functions ¶
func EncryptEndpoint ¶
func GetSessionTimeOutValue ¶ added in v1.5.4
func GetSessionValue ¶ added in v1.5.4
func ReadSessionTokenFromCookie ¶ added in v1.5.4
func WriteSessionTokenToCookie ¶ added in v1.5.4
func WriteSessionTokenToCookie(res http.ResponseWriter, sessionToken string)
Types ¶
type AuthSecret ¶ added in v1.3.69
type BaseClient ¶
type BaseClient struct {
// contains filtered or unexported fields
}
func NewBaseClient ¶
func NewBaseClient(serverUrl string) BaseClient
func (*BaseClient) AttachAuthorization ¶
func (s *BaseClient) AttachAuthorization(authorization string)
func (*BaseClient) AttachContext ¶
func (s *BaseClient) AttachContext(ctx Context)
func (*BaseClient) BindAuthSecret ¶ added in v1.3.69
func (s *BaseClient) BindAuthSecret(authSecret *AuthSecret)
func (*BaseClient) DetachAuthorization ¶
func (s *BaseClient) DetachAuthorization()
func (*BaseClient) DetachContext ¶
func (s *BaseClient) DetachContext()
func (*BaseClient) GetContextValues ¶
func (s *BaseClient) GetContextValues() url.Values
func (*BaseClient) GetHTTPClient ¶
func (s *BaseClient) GetHTTPClient() *http.Client
func (*BaseClient) GetServerURL ¶
func (s *BaseClient) GetServerURL() string
func (*BaseClient) Release ¶
func (s *BaseClient) Release()
func (*BaseClient) UnBindAuthSecret ¶ added in v1.3.69
func (s *BaseClient) UnBindAuthSecret()
type Context ¶
type Context interface {
Decode(req *http.Request)
Encode(vals url.Values) url.Values
Get(key string) (string, bool)
Set(key, value string)
Remove(key string)
Clear()
}
Context context info
func NewDefaultHeaderContext ¶ added in v1.5.4
func NewDefaultHeaderContext() Context
NewDefaultHeaderContext 创建新的默认会话上下文
type Registry ¶
type Registry interface {
GetSession(res http.ResponseWriter, req *http.Request) Session
CountSession(filter util.Filter) int
Release()
}
Registry 会话仓库
func NewRegistry ¶ added in v1.5.4
type Session ¶
type Session interface {
ID() string
Signature() (string, error)
Reset()
BindObserver(observer Observer)
UnbindObserver(observer Observer)
GetString(key string) (string, bool)
GetInt(key string) (int64, bool)
GetUint(key string) (uint64, bool)
GetFloat(key string) (float64, bool)
GetBool(key string) (bool, bool)
GetOption(key string) (any, bool)
SetOption(key string, value any)
RemoveOption(key string)
SubmitOptions()
}
Session 会话
Click to show internal directories.
Click to hide internal directories.