authenticator

package
v0.0.0-...-5c487ac Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 10 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 struct {
	// contains filtered or unexported fields
}

Authenticator securely authenticates an user's identity.

func NewAuthenticator

func NewAuthenticator(
	tokenizer crypto.Tokenizer,
	timer timer.Timer,
	tokenValidDuration time.Duration,
) Authenticator

NewAuthenticator initializes authenticator with custom token valid duration

func NewAuthenticatorFake

func NewAuthenticatorFake(current time.Time, validPeriod time.Duration) Authenticator

NewAuthenticatorFake creates fake authenticator for easy testing.

func (Authenticator) GenerateToken

func (a Authenticator) GenerateToken(user entity.User) (string, error)

GenerateToken encodes part of user data into authentication token

func (Authenticator) GetUser

func (a Authenticator) GetUser(token string) (entity.User, error)

GetUser decodes authentication token to user data

func (Authenticator) IsSignedIn

func (a Authenticator) IsSignedIn(token string) bool

IsSignedIn checks whether user successfully signed in

type Credential

type Credential struct {
	APIKey *string
}

Credential encodes the identity of API consumer.

type Payload

type Payload struct {
	// contains filtered or unexported fields
}

Payload represents the metadata encoded in the authentication token.

func (Payload) TokenPayload

func (p Payload) TokenPayload() crypto.TokenPayload

TokenPayload retrieves key-value pairs representation of the payload.

type ThirdPartyApp

type ThirdPartyApp struct {
	// contains filtered or unexported fields
}

ThirdPartyApp authenticates the identity of a third party application.

func NewThirdPartyApp

func NewThirdPartyApp(
	authorizer authorizer.Authorizer,
	tokenizer crypto.Tokenizer,
	keyGen keygen.KeyGenerator,
	timer timer.Timer,
	apiKeyRepo repository.APIKey,
	appRepo repository.App,
) ThirdPartyApp

NewThirdPartyApp creates ThirdPartyApp authenticator.

func (ThirdPartyApp) GenerateAPIKey

func (t ThirdPartyApp) GenerateAPIKey(user entity.User, app entity.App) (string, error)

GenerateAPIKey generates a new API key for the given app.

func (ThirdPartyApp) GetApp

func (t ThirdPartyApp) GetApp(cred Credential) (entity.App, error)

GetApp retrieves app information based on the credential provided.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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