Documentation ¶
Overview ¶
Package authz provides authentication and authorization functionality, including JWT token handling.
Index ¶
- type CustomClaims
- type JWTAuthz
- func (j *JWTAuthz) AuthCookie(name string, token string) *http.Cookie
- func (j *JWTAuthz) CompareHashAndPassword(hashedPassword, password string) bool
- func (j *JWTAuthz) CreateJWTTokenForUser(userid string) string
- func (j *JWTAuthz) DecodeJWTToUser(token string) (string, error)
- func (j *JWTAuthz) GetHash(email string, password string) []byte
- func (j *JWTAuthz) IsBcryptHash(s string) bool
- func (j *JWTAuthz) JWTAuthzMiddleware(storage Storage, log Log) func(next http.Handler) http.Handler
- type Log
- type Storage
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 ¶
NewJWTAuthz creates a new JWTAuthz instance with the provided signing key and logger.
func (*JWTAuthz) AuthCookie ¶
AuthCookie creates an http.Cookie with the specified name and token value.
func (*JWTAuthz) CompareHashAndPassword ¶
func (*JWTAuthz) CreateJWTTokenForUser ¶
CreateJWTTokenForUser creates a JWT token for the specified user ID.
func (*JWTAuthz) DecodeJWTToUser ¶
DecodeJWTToUser decodes a JWT token to retrieve the user ID.
func (*JWTAuthz) GetHash ¶
GetHash computes the SHA-256 hash of the concatenation of email and password.
func (*JWTAuthz) IsBcryptHash ¶
IsBcryptHash проверяет, является ли данная строка хешем bcrypt.