authn

package
v0.2.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(hashedPassword, password string) error

Compare compares the encrypted text with the plain text if it's the same.

func Encrypt

func Encrypt(source string) (string, error)

Encrypt encrypts the plain text with bcrypt.

Types

type Authenticator

type Authenticator interface {
	// Sign is used to generate a token.
	Sign(ctx context.Context, userID string) (IToken, error)

	// Destroy is used to destroy a token.
	Destroy(ctx context.Context, accessToken string) error

	// ParseClaims parse the token and return the claims.
	ParseClaims(ctx context.Context, accessToken string) (*jwt.RegisteredClaims, error)

	// Release used to release the requested resources.
	Release() error
}

Authenticator defines methods used for token processing.

type IToken

type IToken interface {
	// Get token string.
	GetToken() string
	// Get token type.
	GetTokenType() string
	// Get token expiration timestamp.
	GetExpiresAt() int64
	// JSON encoding
	EncodeToJSON() ([]byte, error)
}

IToken defines methods to implement a generic token.

Directories

Path Synopsis
jwt

Jump to

Keyboard shortcuts

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