forked from matthewhartstonge/storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_manager.go
53 lines (48 loc) · 2.5 KB
/
user_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
package storage
import "context"
// UserManager provides a generic interface to users in order to build a DataStore
type UserManager interface {
Configurer
UserStorer
AuthUserMigrator
}
// UserStorer provides a definition of specific methods that are required to store a User in a data store.
type UserStorer interface {
List(ctx context.Context, filter ListUsersRequest) ([]User, error)
Create(ctx context.Context, user User) (User, error)
Get(ctx context.Context, userID string) (User, error)
GetByUsername(ctx context.Context, username string) (User, error)
Update(ctx context.Context, userID string, user User) (User, error)
Delete(ctx context.Context, userID string) error
// Utility Functions
Authenticate(ctx context.Context, username string, password string) (User, error)
AuthenticateByID(ctx context.Context, userID string, password string) (User, error)
AuthenticateByUsername(ctx context.Context, username string, password string) (User, error)
GrantScopes(ctx context.Context, userID string, scopes []string) (User, error)
RemoveScopes(ctx context.Context, userID string, scopes []string) (User, error)
}
// ListUsersRequest enables filtering stored User entities.
type ListUsersRequest struct {
// AllowedTenantAccess filters users based on an Allowed Tenant Access.
AllowedTenantAccess string `json:"allowedTenantAccess" xml:"allowedTenantAccess"`
// AllowedPersonAccess filters users based on Allowed Person Access.
AllowedPersonAccess string `json:"allowedPersonAccess" xml:"allowedPersonAccess"`
// AllowedPersonAccess filters users based on Person Access.
PersonID string `json:"personId" xml:"personId"`
// Username filters users based on username.
Username string `json:"username" xml:"username"`
// ScopesUnion filters users that have at least one of of the listed scopes.
// ScopesUnion performs an OR operation.
// If ScopesUnion is provided, a union operation will be performed as it
// returns the wider selection.
ScopesUnion []string `json:"scopesUnion" xml:"scopesUnion"`
// ScopesIntersection filters users that have all of the listed scopes.
// ScopesIntersection performs an AND operation.
ScopesIntersection []string `json:"scopesIntersection" xml:"scopesIntersection"`
// FirstName filters users based on their First Name.
FirstName string `json:"firstName" xml:"firstName"`
// LastName filters users based on their Last Name.
LastName string `json:"lastName" xml:"lastName"`
// Disabled filters users to those with disabled accounts.
Disabled bool `json:"disabled" xml:"disabled"`
}