Documentation
¶
Index ¶
Constants ¶
View Source
const ( TypeAccessToken = "access_token" TypeRefreshToken = "refresh_token" )
Defines token types.
View Source
const SessionProtocolVersion = libsf.ProtocolVersion4
SessionProtocolVersion is the account version starting the support of sessions.
Variables ¶
This section is empty.
Functions ¶
func SecureCompare ¶
SecureCompare compares the givens strings in a constant time. So length info is not leaked via timing attacks.
func SecureToken ¶
SecureToken generates a unique random token. Length should be 24 to match ActiveRecord::SecureToken used by the reference implementation.
func UserSupportsJWT ¶
UserSupportsJWT returns true if the user supports the JWT authentication model.
func UserSupportsSessions ¶
UserSupportsSessions returns true if the user supports the sessions authentication model.
Types ¶
type Manager ¶
type Manager interface {
JWTSigningKey() []byte
SessionSecret() []byte
// Token generates the session's token for the given type t.
Token(session *model.Session, t string) (string, error)
// ParseToken parses the given raw token and returns the session_id and token.
ParseToken(token string) (string, string, error)
// Generate creates a new session without user information.
Generate() *model.Session
// Validate validates an access token.
Validate(userID, token string) (*model.Session, error)
// AccessTokenExprireAt returns the expiration date of the access token.
AccessTokenExprireAt(session *model.Session) time.Time
// Regenerate regenerates the session's tokens.
Regenerate(session *model.Session) error
// UserFromToken the user for the given token.
UserFromToken(token any) (*model.User, error)
}
A Manager manages sessions.
Click to show internal directories.
Click to hide internal directories.