Documentation ¶
Index ¶
- Constants
- Variables
- func CreateSessionWithCookie(ctx context.Context, r *http.Request, w http.ResponseWriter, userID uint64) error
- func GetSessionCookie(r *http.Request) string
- func IsSessionValid(sessionID SessionID) bool
- func IsUserValid(userID uint64) bool
- func OpenSessionAllowed(ctx context.Context, userID uint64) bool
- func VerifySession(ctx context.Context, subject string, message *messaging.Message) (*messaging.Message, error)
- type CookieCodec
- type CookieCodecRequest
- type Session
- func (s *Session) Count(ctx context.Context) (int, error)
- func (s *Session) CreateSession(ctx context.Context, userID uint64, remoteAddr string, duration time.Duration) (SessionID, error)
- func (s *Session) ExtendSession(ctx context.Context, remoteAddr string, sessionID SessionID, ...) (uint64, error)
- func (s *Session) InvalidateSession(ctx context.Context, sessionID SessionID) error
- func (s *Session) IsSessionValid(ctx context.Context, sessionID SessionID) bool
- func (s *Session) UserSession(ctx context.Context, sessionID SessionID) uint64
- type SessionArgs
- type SessionID
- type SessionInfo
- type SessionReply
Constants ¶
View Source
const (
KeySessions = "Api.Sessions"
)
View Source
const (
SessionDuration = 3 * time.Minute
)
Variables ¶
View Source
var ( ErrInternalError = errors.New("InternalError") ErrInvalidDuration = errors.New("Invalid Duration") ErrInvalidUserID = errors.New("Invalid UserID") ErrInvalidRemoteAddr = errors.New("Invalid RemoteAddr") ErrRemoteAddrChanged = errors.New("RemoteAddr Changed") ErrInvalidSessionID = errors.New("Invalid SessionID") ErrSessionExpired = errors.New("Session Expired") ErrEncode = errors.New("Encode Error") ErrDecode = errors.New("Decode Error") ErrCache = errors.New("Cache Error") ErrInvalidCrendential = errors.New("InvalidCredentials") ErrMissingCookie = errors.New("MissingCookie") ErrInvalidCookie = errors.New("ErrInvalidCookie") ErrSessionCreationFailed = errors.New("SessionCreationFailed") ErrTooManyOpenSession = errors.New("TooManyOpenSession") ErrSessionClose = errors.New("SessionCloseFailed") )
Functions ¶
func CreateSessionWithCookie ¶
func GetSessionCookie ¶
func IsSessionValid ¶
func IsUserValid ¶
Types ¶
type CookieCodec ¶
type CookieCodec struct {
// contains filtered or unexported fields
}
func NewCookieCodec ¶
func NewCookieCodec(ctx context.Context) *CookieCodec
func (*CookieCodec) NewRequest ¶
func (p *CookieCodec) NewRequest(r *http.Request) rpc.CodecRequest
type CookieCodecRequest ¶
type CookieCodecRequest struct {
// contains filtered or unexported fields
}
func (*CookieCodecRequest) Method ¶
func (p *CookieCodecRequest) Method() (string, error)
func (*CookieCodecRequest) ReadRequest ¶
func (p *CookieCodecRequest) ReadRequest(args interface{}) error
func (*CookieCodecRequest) WriteError ¶
func (p *CookieCodecRequest) WriteError(w http.ResponseWriter, status int, err error)
func (*CookieCodecRequest) WriteResponse ¶
func (p *CookieCodecRequest) WriteResponse(w http.ResponseWriter, args interface{})
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) CreateSession ¶
func (*Session) ExtendSession ¶
func (*Session) InvalidateSession ¶
func (*Session) IsSessionValid ¶
type SessionArgs ¶
type SessionArgs struct {
SessionID string `json:"-"` // SessionID is transmit to client via cookie
}
SessionArgs holds SessionID for operation requests and repls
type SessionInfo ¶
type SessionInfo struct { UserID uint64 RemoteAddr string SessionID SessionID Expiration time.Time }
func (*SessionInfo) Decode ¶
func (s *SessionInfo) Decode(data []byte) error
Decode return SessionInfo from bytes. Decoded with gob
func (*SessionInfo) Encode ¶
func (s *SessionInfo) Encode() ([]byte, error)
Encode return bytes from Message. Encoded with gob
func (*SessionInfo) Expired ¶
func (s *SessionInfo) Expired() bool
type SessionReply ¶
type SessionReply struct { SessionArgs Status string `json:"status"` ValidUntil int64 `json:"valid_until"` }
SessionReply holds session informations for operation replies
func OpenUserSession ¶
Click to show internal directories.
Click to hide internal directories.