auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendQuery

func AppendQuery(raw string, values url.Values) string

func ConfiguredLoginValue

func ConfiguredLoginValue() string

func ConstantTimeEqual

func ConstantTimeEqual(a, b string) bool

func EquivalentResourceURI

func EquivalentResourceURI(left, right string) bool

func IssueToken

func IssueToken(issuer, audience, grantID, key string, ttl time.Duration) (string, error)

func ParseBearerToken

func ParseBearerToken(header string) (string, bool)

func RandomToken

func RandomToken(n int) (string, error)

func ValidPKCEChallenge

func ValidPKCEChallenge(challenge string) bool

func ValidateToken

func ValidateToken(token, issuer, audience, key string) (string, bool)

func VerifyPKCE

func VerifyPKCE(verifier, challenge string) bool

Types

type Bearer

type Bearer struct {
	Token string
}

func (Bearer) Authorized

func (b Bearer) Authorized(r *http.Request) bool

func (Bearer) Enabled

func (b Bearer) Enabled() bool

type OAuthClientRegistration

type OAuthClientRegistration struct {
	ClientName   string   `json:"client_name,omitempty"`
	RedirectURIs []string `json:"redirect_uris"`
	GrantTypes   []string `json:"grant_types"`
	IssuedAt     int64    `json:"issued_at"`
	LastUsedAt   int64    `json:"last_used_at,omitempty"`
}

type OAuthCode

type OAuthCode struct {
	ClientID    string
	RedirectURI string
	Challenge   string
	Resource    string
	GrantID     string
	Redeemed    bool
	ExpiresAt   time.Time
}

type OAuthGrant

type OAuthGrant struct {
	ClientID          string `json:"client_id"`
	Resource          string `json:"resource"`
	CurrentGeneration uint64 `json:"current_generation"`
	ExpiresAt         int64  `json:"expires_at"`
	Revoked           bool   `json:"revoked,omitempty"`
}

type OAuthStore

type OAuthStore struct {
	// contains filtered or unexported fields
}

func NewOAuthStore

func NewOAuthStore() *OAuthStore

func NewPersistentOAuthStore

func NewPersistentOAuthStore(path, signingKey string) (*OAuthStore, error)

func (*OAuthStore) ActivateGrant

func (s *OAuthStore) ActivateGrant(clientID, resource, grantID string, ttl time.Duration) error

func (*OAuthStore) ClientAllowsGrant

func (s *OAuthStore) ClientAllowsGrant(clientID, grantType string) bool

func (*OAuthStore) ClientRegistration

func (s *OAuthStore) ClientRegistration(clientID string) (OAuthClientRegistration, bool)

func (*OAuthStore) Create

func (s *OAuthStore) Create(code OAuthCode) (string, error)

func (*OAuthStore) GrantActive

func (s *OAuthStore) GrantActive(grantID string) bool

func (*OAuthStore) IssueRefreshToken

func (s *OAuthStore) IssueRefreshToken(clientID, resource, grantID string, ttl time.Duration) (string, error)

func (*OAuthStore) PruneExpiredClients

func (s *OAuthStore) PruneExpiredClients(now time.Time) (int, error)

func (*OAuthStore) Redeem

func (s *OAuthStore) Redeem(raw, clientID, redirectURI, verifier, resource string) (OAuthCode, bool, bool)

Redeem validates every authorization-code binding while holding the store lock and consumes the code only after all checks succeed.

func (*OAuthStore) RegisterClient

func (s *OAuthStore) RegisterClient(clientName string, redirectURIs, grantTypes []string) (string, error)

func (*OAuthStore) RevokeGrant

func (s *OAuthStore) RevokeGrant(grantID string, ttl time.Duration) error

func (*OAuthStore) RotateRefreshToken

func (s *OAuthStore) RotateRefreshToken(raw, clientID, requestedResource string, ttl time.Duration) (string, string, string, bool, error)

func (*OAuthStore) ValidateClientID

func (s *OAuthStore) ValidateClientID(clientID string) bool

func (*OAuthStore) ValidateClientRedirect

func (s *OAuthStore) ValidateClientRedirect(clientID, redirectURI string) bool

Jump to

Keyboard shortcuts

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