-
Notifications
You must be signed in to change notification settings - Fork 30
/
serviceuser.go
89 lines (71 loc) · 1.86 KB
/
serviceuser.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
package serviceuser
import (
"time"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/raystack/frontier/pkg/metadata"
)
const (
DefaultKeyType = "sv_rsa"
)
type State string
func (s State) String() string {
return string(s)
}
const (
Enabled State = "enabled"
Disabled State = "disabled"
)
type ServiceUser struct {
ID string
OrgID string
Title string
State string
Metadata metadata.Metadata
// CreatedByUser is a transient field that is used to track the user who created this service user
// this doesn't have any impact on the service user itself
CreatedByUser string
CreatedAt time.Time
UpdatedAt time.Time
}
type CredentialType string
func (c CredentialType) String() string {
return string(c)
}
const (
ClientSecretCredentialType CredentialType = "client_credential"
JWTCredentialType CredentialType = "jwt_bearer"
OpaqueTokenCredentialType CredentialType = "opaque_token"
)
type Credential struct {
// ID is the unique identifier of the credential.
// This is also used as kid in JWT, the spec doesn't
// state how the kid should be generated as anyway this token
// is owned by frontier, and we are in control of key generation
// any arbitrary string can be used as kid as long as its unique
ID string
ServiceUserID string
Type CredentialType
// SecretHash used for basic auth
SecretHash string
// PublicKey used for JWT verification using RSA
PublicKey jwk.Set
// PrivateKey used for JWT signing using RSA, this is not stored and
// only generated and returned when creating a new credential
PrivateKey []byte
Title string
Metadata metadata.Metadata
CreatedAt time.Time
UpdatedAt time.Time
}
type Secret struct {
ID string
Title string
Value string
CreatedAt time.Time
}
type Token struct {
ID string
Title string
Value string
CreatedAt time.Time
}