-
Notifications
You must be signed in to change notification settings - Fork 7
/
client_manager.go
73 lines (66 loc) · 2.93 KB
/
client_manager.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
package storage
import (
// Standard Library Imports
"context"
// External Imports
"github.com/ory/fosite"
)
// ClientManager provides a generic interface to clients in order to build a
// Datastore backend.
type ClientManager interface {
Configurer
ClientStorer
AuthClientMigrator
}
// ClientStorer conforms to fosite.Storage and provides methods
type ClientStorer interface {
// fosite.Storage provides get client.
fosite.Storage
List(ctx context.Context, filter ListClientsRequest) ([]Client, error)
Create(ctx context.Context, client Client) (Client, error)
Get(ctx context.Context, clientID string) (Client, error)
Update(ctx context.Context, clientID string, client Client) (Client, error)
Delete(ctx context.Context, clientID string) error
// Utility Functions
Authenticate(ctx context.Context, clientID string, secret string) (Client, error)
GrantScopes(ctx context.Context, clientID string, scopes []string) (Client, error)
RemoveScopes(ctx context.Context, clientID string, scopes []string) (Client, error)
}
// ListClientsRequest enables listing and filtering client records.
type ListClientsRequest struct {
// AllowedTenantAccess filters clients based on an Allowed Tenant Access.
AllowedTenantAccess string `json:"allowedTenantAccess" xml:"allowedTenantAccess"`
// AllowedRegion filters clients based on an Allowed Region.
AllowedRegion string `json:"allowedRegion" xml:"allowedRegion"`
// RedirectURI filters clients based on redirectURI.
RedirectURI string `json:"redirectURI" xml:"redirectURI"`
// GrantType filters clients based on GrantType.
GrantType string `json:"grantType" xml:"grantType"`
// ResponseType filters clients based on ResponseType.
ResponseType string `json:"responseType" xml:"responseType"`
// ScopesIntersection filters clients that have at least the listed scopes.
// ScopesIntersection performs an AND operation.
// For example:
// - given ["cats"] the client must have "cats" in their scopes.
// - given ["cats, dogs"] the client must have "cats" AND "dogs in their
// scopes.
//
// If ScopesUnion is provided, a union operation will be performed as it
// returns the wider selection.
ScopesIntersection []string `json:"scopesIntersection" xml:"scopesIntersection"`
// ScopesUnion filters users that have at least one of the listed scopes.
// ScopesUnion performs an OR operation.
// For example:
// - given ["cats"] the client must have "cats" in their scopes.
// - given ["cats, dogs"] the client must have "cats" OR "dogs in their
// scopes.
ScopesUnion []string `json:"scopesUnion" xml:"scopesUnion"`
// Contact filters clients based on Contact.
Contact string `json:"contact" xml:"contact"`
// Public filters clients based on Public status.
Public bool `json:"public" xml:"public"`
// Disabled filters clients based on denied access.
Disabled bool `json:"disabled" xml:"disabled"`
// Published filters clients based on published status.
Published bool `json:"published" xml:"published"`
}