auth

package
v0.0.0-...-531b5da Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(password string, hashedPassword string) bool

func HashPassword

func HashPassword(password string) (string, error)

Types

type AuthService

type AuthService struct {
	pb.UnimplementedAuthServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewAuthService

func NewAuthService(cfg *ServiceConfig, store StorageController) *AuthService

Create the auth service

func (AuthService) GetJwks

func (svc AuthService) GetJwks(ctx context.Context, req *pb.GetJwksRequest) (*pb.GetJwksResponse, error)

Provide the JWK ECDSA public key as part of a JSON Web Key set. This method is called by the API gateway for usage when validating inbound JWT tokens.

func (AuthService) LoginPassword

func (AuthService) ProcessUserDeletedEvent

func (svc AuthService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)

func (AuthService) ServiceInfo

func (AuthService) SetPassword

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.AuthServiceServer)
}

Interface for event consumption Flexibility for seperate controllers for different messaging systems (e.g. Kafka, NATS, etc)

type ServiceConfig

type ServiceConfig struct {
	// Core configuration
	Shared      config.SharedConfig
	ServiceOpts ServiceConfigOpts

	// Dynamically loaded configuration
	Postgres config.PostgresConfig
	Kafka    config.KafkaConfig
}

Auth Service Configuration

func NewServiceConfig

func NewServiceConfig() (*ServiceConfig, error)

load the service configuration

type ServiceConfigOpts

type ServiceConfigOpts struct {
	// Env Var: "AUTH_PRIVATE_KEY"
	// to be provided in base64 format
	PrivateKey *ecdsa.PrivateKey

	// Generated from PrivateKey
	PublicJwk *pb.PublicEcJWK
}

Service specific config options

func (*ServiceConfigOpts) Load

func (opts *ServiceConfigOpts) Load() error

Load the ServiceConfigOpts

PrivateKey is loaded and decoded from the base64 encoded PEM file exposed in the 'AUTH_PRIVATE_KEY' environment variable.

type StorageController

type StorageController interface {
	SetPassword(ctx context.Context, userId string, password string) error
	VerifyPassword(ctx context.Context, userId string, password string) (bool, error)

	DeleteAuthMethods(ctx context.Context, userId string) error
}

Interface for database methods Allows implementing seperate controllers for different databases (e.g. Postgres, MongoDB, etc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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