Documentation ¶
Index ¶
- func MaybeBeginTx(ctx context.Context, storage any) (context.Context, error)
- func MaybeCommitTx(ctx context.Context, storage any) error
- func MaybeRollbackTx(ctx context.Context, storage any) error
- type IssuerPublicKeys
- type MemoryStore
- func (s *MemoryStore) Authenticate(_ context.Context, name string, secret string) error
- func (s *MemoryStore) ClientAssertionJWTValid(_ context.Context, jti string) error
- func (s *MemoryStore) CreateAccessTokenSession(_ context.Context, signature string, req oauth2.Requester) error
- func (s *MemoryStore) CreateAuthorizeCodeSession(_ context.Context, code string, req oauth2.Requester) error
- func (s *MemoryStore) CreateDeviceCodeSession(ctx context.Context, signature string, request oauth2.DeviceAuthorizeRequester) error
- func (s *MemoryStore) CreateOpenIDConnectSession(_ context.Context, authorizeCode string, requester oauth2.Requester) error
- func (s *MemoryStore) CreatePARSession(ctx context.Context, requestURI string, request oauth2.AuthorizeRequester) error
- func (s *MemoryStore) CreatePKCERequestSession(_ context.Context, code string, req oauth2.Requester) error
- func (s *MemoryStore) CreateRefreshTokenSession(_ context.Context, signature string, req oauth2.Requester) error
- func (s *MemoryStore) DeleteAccessTokenSession(_ context.Context, signature string) error
- func (s *MemoryStore) DeleteOpenIDConnectSession(_ context.Context, authorizeCode string) error
- func (s *MemoryStore) DeletePARSession(ctx context.Context, requestURI string) (err error)
- func (s *MemoryStore) DeletePKCERequestSession(_ context.Context, code string) error
- func (s *MemoryStore) DeleteRefreshTokenSession(_ context.Context, signature string) error
- func (s *MemoryStore) GetAccessTokenSession(_ context.Context, signature string, _ oauth2.Session) (oauth2.Requester, error)
- func (s *MemoryStore) GetAuthorizeCodeSession(_ context.Context, code string, _ oauth2.Session) (oauth2.Requester, error)
- func (s *MemoryStore) GetClient(_ context.Context, id string) (oauth2.Client, error)
- func (s *MemoryStore) GetDeviceCodeSession(ctx context.Context, signature string, session oauth2.Session) (oauth2.DeviceAuthorizeRequester, error)
- func (s *MemoryStore) GetDeviceCodeSessionByUserCode(ctx context.Context, signature string, session oauth2.Session) (requester oauth2.DeviceAuthorizeRequester, err error)
- func (s *MemoryStore) GetOpenIDConnectSession(_ context.Context, authorizeCode string, requester oauth2.Requester) (oauth2.Requester, error)
- func (s *MemoryStore) GetPARSession(ctx context.Context, requestURI string) (oauth2.AuthorizeRequester, error)
- func (s *MemoryStore) GetPKCERequestSession(_ context.Context, code string, _ oauth2.Session) (oauth2.Requester, error)
- func (s *MemoryStore) GetPublicKey(ctx context.Context, issuer string, subject string, keyId string) (*jose.JSONWebKey, error)
- func (s *MemoryStore) GetPublicKeyScopes(ctx context.Context, issuer string, subject string, keyId string) ([]string, error)
- func (s *MemoryStore) GetPublicKeys(ctx context.Context, issuer string, subject string) (*jose.JSONWebKeySet, error)
- func (s *MemoryStore) GetRefreshTokenSession(_ context.Context, signature string, _ oauth2.Session) (oauth2.Requester, error)
- func (s *MemoryStore) GetSubjectForTokenExchange(ctx context.Context, requester oauth2.Requester, subjectToken map[string]any) (string, error)
- func (s *MemoryStore) InvalidateAuthorizeCodeSession(ctx context.Context, code string) error
- func (s *MemoryStore) InvalidateDeviceCodeSession(_ context.Context, signature string) (err error)
- func (s *MemoryStore) IsJWTUsed(ctx context.Context, jti string) (bool, error)
- func (s *MemoryStore) MarkJWTUsedForTime(ctx context.Context, jti string, exp time.Time) error
- func (s *MemoryStore) RevokeAccessToken(ctx context.Context, requestID string) error
- func (s *MemoryStore) RevokeRefreshToken(ctx context.Context, requestID string) error
- func (s *MemoryStore) RevokeRefreshTokenMaybeGracePeriod(ctx context.Context, requestID string, signature string) error
- func (s *MemoryStore) SetClientAssertionJWT(_ context.Context, jti string, exp time.Time) error
- func (s *MemoryStore) SetTokenExchangeCustomJWT(ctx context.Context, jti string, exp time.Time) error
- func (s *MemoryStore) SetTokenLifespans(clientID string, lifespans *oauth2.ClientLifespanConfig) error
- func (s *MemoryStore) UpdateDeviceCodeSession(ctx context.Context, signature string, request oauth2.DeviceAuthorizeRequester) error
- type MemoryUserRelation
- type PublicKeyScopes
- type StoreAuthorizeCode
- type StoreRefreshToken
- type SubjectPublicKeys
- type Transactional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaybeBeginTx ¶
MaybeBeginTx is a helper function that can be used to initiate a transaction if the supplied storage implements the `Transactional` interface.
func MaybeCommitTx ¶
MaybeCommitTx is a helper function that can be used to commit a transaction if the supplied storage implements the `Transactional` interface.
Types ¶
type IssuerPublicKeys ¶
type IssuerPublicKeys struct { Issuer string KeysBySub map[string]SubjectPublicKeys }
type MemoryStore ¶
type MemoryStore struct { Clients map[string]oauth2.Client AuthorizeCodes map[string]StoreAuthorizeCode IDSessions map[string]oauth2.Requester AccessTokens map[string]oauth2.Requester RefreshTokens map[string]StoreRefreshToken DeviceCodes map[string]oauth2.Requester UserCodes map[string]oauth2.Requester PKCES map[string]oauth2.Requester Users map[string]MemoryUserRelation BlacklistedJTIs map[string]time.Time // In-memory request ID to token signatures AccessTokenRequestIDs map[string]string RefreshTokenRequestIDs map[string]string // Public keys to check signature in auth grant jwt assertion. IssuerPublicKeys map[string]IssuerPublicKeys PARSessions map[string]oauth2.AuthorizeRequester // contains filtered or unexported fields }
func NewExampleStore ¶
func NewExampleStore() *MemoryStore
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Authenticate ¶
func (*MemoryStore) ClientAssertionJWTValid ¶
func (s *MemoryStore) ClientAssertionJWTValid(_ context.Context, jti string) error
func (*MemoryStore) CreateAccessTokenSession ¶
func (*MemoryStore) CreateAuthorizeCodeSession ¶
func (*MemoryStore) CreateDeviceCodeSession ¶
func (s *MemoryStore) CreateDeviceCodeSession(ctx context.Context, signature string, request oauth2.DeviceAuthorizeRequester) error
func (*MemoryStore) CreateOpenIDConnectSession ¶
func (*MemoryStore) CreatePARSession ¶
func (s *MemoryStore) CreatePARSession(ctx context.Context, requestURI string, request oauth2.AuthorizeRequester) error
CreatePARSession stores the pushed authorization request context. The requestURI is used to derive the key.
func (*MemoryStore) CreatePKCERequestSession ¶
func (*MemoryStore) CreateRefreshTokenSession ¶
func (*MemoryStore) DeleteAccessTokenSession ¶
func (s *MemoryStore) DeleteAccessTokenSession(_ context.Context, signature string) error
func (*MemoryStore) DeleteOpenIDConnectSession ¶
func (s *MemoryStore) DeleteOpenIDConnectSession(_ context.Context, authorizeCode string) error
DeleteOpenIDConnectSession is not really called from anywhere and it is deprecated.
func (*MemoryStore) DeletePARSession ¶
func (s *MemoryStore) DeletePARSession(ctx context.Context, requestURI string) (err error)
DeletePARSession deletes the context.
func (*MemoryStore) DeletePKCERequestSession ¶
func (s *MemoryStore) DeletePKCERequestSession(_ context.Context, code string) error
func (*MemoryStore) DeleteRefreshTokenSession ¶
func (s *MemoryStore) DeleteRefreshTokenSession(_ context.Context, signature string) error
func (*MemoryStore) GetAccessTokenSession ¶
func (*MemoryStore) GetAuthorizeCodeSession ¶
func (*MemoryStore) GetDeviceCodeSession ¶
func (s *MemoryStore) GetDeviceCodeSession(ctx context.Context, signature string, session oauth2.Session) (oauth2.DeviceAuthorizeRequester, error)
func (*MemoryStore) GetDeviceCodeSessionByUserCode ¶ added in v0.1.10
func (s *MemoryStore) GetDeviceCodeSessionByUserCode(ctx context.Context, signature string, session oauth2.Session) (requester oauth2.DeviceAuthorizeRequester, err error)
func (*MemoryStore) GetOpenIDConnectSession ¶
func (*MemoryStore) GetPARSession ¶
func (s *MemoryStore) GetPARSession(ctx context.Context, requestURI string) (oauth2.AuthorizeRequester, error)
GetPARSession gets the push authorization request context. If the request is nil, a new request object is created. Otherwise, the same object is updated.
func (*MemoryStore) GetPKCERequestSession ¶
func (*MemoryStore) GetPublicKey ¶
func (*MemoryStore) GetPublicKeyScopes ¶
func (*MemoryStore) GetPublicKeys ¶
func (*MemoryStore) GetRefreshTokenSession ¶
func (*MemoryStore) GetSubjectForTokenExchange ¶
func (s *MemoryStore) GetSubjectForTokenExchange(ctx context.Context, requester oauth2.Requester, subjectToken map[string]any) (string, error)
GetSubjectForTokenExchange computes the session subject and is used for token types where there is no way to know the subject value. For some token types, such as access and refresh tokens, the subject is well-defined and this function is not called.
func (*MemoryStore) InvalidateAuthorizeCodeSession ¶
func (s *MemoryStore) InvalidateAuthorizeCodeSession(ctx context.Context, code string) error
func (*MemoryStore) InvalidateDeviceCodeSession ¶
func (s *MemoryStore) InvalidateDeviceCodeSession(_ context.Context, signature string) (err error)
func (*MemoryStore) MarkJWTUsedForTime ¶
func (*MemoryStore) RevokeAccessToken ¶
func (s *MemoryStore) RevokeAccessToken(ctx context.Context, requestID string) error
func (*MemoryStore) RevokeRefreshToken ¶
func (s *MemoryStore) RevokeRefreshToken(ctx context.Context, requestID string) error
func (*MemoryStore) RevokeRefreshTokenMaybeGracePeriod ¶
func (*MemoryStore) SetClientAssertionJWT ¶
func (*MemoryStore) SetTokenExchangeCustomJWT ¶
func (*MemoryStore) SetTokenLifespans ¶
func (s *MemoryStore) SetTokenLifespans(clientID string, lifespans *oauth2.ClientLifespanConfig) error
func (*MemoryStore) UpdateDeviceCodeSession ¶
func (s *MemoryStore) UpdateDeviceCodeSession(ctx context.Context, signature string, request oauth2.DeviceAuthorizeRequester) error
type MemoryUserRelation ¶
type PublicKeyScopes ¶
type PublicKeyScopes struct { Key *jose.JSONWebKey Scopes []string }
type StoreAuthorizeCode ¶
type StoreRefreshToken ¶
type SubjectPublicKeys ¶
type SubjectPublicKeys struct { Subject string Keys map[string]PublicKeyScopes }
type Transactional ¶
type Transactional interface { BeginTX(ctx context.Context) (context.Context, error) Commit(ctx context.Context) error Rollback(ctx context.Context) error }
Transactional represents a storage provider that has support for transactions should implement this interface to ensure atomicity for certain flows that require transactional semantics. Fosite will call these methods (when atomicity is required) if and only if the storage provider has implemented `Transactional`. It is expected that the storage provider will examine context for an existing transaction each time a database operation is to be performed.
An implementation of `BeginTX` should attempt to initiate a new transaction and store that under a unique key in the context that can be accessible by `Commit` and `Rollback`. The "transactional aware" context will then be returned for further propagation, eventually to be consumed by `Commit` or `Rollback` to finish the transaction.
Implementations for `Commit` & `Rollback` should look for the transaction object inside the supplied context using the same key used by `BeginTX`. If these methods have been called, it is expected that a txn object should be available in the provided context.