forked from ory/kratos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpool.go
103 lines (76 loc) · 4.33 KB
/
pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package identity
import (
"context"
"github.com/ory/x/crdbx"
"github.com/ory/kratos/x"
"github.com/ory/x/pagination/keysetpagination"
"github.com/ory/x/sqlxx"
"github.com/gofrs/uuid"
)
type (
ListIdentityParameters struct {
Expand Expandables
IdsFilter []string
CredentialsIdentifier string
CredentialsIdentifierSimilar string
DeclassifyCredentials []CredentialsType
KeySetPagination []keysetpagination.Option
// DEPRECATED
PagePagination *x.Page
ConsistencyLevel crdbx.ConsistencyLevel
}
Pool interface {
// ListIdentities lists all identities in the store given the page and itemsPerPage.
ListIdentities(ctx context.Context, params ListIdentityParameters) ([]Identity, *keysetpagination.Paginator, error)
// CountIdentities counts the number of identities in the store.
CountIdentities(ctx context.Context) (int64, error)
// GetIdentity returns an identity by its id. Will return an error if the identity does not exist or backend
// connectivity is broken.
GetIdentity(context.Context, uuid.UUID, sqlxx.Expandables) (*Identity, error)
// FindVerifiableAddressByValue returns a matching address or sql.ErrNoRows if no address could be found.
FindVerifiableAddressByValue(ctx context.Context, via string, address string) (*VerifiableAddress, error)
// FindRecoveryAddressByValue returns a matching address or sql.ErrNoRows if no address could be found.
FindRecoveryAddressByValue(ctx context.Context, via RecoveryAddressType, address string) (*RecoveryAddress, error)
}
PoolProvider interface {
IdentityPool() Pool
}
PrivilegedPoolProvider interface {
PrivilegedIdentityPool() PrivilegedPool
}
PrivilegedPool interface {
Pool
// FindByCredentialsIdentifier returns an identity by querying for it's credential identifiers.
FindByCredentialsIdentifier(ctx context.Context, ct CredentialsType, match string) (*Identity, *Credentials, error)
// DeleteIdentity removes an identity by its id. Will return an error
// if identity exists, backend connectivity is broken, or trait validation fails.
DeleteIdentity(context.Context, uuid.UUID) error
// UpdateVerifiableAddress updates an identity's verifiable address.
UpdateVerifiableAddress(ctx context.Context, address *VerifiableAddress) error
// CreateIdentity creates an identity. It is capable of setting credentials without encoding. Will return an error
// if identity exists, backend connectivity is broken, or trait validation fails.
CreateIdentity(context.Context, *Identity) error
// CreateIdentities creates multiple identities. It is capable of setting credentials without encoding. Will return an error
// if identity exists, backend connectivity is broken, or trait validation fails.
CreateIdentities(context.Context, ...*Identity) error
// UpdateIdentity updates an identity including its confidential / privileged / protected data.
UpdateIdentity(context.Context, *Identity) error
// GetIdentityConfidential returns the identity including it's raw credentials. This should only be used internally.
GetIdentityConfidential(context.Context, uuid.UUID) (*Identity, error)
// ListVerifiableAddresses lists all tracked verifiable addresses, regardless of whether they are already verified
// or not.
ListVerifiableAddresses(ctx context.Context, page, itemsPerPage int) ([]VerifiableAddress, error)
// ListRecoveryAddresses lists all tracked recovery addresses.
ListRecoveryAddresses(ctx context.Context, page, itemsPerPage int) ([]RecoveryAddress, error)
// HydrateIdentityAssociations hydrates the associations of an identity.
HydrateIdentityAssociations(ctx context.Context, i *Identity, expandables Expandables) error
// InjectTraitsSchemaURL sets the identity's traits JSON schema URL from the schema's ID.
InjectTraitsSchemaURL(ctx context.Context, i *Identity) error
// FindIdentityByCredentialIdentifier returns an identity by matching the identifier to any of the identity's credentials.
FindIdentityByCredentialIdentifier(ctx context.Context, identifier string, caseSensitive bool) (*Identity, error)
// FindIdentityByWebauthnUserHandle returns an identity matching a webauthn user handle.
FindIdentityByWebauthnUserHandle(ctx context.Context, userHandle []byte) (*Identity, error)
}
)