types

package
v1.50.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAudience = "authula"

Variables

This section is empty.

Functions

This section is empty.

Types

type JWK added in v1.16.0

type JWK struct {
	Kty string `json:"kty" required:"true" nullable:"false"`
	Crv string `json:"crv,omitempty" nullable:"false"`
	Kid string `json:"kid,omitempty" nullable:"false"`
	X   string `json:"x,omitempty" nullable:"false"`
	Alg string `json:"alg,omitempty" nullable:"false"`
	Use string `json:"use,omitempty" nullable:"false"`
	N   string `json:"n,omitempty" nullable:"false"`
	E   string `json:"e,omitempty" nullable:"false"`
}

type JWKS

type JWKS struct {
	bun.BaseModel `bun:"table:jwks"`

	ID         string     `json:"id" bun:"column:id,pk"`
	PublicKey  string     `json:"public_key" bun:"column:public_key"`
	PrivateKey string     `json:"private_key" bun:"column:private_key"`
	ExpiresAt  *time.Time `json:"expires_at" bun:"column:expires_at"`
	CreatedAt  time.Time  `json:"created_at" bun:"column:created_at,default:current_timestamp"`
}

type JWTPluginConfig

type JWTPluginConfig struct {
	Enabled                bool          `json:"enabled" toml:"enabled"`
	KeyRotationInterval    time.Duration `json:"key_rotation_interval" toml:"key_rotation_interval"`         // Default: 30 days
	KeyRotationGracePeriod time.Duration `json:"key_rotation_grace_period" toml:"key_rotation_grace_period"` // Grace period for old key validity after rotation, default: 1 hour
	ExpiresIn              time.Duration `json:"expires_in" toml:"expires_in"`                               // Access token TTL
	RefreshExpiresIn       time.Duration `json:"refresh_expires_in" toml:"refresh_expires_in"`               // Refresh token TTL
	JWKSCacheTTL           time.Duration `json:"jwks_cache_ttl" toml:"jwks_cache_ttl"`                       // Cache TTL for JWKS, default 24 hours
	RefreshGracePeriod     time.Duration `json:"refresh_grace_period" toml:"refresh_grace_period"`           // Grace period for refresh token reuse, default 10s
	Issuer                 string        `json:"issuer" toml:"issuer"`                                       // Token issuer; defaults to base_url + base_path
	Audience               string        `json:"audience" toml:"audience"`                                   // Token audience; defaults to "authula"
}

func (*JWTPluginConfig) ApplyDefaults

func (c *JWTPluginConfig) ApplyDefaults()

func (*JWTPluginConfig) ApplyDefaultsFromGlobal added in v1.50.1

func (c *JWTPluginConfig) ApplyDefaultsFromGlobal(baseURL, basePath string)

ApplyDefaultsFromGlobal fills the issuer and audience when they are not configured. The issuer is derived from the public base URL and base path so tokens identify this Authula deployment.

func (*JWTPluginConfig) Validate added in v1.50.1

func (c *JWTPluginConfig) Validate() error

Validate rejects configurations that would mint or accept ambiguous tokens.

type JWTTokenType

type JWTTokenType string
const (
	JWTTokenTypeAccess  JWTTokenType = "access_token"
	JWTTokenTypeRefresh JWTTokenType = "refresh_token"
)

func (JWTTokenType) String

func (t JWTTokenType) String() string

type RefreshErrorResponse added in v1.50.1

type RefreshErrorResponse struct {
	Message string `json:"message" required:"true" nullable:"false"`
}

RefreshErrorResponse is the generic error body returned by the refresh endpoint.

type RefreshToken

type RefreshToken struct {
	bun.BaseModel `bun:"table:refresh_tokens"`

	ID               string     `json:"id" bun:"column:id,pk"`
	SessionID        string     `json:"session_id" bun:"column:session_id"`
	TokenHash        string     `json:"token_hash" bun:"column:token_hash"`
	ExpiresAt        time.Time  `json:"expires_at" bun:"column:expires_at"`
	IsRevoked        bool       `json:"is_revoked" bun:"column:is_revoked"`
	RevokedAt        *time.Time `json:"revoked_at" bun:"column:revoked_at"`
	LastReuseAttempt *time.Time `json:"last_reuse_attempt" bun:"column:last_reuse_attempt"`
	CreatedAt        time.Time  `json:"created_at" bun:"column:created_at,default:current_timestamp"`
}

type RefreshTokenRequest added in v1.7.0

type RefreshTokenRequest struct {
	RefreshToken string `json:"refresh_token" required:"true" nullable:"false"`
}

func (*RefreshTokenRequest) Validate added in v1.7.0

func (r *RefreshTokenRequest) Validate() error

type RefreshTokenResponse added in v1.7.0

type RefreshTokenResponse struct {
	AccessToken  string `json:"access_token" required:"true" nullable:"false"`
	RefreshToken string `json:"refresh_token" required:"true" nullable:"false"`
	TokenType    string `json:"token_type" required:"true" nullable:"false"`
	ExpiresIn    int64  `json:"expires_in" required:"true" nullable:"false"`
}

type TokenClaims added in v1.9.0

type TokenClaims struct {
	Subject        string   `json:"sub"`
	Issuer         string   `json:"iss"`
	Audience       []string `json:"aud"`
	UserID         string   `json:"user_id,omitempty"`
	SessionID      string   `json:"session_id,omitempty"`
	TokenType      string   `json:"token_type"`
	ActorType      string   `json:"actor_type,omitempty"`
	ClientID       string   `json:"client_id,omitempty"`
	OrganizationID string   `json:"organization_id,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
	JTI            string   `json:"jti"`
	IssuedAt       int64    `json:"iat"`
	Expiration     int64    `json:"exp"`
}

type TokenPair

type TokenPair struct {
	AccessToken  string        `json:"access_token"`
	RefreshToken string        `json:"refresh_token"`
	ExpiresIn    time.Duration `json:"expires_in"`
	TokenType    string        `json:"token_type"`
}

type WellKnownJWKSResponse added in v1.16.0

type WellKnownJWKSResponse struct {
	Keys []JWK `json:"keys" required:"true" nullable:"false"`
}

Jump to

Keyboard shortcuts

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