jwtclaims

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package jwtclaims provide the Claims type providing helper functions to work with JWT claims

Index

Constants

View Source
const (
	Iss       = "iss"        // Issuer claim - identifies the principal that issued the JWT
	Jti       = "jti"        // JWT ID claim - unique identifier for the JWT
	Scope     = "scope"      // Scope claim - space-separated list of scopes
	Sub       = "sub"        // Subject claim - identifies the principal that is the subject of the JWT
	Exp       = "exp"        // Expiration time claim - expiration time on or after which the JWT must not be accepted
	Iat       = "iat"        // Issued at claim - time at which the JWT was issued
	Nbf       = "nbf"        // Not before claim - time before which the JWT must not be accepted
	Username  = "username"   // Username claim - AWS-specific claim for the username
	ClientID  = "client_id"  // Client ID claim - OAuth2/AWS client identifier
	OriginJti = "origin_jti" // Original JWT ID claim - AWS-specific claim for token refresh
	EventID   = "event_id"   // Event ID claim - AWS-specific claim for event identification
	TokenUse  = "token_use"  // Token use claim - AWS-specific claim indicating token usage (id/access)
	AuthTime  = "auth_time"  // Authentication time claim - time when authentication occurred
)

Standard JWT claim names and AWS-specific extensions

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims map[string]string

Claims is a map of JWT claim names and values

func (Claims) AuthTime

func (c Claims) AuthTime() time.Time

AuthTime returns the value of the auth_time claim, converted to a time.Time. If auth_time is either undefined or not a valid timestamp, the zero value of time.Time is returned

func (Claims) ClientID

func (c Claims) ClientID() string

ClientID returns the value of the client_id claim

func (Claims) EventID

func (c Claims) EventID() string

EventID returns the value of the event_id claim

func (Claims) Exp

func (c Claims) Exp() time.Time

Exp returns the value of the exp claim, converted to a time.Time. If exp is either undefined or not a valid timestamp, the zero value of time.Time is returned

func (Claims) Iat

func (c Claims) Iat() time.Time

Iat returns the value of the iat claim, converted to a time.Time. If iat is either undefined or not a valid timestamp, the zero value of time.Time is returned

func (Claims) Iss

func (c Claims) Iss() string

Iss returns the value of the iss claim

func (Claims) Jti

func (c Claims) Jti() string

Jti returns the value of the jti claim

func (Claims) Nbf

func (c Claims) Nbf() time.Time

Nbf returns the value of the nbf claim, converted to a time.Time. If nbf is either undefined or not a valid timestamp, the zero value of time.Time is returned

func (Claims) OriginJti

func (c Claims) OriginJti() string

OriginJti returns the value of the origin_jti claim

func (Claims) Scope

func (c Claims) Scope() string

Scope returns the value of the scope claim

func (Claims) Sub

func (c Claims) Sub() string

Sub returns the value of the sub claim

func (Claims) Timestamp

func (c Claims) Timestamp(claim string) time.Time

Timestamp returns the value of the given claim converted to a time.Time. If the value of the claim is either undefined or not a valid timestamp, the zero value of time.Time is returned

func (Claims) TokenUse

func (c Claims) TokenUse() string

TokenUse returns the value of the token_use claim

func (Claims) Username

func (c Claims) Username() string

Username returns the value of the username claim

Jump to

Keyboard shortcuts

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