auth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	EmailValidation(email string) bool
	ValidatePasswordHash(hash, password string) error
	HashPassword(password string) (string, error)
	GenerateCode() string
	GetBearerToken(headers http.Header) (string, error)
	MakeJWT(cfg *config.Config, userID uuid.UUID) (string, error)
	ValidateJWT(cfg *config.Config, tokenString string) (uuid.UUID, error)
	VerifyPlaidJWT(p PlaidKeyFetcher, ctx context.Context, tokenString string) error
	MakeRefreshToken(tokenStore TokenStore, userID uuid.UUID, delegation database.Delegation) (string, error)
	HashRefreshToken(token string) string
}

Auth interface

type PlaidKeyFetcher

type PlaidKeyFetcher interface {
	GetWebhookVerificationKey(ctx context.Context, keyID string) (plaid.JWKPublicKey, error)
}

type Service

type Service struct{}

Struct that holds auth functions as methods

func (*Service) EmailValidation

func (s *Service) EmailValidation(email string) bool

Validates that a given string represents a valid email address

func (*Service) GenerateCode

func (s *Service) GenerateCode() string

Function generates a random 8 character string. Creates a new UUID, and returns the first 8 characters of the converted string

func (*Service) GetBearerToken

func (s *Service) GetBearerToken(headers http.Header) (string, error)

Function gets bearer authorization token from incoming request header

func (*Service) HashPassword

func (s *Service) HashPassword(password string) (string, error)

Function accepts a string password, and hashes it

func (*Service) HashRefreshToken

func (s *Service) HashRefreshToken(token string) string

Hash a refresh token using sha256

func (*Service) MakeJWT

func (s *Service) MakeJWT(cfg *config.Config, userID uuid.UUID) (string, error)

Function generates a JWT authorization token for a given userID

func (*Service) MakeRefreshToken

func (s *Service) MakeRefreshToken(tokenStore TokenStore, userID uuid.UUID, delegation database.Delegation) (string, error)

Function creates a new token string, hashes the token, and creates a record of it in the database

func (*Service) ValidateJWT

func (s *Service) ValidateJWT(cfg *config.Config, tokenString string) (uuid.UUID, error)

Validates a token input based off the secret string

func (*Service) ValidatePasswordHash

func (s *Service) ValidatePasswordHash(hash, password string) error

Compares hashed password input against stored password hash

func (*Service) VerifyPlaidJWT

func (s *Service) VerifyPlaidJWT(p PlaidKeyFetcher, ctx context.Context, tokenString string) error

Validates the JWT provided from Plaid webhooks

type TokenStore

type TokenStore interface {
	CreateToken(ctx context.Context, params database.CreateTokenParams) (database.RefreshToken, error)
}

Interface to access database.Queries in auth package

Jump to

Keyboard shortcuts

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