Documentation ¶
Overview ¶
Authentication logic and JWT operations package.
Index ¶
- Constants
- Variables
- func AuthMiddleware(next http.Handler) http.Handler
- func NewAccessToken(claims UserClaims, secret string) (string, error)
- func NewRefreshToken(claims jwt.StandardClaims, secret string) (string, error)
- func ParseRefreshToken(refreshToken string, secret string) *jwt.StandardClaims
- func Router() chi.Router
- type AuthUser
- type UserClaims
Constants ¶
View Source
const ( ACCESS_TOKEN = "access-token" REFRESH_TOKEN = "refresh-token" )
Variables ¶
View Source
var PathExceptions = []string{
"/api/v1",
"/api/v1/auth",
"/api/v1/auth/logout",
"/api/v1/dump",
"/api/v1/live",
"/api/v1/users/activation/",
"/api/v1/users/passphrase/request",
"/api/v1/users/passphrase/reset",
}
These URL paths are to be skipped by the authentication middleware.
Functions ¶
func AuthMiddleware ¶
The very authentication middleware entrypoint.
func NewAccessToken ¶
func NewAccessToken(claims UserClaims, secret string) (string, error)
NewAccessToken generates a new signed access token.
func NewRefreshToken ¶
func NewRefreshToken(claims jwt.StandardClaims, secret string) (string, error)
NewRefreshToken generates a new signed refresh token.
func ParseRefreshToken ¶
func ParseRefreshToken(refreshToken string, secret string) *jwt.StandardClaims
ParseRefreshToken decodes the refreshCookie value to get the StandardClaims payload.
Types ¶
type AuthUser ¶ added in v0.43.7
type AuthUser struct { // Nickname is the user's very username. Nickname string `json:"nickname"` // Passphrase is a legacy format converted to string from a raw byte stream // (do not use anymore as this will be removed in future versions). Passphrase string `json:"passphrase"` // PassphraseHex is a hexadecimal representation of a passphrase (a SHA-512 checksum). // Use 'echo $PASS | sha512sum' for example to get the hex format. PassphraseHex string `json:"passphrase_hex"` }
type UserClaims ¶
type UserClaims struct { Nickname string `json:"nickname"` jwt.StandardClaims }
UserClaims is a generic structure for a personal user's (access) token.
func ParseAccessToken ¶
func ParseAccessToken(accessToken string, secret string) *UserClaims
ParseAccessToken decodes the accessCookie value to get the UserClaims payload.
Click to show internal directories.
Click to hide internal directories.