auth

package module
v0.0.0-...-d284103 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MPL-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

AuthMiddleware checks for JWT in the authorization header and validates it (ONLY WHEN MAKING CALLS VIA GRPC PORT)

func CheckPassword

func CheckPassword(p string, hp string) error

CheckPassword checks if the provided plaintext password is equivalent to the hashed password

func CreateJWT

func CreateJWT(uuid string, email string, t TokenType) (string, error)

func EmailSender

func EmailSender(receiverEmail string, subject string, body string, htmlBody string) error

func EmailVerification

func EmailVerification(receiverEmail string, code string) error

func HashPassword

func HashPassword(p string) (string, error)

HashPassword returns the hashed password

func HttpAuthMiddleware

func HttpAuthMiddleware(next http.Handler) http.Handler

HTTPAuthMiddleware checks for JWT in the authorization header and validates it (ONLY WHEN MAKING CALLS VIA HTTP PORT, grpc interceptor doesnt function during http calls)

Types

type Claims

type Claims struct {
	Uuid  string    `json:"uuid"`
	Email string    `json:"email"`
	Type  TokenType `json:"type"` //To decide whether it is access(0) or refresh(1) token
	jwt.RegisteredClaims
}

Claims represents the JWT claims structure

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type TokenType

type TokenType int64

Jump to

Keyboard shortcuts

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