Documentation ¶
Index ¶
- func CompareHashAndPassword(password string, hashedPassword string) bool
- func HashPassword(password string) (string, error)
- type AuthService
- func (svc AuthService) GetJwks(ctx context.Context, req *pb.GetJwksRequest) (*pb.GetJwksResponse, error)
- func (svc AuthService) LoginPassword(ctx context.Context, req *pb.LoginPasswordRequest) (*pb.LoginPasswordResponse, error)
- func (svc AuthService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)
- func (svc AuthService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
- func (svc AuthService) SetPassword(ctx context.Context, req *pb.SetPasswordRequest) (*pb.SetPasswordResponse, error)
- type ConsumerController
- type ServiceConfig
- type ServiceConfigOpts
- type StorageController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareHashAndPassword ¶
func HashPassword ¶
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 (svc AuthService) LoginPassword(ctx context.Context, req *pb.LoginPasswordRequest) (*pb.LoginPasswordResponse, error)
func (AuthService) ProcessUserDeletedEvent ¶
func (svc AuthService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)
func (AuthService) ServiceInfo ¶
func (svc AuthService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
func (AuthService) SetPassword ¶
func (svc AuthService) SetPassword(ctx context.Context, req *pb.SetPasswordRequest) (*pb.SetPasswordResponse, error)
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 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)