/
models.go
216 lines (191 loc) · 7.43 KB
/
models.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package gocloak
// APIError represents an api error
type APIError struct {
Code int
Message string
}
// Error stringifies the APIError
func (apiError APIError) Error() string {
return apiError.Message
}
type CertResponseKey struct {
Kid string `json:"kid"`
Kty string `json:"kty"`
Alg string `json:"alg"`
Use string `json:"use"`
N string `json:"n"`
E string `json:"e"`
}
// CertResponse is retuned by the certs endpoint
type CertResponse struct {
Keys []CertResponseKey `json:"keys"`
}
// IssuerResponse is returned by the issuer endpoint
type IssuerResponse struct {
Realm string `json:"realm"`
PublicKey string `json:"public_key"`
TokenService string `json:"token-service"`
AccountService string `json:"account-service"`
TokensNotBefore int `json:"tokens-not-before"`
}
// RetrospecTokenResult is returned when a token was checked
type RetrospecTokenResult struct {
Permissions map[string]string `json:"permissions,omitempty"`
Exp int `json:"exp,omitempty"`
Nbf int `json:"nbf,omitempty"`
Iat int `json:"iat,omitempty"`
Aud string `json:"aud,omitempty"`
Active bool `json:"active,omitempty"`
AuthTime int `json:"auth_time,omitempty"`
Jti string `json:"jti,omitempty"`
Type string `json:"typ,omitempty"`
}
// User represents the Keycloak User Structure
type User struct {
ID string `json:"id,omitempty"`
CreatedTimestamp int64 `json:"createdTimestamp,omitempty"`
Username string `json:"username,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Totp bool `json:"totp,omitempty"`
EmailVerified bool `json:"emailVerified,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
FederationLink string `json:"federationLink,omitempty"`
Attributes map[string][]string `json:"attributes,omitempty"`
DisableableCredentialTypes []interface{} `json:"disableableCredentialTypes,omitempty"`
RequiredActions []interface{} `json:"requiredActions,omitempty"`
Access map[string]bool `json:"access,omitempty"`
}
// SetPasswordRequest sets a new password
type SetPasswordRequest struct {
Type string `json:"type"`
Temporary bool `json:"temporary"`
Password string `json:"value"`
}
// Component is a component
type Component struct {
ID string `json:"id"`
Name string `json:"name"`
ProviderID string `json:"providerId"`
ProviderType string `json:"providerType"`
ParentID string `json:"parentId"`
ComponentConfig ComponentConfig `json:"config"`
SubType string `json:"subType,omitempty"`
}
// ComponentConfig is a componentconfig
type ComponentConfig struct {
Priority []string `json:"priority"`
Algorithm []string `json:"algorithm"`
}
// KeyStoreConfig holds the keyStoreConfig
type KeyStoreConfig struct {
ActiveKeys ActiveKeys `json:"active"`
Key []Key `json:"keys"`
}
// ActiveKeys holds the active keys
type ActiveKeys struct {
HS256 string `json:"HS256"`
RS256 string `json:"RS256"`
AES string `json:"AES"`
}
// Key is a key
type Key struct {
ProviderID string `json:"providerId"`
ProviderPriority int `json:"providerPriority"`
Kid string `json:"kid"`
Status string `json:"status"`
Type string `json:"type"`
Algorithm string `json:"algorithm"`
PublicKey string `json:"publicKey,omitempty"`
Certificate string `json:"certificate,omitempty"`
}
// Attributes holds Attributes
type Attributes struct {
LDAPENTRYDN []string `json:"LDAP_ENTRY_DN"`
LDAPID []string `json:"LDAP_ID"`
}
// Access represents access
type Access struct {
ManageGroupMembership bool `json:"manageGroupMembership"`
View bool `json:"view"`
MapRoles bool `json:"mapRoles"`
Impersonate bool `json:"impersonate"`
Manage bool `json:"manage"`
}
// UserGroup is a UserGroup
type UserGroup struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
}
// Group is a Group
type Group struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
SubGroups []interface{} `json:"subGroups,omitempty"`
}
// Role is a role
type Role struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ScopeParamRequired bool `json:"scopeParamRequired,omitempty"`
Composite bool `json:"composite,omitempty"`
ClientRole bool `json:"clientRole,omitempty"`
ContainerID string `json:"containerId,omitempty"`
Description string `json:"description,omitempty,omitempty"`
}
// RoleMapping is a role mapping
type RoleMapping struct {
ID string `json:"id"`
Client string `json:"client"`
Mappings []ClientRoleMappingRole `json:"mappings"`
}
// ClientRoleMappingRole is a client role mapping role
type ClientRoleMappingRole struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
ScopeParamRequired bool `json:"scopeParamRequired"`
Composite bool `json:"composite"`
ClientRole bool `json:"clientRole"`
ContainerID string `json:"containerId"`
}
// ClientScope is a ClientScope
type ClientScope struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Protocol string `json:"protocol"`
ClientScopeAttributes ClientScopeAttributes `json:"attributes"`
ProtocolMappers ProtocolMappers `json:"protocolMappers,omitempty"`
}
// ClientScopeAttributes are attributes of client scopes
type ClientScopeAttributes struct {
ConsentScreenText string `json:"consent.screen.text"`
DisplayOnConsentScreen string `json:"display.on.consent.screen"`
}
// ProtocolMappers are protocolmappers
type ProtocolMappers struct {
ID string `json:"id"`
Name string `json:"name"`
Protocol string `json:"protocol"`
ProtocolMapper string `json:"protocolMapper"`
ConsentRequired bool `json:"consentRequired"`
ProtocolMappersConfig ProtocolMappersConfig `json:"config"`
}
// ProtocolMappersConfig is a config of a protocol mapper
type ProtocolMappersConfig struct {
UserinfoTokenClaim string `json:"userinfo.token.claim"`
UserAttribute string `json:"user.attribute"`
IDTokenClaim string `json:"id.token.claim"`
AccessTokenClaim string `json:"access.token.claim"`
ClaimName string `json:"claim.name"`
JSONTypeLabel string `json:"jsonType.label"`
}
// Client is a Client
type Client struct {
ID string `json:"id"`
ClientID string `json:"clientId"`
}