auth

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	GuardDriver
	Guard(name string) GuardDriver
	Extend(name string, fn GuardFunc)
	Provider(name string, fn UserProviderFunc)
}

type GuardDriver added in v1.15.12

type GuardDriver interface {
	// Check whether user logged in or not
	Check() bool
	// Check whether user *not* logged in or not | !Check()
	Guest() bool
	// ID returns the current user id.
	ID() (token string, err error)
	// Login logs a user into the application.
	Login(user any) (token string, err error)
	// LoginUsingID logs the given user ID into the application.
	LoginUsingID(id any) (token string, err error)
	// Logout logs the user out of the application.
	Logout() error
	// Parse the given token.
	Parse(token string) (*Payload, error)
	// Refresh the token for the current user.
	Refresh() (token string, err error)
	// User returns the current authenticated user.
	User(user any) error
}

type GuardFunc added in v1.15.12

type GuardFunc func(ctx http.Context, name string, userProvider UserProvider) (GuardDriver, error)

type Payload added in v1.10.0

type Payload struct {
	ExpireAt time.Time
	IssuedAt time.Time
	Guard    string
	Key      string
}

type UserProvider added in v1.15.12

type UserProvider interface {
	// GetID returns the user id.
	GetID(user any) (any, error)
	// RetriveByID returns the user by id, user should be a pointer.
	RetriveByID(user any, id any) error
}

type UserProviderFunc added in v1.15.12

type UserProviderFunc func(ctx http.Context) (UserProvider, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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