auth

package
v0.0.0-...-e235655 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken    = errors.New("token is invalid")
	ErrExpiredToken    = errors.New("token has expired")
	ErrGeneratingToken = errors.New("token could not be signed")
)

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword string) error

func HashPassword

func HashPassword(password string) (string, error)

Types

type AuthServer

type AuthServer struct {
	Handler db.Handler
	Jwt     JwtWrapper
	Config  config.Config // used to test circuit breakers
}

func (*AuthServer) DeleteUser

func (s *AuthServer) DeleteUser(ctx context.Context, id *pb.EntityID) (*pb.DeleteResponse, error)

func (*AuthServer) GetUser

func (s *AuthServer) GetUser(ctx context.Context, req *pb.EntityID) (*pb.UserResponse, error)

func (*AuthServer) Login

func (s *AuthServer) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error)

func (*AuthServer) Register

func (s *AuthServer) Register(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error)

TODO SHULD CHECK ROLE FOR ENUM

func (*AuthServer) Validate

func (s *AuthServer) Validate(ctx context.Context, req *pb.ValidateRequest) (*pb.ValidateResponse, error)

type JwtWrapper

type JwtWrapper struct {
	SecretKey       string
	Issuer          string
	ExpirationHours int64
}

func (*JwtWrapper) GenerateToken

func (w *JwtWrapper) GenerateToken(user models.User) (signedToken string, err error)

func (*JwtWrapper) ValidateToken

func (w *JwtWrapper) ValidateToken(signedToken string) (claims *jwtClaims, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳