Documentation
¶
Index ¶
Constants ¶
const ( ClaimAppAuthenticated = "authn" ClaimAppRoles = "roles" ClaimAudience = "aud" ClaimExpires = "exp" ClaimIssuer = "iss" ClaimIssuedAt = "iat" ClaimNotBefore = "nbf" ClaimSubject = "sub" ClaimRoleUser = "user" ClaimRoleAPIUser = "api-user" ContextKeyAPIStateCode = "api_state_code" ContextKeyAPIError = "api_error" )
JWT claim constants
const (
ErrorMimeType = "error"
)
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
ErrorHandler handles any errors that arise as part of the JWT authentication and validation process.
func IsAuthenticated ¶
IsAuthenticated determines whether or not the JWT token indicates the user has been authenticated.
If the token is valid and not expired, no error is returned. The boolean status will indicate whether or not the user has been authenticated.
The following errors are returned by this function: APITokenExpired, APITokenInvalid, APITokenNotAuthenticated
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
// contains filtered or unexported fields
}
ErrorResponse holds details used to send an error response for a request.
func NewErrorResponse ¶
func NewErrorResponse(ctx *gin.Context, statusCode int, message string, err error, details ...map[string]interface{}) *ErrorResponse
NewErrorResponse constructs and initializes a new ErrorResponse object.
func (*ErrorResponse) Render ¶
func (r *ErrorResponse) Render()
Render writes the response object to the given writer.
type JWTClaims ¶
type JWTClaims struct { jwt.RegisteredClaims IsAuthenticated bool `json:"authn"` Roles []string `json:"roles"` }
JWTClaims holds JWT claim data.
func ParseJWTClaims ¶
ParseJWTClaims takes the given claims interface and turns it into a JWTClaims object.
Note that this function only parses claims, it does not validate the presense of specific claims or their values.
The following errors are returned by this function: APITokenInvalid