authz

package
v0.0.0-...-0776f63 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package authz provides authentication and authorization functionality, including JWT token handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	Email string `json:"email"`
	jwt.StandardClaims
}

CustomClaims represents custom claims for JWT token.

type JWTAuthz

type JWTAuthz struct {
	// contains filtered or unexported fields
}

JWTAuthz provides JWT token creation, decoding, and middleware functionality for authentication and authorization.

func NewJWTAuthz

func NewJWTAuthz(signingKey string, log Log) *JWTAuthz

NewJWTAuthz creates a new JWTAuthz instance with the provided signing key and logger.

func (*JWTAuthz) AuthCookie

func (j *JWTAuthz) AuthCookie(name string, token string) *http.Cookie

AuthCookie creates an http.Cookie with the specified name and token value.

func (*JWTAuthz) CompareHashAndPassword

func (j *JWTAuthz) CompareHashAndPassword(hashedPassword, password string) bool

func (*JWTAuthz) CreateJWTTokenForUser

func (j *JWTAuthz) CreateJWTTokenForUser(userid string) string

CreateJWTTokenForUser creates a JWT token for the specified user ID.

func (*JWTAuthz) DecodeJWTToUser

func (j *JWTAuthz) DecodeJWTToUser(token string) (string, error)

DecodeJWTToUser decodes a JWT token to retrieve the user ID.

func (*JWTAuthz) GetHash

func (j *JWTAuthz) GetHash(email string, password string) []byte

GetHash computes the SHA-256 hash of the concatenation of email and password.

func (*JWTAuthz) IsBcryptHash

func (j *JWTAuthz) IsBcryptHash(s string) bool

IsBcryptHash проверяет, является ли данная строка хешем bcrypt.

func (*JWTAuthz) JWTAuthzMiddleware

func (j *JWTAuthz) JWTAuthzMiddleware(storage Storage, log Log) func(next http.Handler) http.Handler

type Log

type Log interface {
	Info(string, ...zapcore.Field)
}

Log is an interface representing a logger with Info method.

type Storage

type Storage interface {
}

Storage is an interface representing methods for inserting user data.

Jump to

Keyboard shortcuts

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