session

package
v1.3.80 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Credential = "Credential"
	Signature  = "Signature"
)
View Source
const (
	StatusUpdate = iota
	StatusTerminate
)
View Source
const (

	// Authorization info, from request header
	Authorization = "Authorization"
	// RemoteAddress 远端地址
	RemoteAddress = "$$sessionRemoteAddress"
)
View Source
const (
	DefaultSessionTimeOutValue = 10 * time.Minute // 10 minute
)

Variables

This section is empty.

Functions

func EncryptEndpoint

func EncryptEndpoint(endpoint *Endpoint) (string, error)

Types

type AuthSecret added in v1.3.69

type AuthSecret struct {
	Endpoint  string `json:"endpoint"`
	AuthToken string `json:"authToken"`
}

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(endpoint, authToken string)

func (*BaseClient) BindToken

func (s *BaseClient) BindToken(sessionToken Token)

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()

func (*BaseClient) UnBindToken

func (s *BaseClient) UnBindToken()

type Client

type Client interface {
	GetServerURL() string
	GetHTTPClient() *http.Client

	AttachContext(ctx Context)
	DetachContext()

	AttachAuthorization(authorization string)
	DetachAuthorization()

	BindToken(token Token)
	UnBindToken()

	BindAuthSecret(endpoint, authToken string)
	UnBindAuthSecret()

	Release()
}

type Context

type Context interface {
	Decode(req *http.Request)
	Encode(vals url.Values) url.Values
}

Context context info

type Endpoint

type Endpoint struct {
	Endpoint string                 `json:"endpoint"`
	Context  map[string]interface{} `json:"context"`
}

type Observer

type Observer interface {
	ID() string
	OnStatusChange(session Session, status Status)
}

Observer session Observer

type Registry

type Registry interface {
	GetSession(res http.ResponseWriter, req *http.Request) Session
	CountSession(filter util.Filter) int
}

Registry 会话仓库

func CreateRegistry

func CreateRegistry() Registry

CreateRegistry 创建Session仓库

type Session

type Session interface {
	ID() string
	Signature() (Token, 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) (interface{}, bool)
	SetOption(key string, value interface{})
	RemoveOption(key string)
	SubmitOptions()
}

Session 会话

type Status

type Status int

type Token

type Token string

func SignatureEndpoint

func SignatureEndpoint(endpoint string, authToken string) (Token, error)

func SignatureJWT

func SignatureJWT(mc jwt.MapClaims) (Token, error)

Jump to

Keyboard shortcuts

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