Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface {
// StartSession starts a new session for a user. It returns the session ID.
StartSession(w http.ResponseWriter, r *http.Request, values ...SessionValue) (string, error)
EndSession(w http.ResponseWriter, r *http.Request, sessionID string) error
IsValidSessionID(r *http.Request, sessionID string) bool
GetSession(r *http.Request, sessionID string) (*Session, error)
// Serve serves the fiber app.
Serve(router *mux.Router)
}
Authenticator represents the interface for session-based authentication.
func NewAuthenticator ¶
func NewAuthenticator() Authenticator
NewAuthenticator returns a new Authenticator instance. It also initializes the underlying fiber app. this is used to have authenticated routes.
type RouteHandler ¶
type RouteHandler func(w http.ResponseWriter, r *http.Request)
type Session ¶
type Session struct {
UserAlias string
Credential string
Address string
IsMobile bool
Did string
Name string
Days string
Secret string
}
Session represents an authenticated session. In a real application, this might include additional fields such as the user ID, the session expiry time, etc.
func LoadSession ¶
LoadSession gets all the session values and verifies their types.
type SessionValue ¶
type SessionValue func(s *Session)
func WithAddress ¶
func WithAddress(address string) SessionValue
func WithCredential ¶
func WithCredential(credential []byte) SessionValue
func WithDid ¶
func WithDid(did string) SessionValue
func WithIsMobile ¶
func WithIsMobile(isMobile bool) SessionValue
func WithUserAlias ¶
func WithUserAlias(alias string) SessionValue
Click to show internal directories.
Click to hide internal directories.