custom

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hashedPassword string) bool

CheckPasswordHash compares a plain text password with a hashed password

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a plain text password using bcrypt

func NewConnector

func NewConnector(driver, dsn string, secret *scy.Resource) *sqlConnector

NewConnector creates a connector

Types

type AuthError

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

AuthError represents an authentication error

func (*AuthError) Error

func (e *AuthError) Error() string

Error returns the error message

func (*AuthError) Reason

func (e *AuthError) Reason() error

Reason returns the reason for the authentication error

type Config

type Config struct {
	AuthSQL           string
	AuthConnector     string
	IdentitySQL       string //maps identifier to subject
	IdentityConnector string
	MaxAttempts       int
	// contains filtered or unexported fields
}

Config represents the custom configuration

func (*Config) EnsureSQL

func (c *Config) EnsureSQL() error

type Connector

type Connector interface {
	DB() (*sql.DB, error)
}

Config represents the custom configuration

type Identity

type Identity struct {
	ID string `sqlx:"id" aerospike:"id,pk=true"`
}

Identity represents the identity

type Service

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

Service represents a custom auth service

func New

func New(config *Config, authConnector, identityConnector Connector, signer *signer.Service) *Service

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, id, password string, expireIn time.Duration, claims string) (*auth.Token, error)

Authenticate authenticates user

func (*Service) SetPassword

func (s *Service) SetPassword(ctx context.Context, id, password string) error

SetPassword sets password

type Subject

type Subject struct {
	ID       string  `aerospike:"uid,pk=true"`
	Locked   *bool   `aerospike:"locked"`
	Password *string `aerospike:"password"`
	Attempts *int    `aerospike:"attempts"`
}

Subject represent subject

func (Subject) IsLocked

func (s Subject) IsLocked(maxAttempts int) bool

IsLocked returns true if the subject is locked

Jump to

Keyboard shortcuts

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