gateway

package
v0.6.26 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: GPL-3.0 Imports: 7 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 {
	// Router returns the underlying fiber app.
	Router() *fiber.App

	// StartSession starts a new session for a user. It returns the session ID.
	StartSession(ctx *fasthttp.RequestCtx, values ...SessionValue) (string, error)

	// EndSession ends the specified session. It returns an error if the session does not exist.
	EndSession(ctx *fasthttp.RequestCtx, sessionID string) error

	// IsValidSessionID checks if the specified session ID is valid (i.e., it corresponds to an active session).
	IsValidSessionID(ctx *fasthttp.RequestCtx, sessionID string) bool

	// GetSession retrieves the session information for a session ID. It returns an error if the session does not exist.
	GetSession(ctx *fasthttp.RequestCtx, sessionID string) (*Session, error)

	// Serve serves the fiber app.
	Serve()
}

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