sql

package
v2.3.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 46 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTransactionOpen = errors.New("There is no Transaction in this context.")
)
View Source
var Migrations embed.FS

Functions

This section is empty.

Types

type Dependencies

type Dependencies interface {
	ClientHasher() fosite.Hasher
	KeyCipher() *aead.AESGCM
	FlowCipher() *aead.XChaCha20Poly1305
	Kratos() kratos.Client
	contextx.Provider
	x.RegistryLogger
	x.TracingProvider
	config.Provider
}

type OAuth2RefreshTable

type OAuth2RefreshTable struct {
	OAuth2RequestSQL
	FirstUsedAt          sql.NullTime   `db:"first_used_at"`
	AccessTokenSignature sql.NullString `db:"access_token_signature"`
}

func (OAuth2RefreshTable) TableName

func (r OAuth2RefreshTable) TableName() string

type OAuth2RequestSQL

type OAuth2RequestSQL struct {
	ID                string         `db:"signature"`
	NID               uuid.UUID      `db:"nid"`
	Request           string         `db:"request_id"`
	ConsentChallenge  sql.NullString `db:"challenge_id"`
	RequestedAt       time.Time      `db:"requested_at"`
	Client            string         `db:"client_id"`
	Scopes            string         `db:"scope"`
	GrantedScope      string         `db:"granted_scope"`
	RequestedAudience string         `db:"requested_audience"`
	GrantedAudience   string         `db:"granted_audience"`
	Form              string         `db:"form_data"`
	Subject           string         `db:"subject"`
	Active            bool           `db:"active"`
	Session           []byte         `db:"session_data"`
	Table             tableName      `db:"-"`
	// InternalExpiresAt denormalizes the expiry from the session to additionally store it as a row.
	InternalExpiresAt sqlxx.NullTime `db:"expires_at" json:"-"`
}

func (OAuth2RequestSQL) TableName

func (r OAuth2RequestSQL) TableName() string

type OldMigrationRecord

type OldMigrationRecord struct {
	ID        string    `db:"id"`
	AppliedAt time.Time `db:"applied_at"`
}

this type is copied from sql-migrate to remove the dependency

type Persister

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

func NewPersister

func NewPersister(ctx context.Context, c *pop.Connection, r Dependencies, config *config.DefaultProvider, extraMigrations []fs.FS, goMigrations []popx.Migration) (*Persister, error)

func (*Persister) AcceptLogoutRequest

func (p *Persister) AcceptLogoutRequest(ctx context.Context, challenge string) (_ *flow.LogoutRequest, err error)

func (*Persister) AddKey

func (p *Persister) AddKey(ctx context.Context, set string, key *jose.JSONWebKey) (err error)

func (*Persister) AddKeySet

func (p *Persister) AddKeySet(ctx context.Context, set string, keys *jose.JSONWebKeySet) (err error)

func (*Persister) Authenticate

func (p *Persister) Authenticate(ctx context.Context, name, secret string) (subject string, err error)

func (*Persister) AuthenticateClient added in v2.2.0

func (p *Persister) AuthenticateClient(ctx context.Context, id string, secret []byte) (_ *client.Client, err error)

func (*Persister) BeginTX

func (p *Persister) BeginTX(ctx context.Context) (_ context.Context, err error)

func (*Persister) ClientAssertionJWTValid

func (p *Persister) ClientAssertionJWTValid(ctx context.Context, jti string) (err error)

func (*Persister) Commit

func (p *Persister) Commit(ctx context.Context) (err error)

func (*Persister) ConfirmLoginSession

func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.LoginSession) (err error)

ConfirmLoginSession creates or updates the login session. The NID will be set to the network ID of the context.

func (*Persister) Connection

func (p *Persister) Connection(ctx context.Context) *pop.Connection

func (*Persister) CountClients

func (p *Persister) CountClients(ctx context.Context) (n int, err error)

func (*Persister) CountGrants

func (p *Persister) CountGrants(ctx context.Context) (n int, err error)

func (*Persister) CountSubjectsGrantedConsentRequests

func (p *Persister) CountSubjectsGrantedConsentRequests(ctx context.Context, subject string) (n int, err error)

func (*Persister) CreateAccessTokenSession

func (p *Persister) CreateAccessTokenSession(ctx context.Context, signature string, requester fosite.Requester) (err error)

func (*Persister) CreateAuthorizeCodeSession

func (p *Persister) CreateAuthorizeCodeSession(ctx context.Context, signature string, requester fosite.Requester) error

func (*Persister) CreateClient

func (p *Persister) CreateClient(ctx context.Context, c *client.Client) (err error)

func (*Persister) CreateConsentRequest

func (p *Persister) CreateConsentRequest(ctx context.Context, f *flow.Flow, req *flow.OAuth2ConsentRequest) (err error)

CreateConsentRequest configures fields that are introduced or changed in the consent request. It doesn't touch fields that would be copied from the login request.

func (*Persister) CreateForcedObfuscatedLoginSession

func (p *Persister) CreateForcedObfuscatedLoginSession(ctx context.Context, session *consent.ForcedObfuscatedLoginSession) (err error)

func (*Persister) CreateGrant

func (p *Persister) CreateGrant(ctx context.Context, g trust.Grant, publicKey jose.JSONWebKey) (err error)

func (*Persister) CreateLoginRequest

func (p *Persister) CreateLoginRequest(ctx context.Context, req *flow.LoginRequest) (_ *flow.Flow, err error)

func (*Persister) CreateLoginSession

func (p *Persister) CreateLoginSession(ctx context.Context, session *flow.LoginSession) (err error)

func (*Persister) CreateLogoutRequest

func (p *Persister) CreateLogoutRequest(ctx context.Context, request *flow.LogoutRequest) (err error)

func (*Persister) CreateOpenIDConnectSession

func (p *Persister) CreateOpenIDConnectSession(ctx context.Context, signature string, requester fosite.Requester) (err error)

func (*Persister) CreatePKCERequestSession

func (p *Persister) CreatePKCERequestSession(ctx context.Context, signature string, requester fosite.Requester) (err error)

func (*Persister) CreateRefreshTokenSession

func (p *Persister) CreateRefreshTokenSession(ctx context.Context, signature string, accessTokenSignature string, requester fosite.Requester) (err error)

func (*Persister) CreateWithNetwork

func (p *Persister) CreateWithNetwork(ctx context.Context, v interface{}) error

func (*Persister) DeleteAccessTokenSession

func (p *Persister) DeleteAccessTokenSession(ctx context.Context, signature string) (err error)

func (*Persister) DeleteAccessTokens

func (p *Persister) DeleteAccessTokens(ctx context.Context, clientID string) (err error)

func (*Persister) DeleteClient

func (p *Persister) DeleteClient(ctx context.Context, id string) (err error)

func (*Persister) DeleteGrant

func (p *Persister) DeleteGrant(ctx context.Context, id string) (err error)

func (*Persister) DeleteKey

func (p *Persister) DeleteKey(ctx context.Context, set, kid string) (err error)

func (*Persister) DeleteKeySet

func (p *Persister) DeleteKeySet(ctx context.Context, set string) (err error)

func (*Persister) DeleteLoginSession

func (p *Persister) DeleteLoginSession(ctx context.Context, id string) (deletedSession *flow.LoginSession, err error)

func (*Persister) DeleteOpenIDConnectSession

func (p *Persister) DeleteOpenIDConnectSession(ctx context.Context, signature string) (err error)

func (*Persister) DeletePKCERequestSession

func (p *Persister) DeletePKCERequestSession(ctx context.Context, signature string) (err error)

func (*Persister) DeleteRefreshTokenSession

func (p *Persister) DeleteRefreshTokenSession(ctx context.Context, signature string) (err error)

func (*Persister) DetermineNetwork

func (p *Persister) DetermineNetwork(ctx context.Context) (*networkx.Network, error)

func (*Persister) FindGrantedAndRememberedConsentRequests

func (p *Persister) FindGrantedAndRememberedConsentRequests(ctx context.Context, client, subject string) (rs []flow.AcceptOAuth2ConsentRequest, err error)

func (*Persister) FindSubjectsGrantedConsentRequests

func (p *Persister) FindSubjectsGrantedConsentRequests(ctx context.Context, subject string, limit, offset int) (_ []flow.AcceptOAuth2ConsentRequest, err error)

func (*Persister) FindSubjectsSessionGrantedConsentRequests

func (p *Persister) FindSubjectsSessionGrantedConsentRequests(ctx context.Context, subject, sid string, limit, offset int) (_ []flow.AcceptOAuth2ConsentRequest, err error)

func (*Persister) FlushInactiveAccessTokens

func (p *Persister) FlushInactiveAccessTokens(ctx context.Context, notAfter time.Time, limit int, batchSize int) (err error)

func (*Persister) FlushInactiveGrants

func (p *Persister) FlushInactiveGrants(ctx context.Context, notAfter time.Time, _ int, _ int) (err error)

func (*Persister) FlushInactiveLoginConsentRequests

func (p *Persister) FlushInactiveLoginConsentRequests(ctx context.Context, notAfter time.Time, limit int, batchSize int) (err error)

func (*Persister) FlushInactiveRefreshTokens

func (p *Persister) FlushInactiveRefreshTokens(ctx context.Context, notAfter time.Time, limit int, batchSize int) (err error)

func (*Persister) GenerateAndPersistKeySet

func (p *Persister) GenerateAndPersistKeySet(ctx context.Context, set, kid, alg, use string) (_ *jose.JSONWebKeySet, err error)

func (*Persister) GetAccessTokenSession

func (p *Persister) GetAccessTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)

func (*Persister) GetAuthorizeCodeSession

func (p *Persister) GetAuthorizeCodeSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)

func (*Persister) GetClient

func (p *Persister) GetClient(ctx context.Context, id string) (fosite.Client, error)

func (*Persister) GetClientAssertionJWT

func (p *Persister) GetClientAssertionJWT(ctx context.Context, j string) (_ *oauth2.BlacklistedJTI, err error)

func (*Persister) GetClients

func (p *Persister) GetClients(ctx context.Context, filters client.Filter) (_ []client.Client, err error)

func (*Persister) GetConcreteClient

func (p *Persister) GetConcreteClient(ctx context.Context, id string) (c *client.Client, err error)

func (*Persister) GetConcreteGrant

func (p *Persister) GetConcreteGrant(ctx context.Context, id string) (_ trust.Grant, err error)

func (*Persister) GetConsentRequest

func (p *Persister) GetConsentRequest(ctx context.Context, challenge string) (_ *flow.OAuth2ConsentRequest, err error)

func (*Persister) GetFlow

func (p *Persister) GetFlow(ctx context.Context, loginChallenge string) (_ *flow.Flow, err error)

func (*Persister) GetFlowByConsentChallenge

func (p *Persister) GetFlowByConsentChallenge(ctx context.Context, challenge string) (_ *flow.Flow, err error)

func (*Persister) GetForcedObfuscatedLoginSession

func (p *Persister) GetForcedObfuscatedLoginSession(ctx context.Context, client, obfuscated string) (_ *consent.ForcedObfuscatedLoginSession, err error)

func (*Persister) GetGrants

func (p *Persister) GetGrants(ctx context.Context, limit, offset int, optionalIssuer string) (_ []trust.Grant, err error)

func (*Persister) GetKey

func (p *Persister) GetKey(ctx context.Context, set, kid string) (_ *jose.JSONWebKeySet, err error)

func (*Persister) GetKeySet

func (p *Persister) GetKeySet(ctx context.Context, set string) (keys *jose.JSONWebKeySet, err error)

func (*Persister) GetLoginRequest

func (p *Persister) GetLoginRequest(ctx context.Context, loginChallenge string) (_ *flow.LoginRequest, err error)

func (*Persister) GetLogoutRequest

func (p *Persister) GetLogoutRequest(ctx context.Context, challenge string) (_ *flow.LogoutRequest, err error)

func (*Persister) GetOpenIDConnectSession

func (p *Persister) GetOpenIDConnectSession(ctx context.Context, signature string, requester fosite.Requester) (_ fosite.Requester, err error)

func (*Persister) GetPKCERequestSession

func (p *Persister) GetPKCERequestSession(ctx context.Context, signature string, session fosite.Session) (_ fosite.Requester, err error)

func (*Persister) GetPublicKey

func (p *Persister) GetPublicKey(ctx context.Context, issuer string, subject string, keyId string) (_ *jose.JSONWebKey, err error)

func (*Persister) GetPublicKeyScopes

func (p *Persister) GetPublicKeyScopes(ctx context.Context, issuer string, subject string, keyId string) (_ []string, err error)

func (*Persister) GetPublicKeys

func (p *Persister) GetPublicKeys(ctx context.Context, issuer string, subject string) (_ *jose.JSONWebKeySet, err error)

func (*Persister) GetRefreshTokenSession

func (p *Persister) GetRefreshTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)

func (*Persister) GetRememberedLoginSession

func (p *Persister) GetRememberedLoginSession(ctx context.Context, loginSessionFromCookie *flow.LoginSession, id string) (_ *flow.LoginSession, err error)

func (*Persister) HandleConsentRequest

func (p *Persister) HandleConsentRequest(ctx context.Context, f *flow.Flow, r *flow.AcceptOAuth2ConsentRequest) (_ *flow.OAuth2ConsentRequest, err error)

func (*Persister) HandleLoginRequest

func (p *Persister) HandleLoginRequest(ctx context.Context, f *flow.Flow, challenge string, r *flow.HandledLoginRequest) (lr *flow.LoginRequest, err error)

func (*Persister) InvalidateAuthorizeCodeSession

func (p *Persister) InvalidateAuthorizeCodeSession(ctx context.Context, signature string) (err error)

func (*Persister) IsJWTUsed

func (p *Persister) IsJWTUsed(ctx context.Context, jti string) (ok bool, err error)

func (*Persister) IsNonceValid added in v2.2.0

func (p *Persister) IsNonceValid(ctx context.Context, accessToken, nonce string) (err error)

func (*Persister) ListUserAuthenticatedClientsWithBackChannelLogout

func (p *Persister) ListUserAuthenticatedClientsWithBackChannelLogout(ctx context.Context, subject, sid string) (_ []client.Client, err error)

func (*Persister) ListUserAuthenticatedClientsWithFrontChannelLogout

func (p *Persister) ListUserAuthenticatedClientsWithFrontChannelLogout(ctx context.Context, subject, sid string) (_ []client.Client, err error)

func (*Persister) MarkJWTUsedForTime

func (p *Persister) MarkJWTUsedForTime(ctx context.Context, jti string, exp time.Time) (err error)

func (*Persister) MigrateDown

func (p *Persister) MigrateDown(ctx context.Context, steps int) error

func (*Persister) MigrateUp

func (p *Persister) MigrateUp(ctx context.Context) error

func (*Persister) MigrateUpTo

func (p *Persister) MigrateUpTo(ctx context.Context, steps int) (int, error)

func (*Persister) MigrationStatus

func (p *Persister) MigrationStatus(ctx context.Context) (popx.MigrationStatuses, error)

func (*Persister) NetworkID

func (p *Persister) NetworkID(ctx context.Context) uuid.UUID

func (*Persister) NewNonce added in v2.2.0

func (p *Persister) NewNonce(ctx context.Context, accessToken string, expiresIn time.Time) (res string, err error)

func (*Persister) Ping

func (p *Persister) Ping(ctx context.Context) error

func (*Persister) PingContext

func (p *Persister) PingContext(ctx context.Context) error

func (*Persister) PrepareMigration

func (p *Persister) PrepareMigration(_ context.Context) error

func (*Persister) QueryWithNetwork

func (p *Persister) QueryWithNetwork(ctx context.Context) *pop.Query

func (*Persister) RejectLogoutRequest

func (p *Persister) RejectLogoutRequest(ctx context.Context, challenge string) (err error)

func (*Persister) RevokeAccessToken

func (p *Persister) RevokeAccessToken(ctx context.Context, id string) (err error)

func (*Persister) RevokeRefreshToken

func (p *Persister) RevokeRefreshToken(ctx context.Context, id string) (err error)

func (*Persister) RevokeSubjectClientConsentSession

func (p *Persister) RevokeSubjectClientConsentSession(ctx context.Context, user, client string) (err error)

func (*Persister) RevokeSubjectConsentSession

func (p *Persister) RevokeSubjectConsentSession(ctx context.Context, user string) (err error)

func (*Persister) RevokeSubjectLoginSession

func (p *Persister) RevokeSubjectLoginSession(ctx context.Context, subject string) (err error)

func (*Persister) Rollback

func (p *Persister) Rollback(ctx context.Context) (err error)

func (*Persister) RotateRefreshToken

func (p *Persister) RotateRefreshToken(ctx context.Context, requestID string, refreshTokenSignature string) (err error)

func (*Persister) SetClientAssertionJWT

func (p *Persister) SetClientAssertionJWT(ctx context.Context, jti string, exp time.Time) (err error)

func (*Persister) SetClientAssertionJWTRaw

func (p *Persister) SetClientAssertionJWTRaw(ctx context.Context, jti *oauth2.BlacklistedJTI) (err error)

func (*Persister) Transaction

func (p *Persister) Transaction(ctx context.Context, f func(ctx context.Context, c *pop.Connection) error) error

func (*Persister) UpdateClient

func (p *Persister) UpdateClient(ctx context.Context, cl *client.Client) (err error)

func (*Persister) UpdateKey

func (p *Persister) UpdateKey(ctx context.Context, set string, key *jose.JSONWebKey) (err error)

UpdateKey updates or creates the key.

func (*Persister) UpdateKeySet

func (p *Persister) UpdateKeySet(ctx context.Context, set string, keySet *jose.JSONWebKeySet) (err error)

UpdateKeySet updates or creates the key set.

func (*Persister) UpdateWithNetwork

func (p *Persister) UpdateWithNetwork(ctx context.Context, v interface{}) (int64, error)

func (*Persister) VerifyAndInvalidateConsentRequest

func (p *Persister) VerifyAndInvalidateConsentRequest(ctx context.Context, verifier string) (_ *flow.AcceptOAuth2ConsentRequest, err error)

func (*Persister) VerifyAndInvalidateLoginRequest

func (p *Persister) VerifyAndInvalidateLoginRequest(ctx context.Context, verifier string) (_ *flow.HandledLoginRequest, err error)

func (*Persister) VerifyAndInvalidateLogoutRequest

func (p *Persister) VerifyAndInvalidateLogoutRequest(ctx context.Context, verifier string) (_ *flow.LogoutRequest, err error)

func (Persister) WithFallbackNetworkID

func (p Persister) WithFallbackNetworkID(nid uuid.UUID) persistence.Persister

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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