Documentation
¶
Overview ¶
Package statuslist implements JWT Status List for credential revocation as specified in draft-ietf-oauth-status-list.
Index ¶
Constants ¶
const ( StatusValid = 0x00 // Credential is valid StatusInvalid = 0x01 // Credential is invalid/revoked )
Status values for credentials.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitsPerStatus ¶
type BitsPerStatus int
BitsPerStatus defines the number of bits used to represent each status.
const ( // Bits1 uses 1 bit per status (0 or 1) Bits1 BitsPerStatus = 1 // Bits2 uses 2 bits per status (0-3) Bits2 BitsPerStatus = 2 // Bits4 uses 4 bits per status (0-15) Bits4 BitsPerStatus = 4 // Bits8 uses 8 bits per status (0-255) Bits8 BitsPerStatus = 8 )
type StatusList ¶
type StatusList struct {
// contains filtered or unexported fields
}
StatusList represents a compressed bitstring of status values.
func Decode ¶
func Decode(encoded string, size int, bitsPerStatus BitsPerStatus) (*StatusList, error)
Decode decodes and decompresses a status list from a base64url string.
func NewStatusList ¶
func NewStatusList(size int, bitsPerStatus BitsPerStatus) (*StatusList, error)
NewStatusList creates a new StatusList with the specified size and bits per status.
func (*StatusList) BitsPerStatus ¶
func (s *StatusList) BitsPerStatus() BitsPerStatus
BitsPerStatus returns the number of bits per status entry.
func (*StatusList) Encode ¶
func (s *StatusList) Encode() (string, error)
Encode compresses and encodes the status list to a base64url string.
func (*StatusList) GetStatus ¶
func (s *StatusList) GetStatus(index int) (int, error)
GetStatus returns the status value at the given index.
func (*StatusList) SetStatus ¶
func (s *StatusList) SetStatus(index int, value int) error
SetStatus sets the status value at the given index.
func (*StatusList) Size ¶
func (s *StatusList) Size() int
Size returns the number of status entries.
type StatusListClaim ¶
type StatusListClaim struct {
// Bits is the number of bits per status (1, 2, 4, or 8)
Bits int `json:"bits"`
// List is the base64url-encoded compressed status list
List string `json:"lst"`
}
StatusListClaim is the "status_list" claim in a Status List Token.
type StatusListSignOptions ¶
type StatusListSignOptions struct {
// Type is the JWT typ header value.
Type string
// ExtraHeaders contains additional JWT header parameters.
ExtraHeaders map[string]any
}
StatusListSignOptions contains optional signing settings for status list tokens.
type StatusListToken ¶
type StatusListToken struct {
// Issuer is the issuer of the status list token
Issuer string `json:"iss"`
// Subject is typically the URI of the status list
Subject string `json:"sub"`
// IssuedAt is when the token was issued
IssuedAt int64 `json:"iat"`
// ExpiresAt is when the token expires (optional)
ExpiresAt int64 `json:"exp,omitempty"`
// TimeToLive is the recommended cache time in seconds
TimeToLive int64 `json:"ttl,omitempty"`
// StatusList contains the encoded status list
StatusList StatusListClaim `json:"status_list"`
}
StatusListToken represents the payload of a Status List Token (JWT).
func NewStatusListToken ¶
func NewStatusListToken(issuer, subject string, list *StatusList, issuedAt, expiresAt int64) (*StatusListToken, error)
NewStatusListToken creates a new Status List Token with the given status list.
func ParseStatusListToken ¶
func ParseStatusListToken(data []byte) (*StatusListToken, error)
ParseStatusListToken parses a Status List Token payload from JSON.
func (*StatusListToken) GetStatusList ¶
func (t *StatusListToken) GetStatusList(size int) (*StatusList, error)
GetStatusList decodes the status list from the token.
func (*StatusListToken) SetStatusList ¶
func (t *StatusListToken) SetStatusList(list *StatusList) error
SetStatusList encodes and sets the status list in the token.
func (*StatusListToken) Sign ¶
func (t *StatusListToken) Sign(s signer.Signer, opts *StatusListSignOptions) (string, error)
Sign creates a signed JWT for the status list token using the provided signer.
func (*StatusListToken) ToJSON ¶
func (t *StatusListToken) ToJSON() ([]byte, error)
ToJSON serializes the status list token payload to JSON.
type StatusReference ¶
type StatusReference struct {
// StatusListIndex is the index in the status list
StatusListIndex int `json:"status_list_index"`
// StatusListURI is the URI of the status list token
StatusListURI string `json:"status_list_uri"`
}
StatusReference is used in credentials to reference a status list.