gateway

package
v0.6.28-beta.10 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

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

func LoadSession(sess *sessions.Session) *Session

LoadSession gets all the session values and verifies their types.

func (*Session) Save

func (s *Session) Save(sess *sessions.Session)

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

Jump to

Keyboard shortcuts

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