This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
security.go
297 lines (231 loc) · 13.4 KB
/
security.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package responses
// UserResponse represents a user response
type UserResponse struct {
Name string `json:"name"`
URI string `json:"uri"`
}
func (u UserResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (u UserResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (u UserResponse) deprecated() bool { return false }
// UserResponseTestData is test data for a user response
const UserResponseTestData = "user.json"
// GetUserDetailsResponse represents a user detail response
type GetUserDetailsResponse struct {
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password"`
Admin bool `json:"admin"`
ProfileUpdatable bool `json:"profileUpdatable"`
DisableUIAccess bool `json:"disableUIAccess"`
InternalPasswordDisabled bool `json:"internalPasswordDisabled"`
LastLoggedIn *JSONTime `json:"lastLoggedIn"`
Realm string `json:"realm"`
Groups []string `json:"groups"`
}
func (u GetUserDetailsResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (u GetUserDetailsResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (u GetUserDetailsResponse) deprecated() bool { return false }
// GetUserDetailsResponseTestData is test data for a user detail response
const GetUserDetailsResponseTestData = "user_detail.json"
// GetUsersResponse represents a GetUsers response
type GetUsersResponse []UserResponse
// GetUsersResponseTestData is test data for a get users response
const GetUsersResponseTestData = "users.json"
func (u GetUsersResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (u GetUsersResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (u GetUsersResponse) deprecated() bool { return false }
// GetEncryptedPasswordResponse is a placeholder type for getting the current user's encrypted password
type GetEncryptedPasswordResponse struct{}
func (u GetEncryptedPasswordResponse) minVersion() Version { return versionMustParse("3.3.0") }
func (u GetEncryptedPasswordResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (u GetEncryptedPasswordResponse) deprecated() bool { return false }
// GetPasswordExpirationPolicyResponse represents a GetPasswordExpirationPolicy response
type GetPasswordExpirationPolicyResponse struct {
Enabled bool `json:"enabled"`
PasswordMaxAge int `json:"passwordMaxAge"`
NotifyByEmail bool `json:"notifyByEmail"`
}
// GetPasswordExpirationPolicyResponseTestData is test data for GetPasswordExpirationPolicyResponse
const GetPasswordExpirationPolicyResponseTestData = "password_expiration_policy.json"
func (r GetPasswordExpirationPolicyResponse) minVersion() Version { return versionMustParse("4.4.2") }
func (r GetPasswordExpirationPolicyResponse) maxVersion() Version {
return versionMustParse(CurrentVersion)
}
func (r GetPasswordExpirationPolicyResponse) deprecated() bool { return false }
// RetrieveUserLockPolicyResponse represents a RetrieveUserLockPolicy response
type RetrieveUserLockPolicyResponse struct {
Enabled bool `json:"enabled"`
LoginAttempts int `json:"loginAttempts"`
}
// RetrieveUserLockPolicyResponseTestData is test data for RetrieveUserLockPolicyResponse
const RetrieveUserLockPolicyResponseTestData = "user_lock_policy.json"
func (r RetrieveUserLockPolicyResponse) minVersion() Version { return versionMustParse("4.4") }
func (r RetrieveUserLockPolicyResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r RetrieveUserLockPolicyResponse) deprecated() bool { return false }
// CreateAPIKeyResponse represents a CreateAPIKey response
type CreateAPIKeyResponse struct {
APIKey string `json:"apiKey"`
}
// CreateAPIKeyResponseTestData is test data for CreateAPIKeyResponse
const CreateAPIKeyResponseTestData = "api_key.json"
func (r CreateAPIKeyResponse) minVersion() Version { return versionMustParse("4.3.0") }
func (r CreateAPIKeyResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r CreateAPIKeyResponse) deprecated() bool { return false }
// RegenerateAPIKeyResponse represents a RegenerateAPIKey response
type RegenerateAPIKeyResponse struct {
APIKey string `json:"apiKey"`
}
// RegenerateAPIKeyResponseTestData is test data for RegenerateAPIKeyResponse
const RegenerateAPIKeyResponseTestData = "api_key.json"
func (r RegenerateAPIKeyResponse) minVersion() Version { return versionMustParse("4.3.0") }
func (r RegenerateAPIKeyResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r RegenerateAPIKeyResponse) deprecated() bool { return false }
// GetAPIKeyResponse represents a GetAPIKey response
type GetAPIKeyResponse struct {
APIKey string `json:"apiKey"`
}
// GetAPIKeyResponseTestData is test data for GetAPIKeyResponse
const GetAPIKeyResponseTestData = "api_key.json"
func (r GetAPIKeyResponse) minVersion() Version { return versionMustParse("4.3.0") }
func (r GetAPIKeyResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetAPIKeyResponse) deprecated() bool { return false }
// GroupResponse is an entry in a GetGroupsResponse
type GroupResponse struct {
Name string `json:"name"`
URI string `json:"uri"`
}
// GetGroupsResponse represents a GetGroups response
type GetGroupsResponse []GroupResponse
// GetGroupsResponseTestData is test data for GetGroupsResponse
const GetGroupsResponseTestData = "groups.json"
func (r GetGroupsResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (r GetGroupsResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetGroupsResponse) deprecated() bool { return false }
// GetGroupDetailsResponse represents a GetGroupDetails response
type GetGroupDetailsResponse struct {
Name string `json:"name"`
Description string `json:"description"`
AutoJoin bool `json:"autojoin"`
Realm string `json:"realm"`
AdminPrivileges bool `json:"adminPrivileges"`
}
// GetGroupDetailsResponseTestData is test data for GetGroupDetailsResponse
const GetGroupDetailsResponseTestData = "group.json"
func (r GetGroupDetailsResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (r GetGroupDetailsResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetGroupDetailsResponse) deprecated() bool { return false }
// PermissionTargetEntry is an individual entry for GetPermissionTargetsResponse
type PermissionTargetEntry struct {
Name string `json:"name"`
URI string `json:"uri"`
}
// GetPermissionTargetsResponse represents a GetPermissionTargets response
type GetPermissionTargetsResponse []PermissionTargetEntry
// GetPermissionTargetsResponseTestData is test data for GetPermissionTargetsResponse
const GetPermissionTargetsResponseTestData = "permission_targets.json"
func (r GetPermissionTargetsResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (r GetPermissionTargetsResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetPermissionTargetsResponse) deprecated() bool { return false }
// GetPermissionTargetDetailsResponse represents a GetPermissionTarget response
type GetPermissionTargetDetailsResponse struct {
Name string `json:"name"`
IncludesPattern string `json:"includesPattern"`
ExcludesPattern string `json:"excludesPattern"`
Repositories []string `json:"repositories"`
Principals map[string]map[string][]string `json:"principals"`
}
// GetPermissionTargetDetailsResponseTestData is test data for GetPermissionTargetResponse
const GetPermissionTargetDetailsResponseTestData = "permission_target.json"
func (r GetPermissionTargetDetailsResponse) minVersion() Version { return versionMustParse("2.4.0") }
func (r GetPermissionTargetDetailsResponse) maxVersion() Version {
return versionMustParse(CurrentVersion)
}
func (r GetPermissionTargetDetailsResponse) deprecated() bool { return false }
// CreateTokenResponse represents a CreateToken response
type CreateTokenResponse struct {
Scope string `json:"scope"`
ExpiresIn int `json:"expires_in"`
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
RefreshToken string `json:"refresh_token,omitempty"`
}
// CreateTokenResponseTestData is test data for CreateTokenResponse
const CreateTokenResponseTestData = "create_token.json"
func (r CreateTokenResponse) minVersion() Version { return versionMustParse("5.0.0") }
func (r CreateTokenResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r CreateTokenResponse) deprecated() bool { return false }
// RefreshTokenResponse represents a RefreshToken response
type RefreshTokenResponse struct {
Scope string `json:"scope"`
ExpiresIn int `json:"expires_in"`
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
RefreshToken string `json:"refresh_token,omitempty"`
}
// RefreshTokenResponseTestData is test data for RefreshTokenResponse
const RefreshTokenResponseTestData = "create_token.json"
func (r RefreshTokenResponse) minVersion() Version { return versionMustParse("5.0.0") }
func (r RefreshTokenResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r RefreshTokenResponse) deprecated() bool { return false }
// RevokeTokenResponse represents a RevokeToken response
type RevokeTokenResponse struct{}
func (r RevokeTokenResponse) minVersion() Version { return versionMustParse("5.0.0") }
func (r RevokeTokenResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r RevokeTokenResponse) deprecated() bool { return false }
// GetUserEncryptedPasswordResponse represents a GetUserEncryptedPassword response
type GetUserEncryptedPasswordResponse struct{}
func (r GetUserEncryptedPasswordResponse) minVersion() Version { return versionMustParse("3.3.0") }
func (r GetUserEncryptedPasswordResponse) maxVersion() Version {
return versionMustParse(CurrentVersion)
}
func (r GetUserEncryptedPasswordResponse) deprecated() bool { return false }
// GetLockedOutUsersResponse represents a GetLockedOutUsers response
type GetLockedOutUsersResponse []string
// GetLockedOutUsersResponseTestData is test data for GetLockedOutUsersResponse
const GetLockedOutUsersResponseTestData = "get_locked_out_users.json"
func (r GetLockedOutUsersResponse) minVersion() Version { return versionMustParse("4.4") }
func (r GetLockedOutUsersResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetLockedOutUsersResponse) deprecated() bool { return false }
// GetGPGPublicKeyResponse represents a GetGPGPublicKey response
type GetGPGPublicKeyResponse struct{}
func (r GetGPGPublicKeyResponse) minVersion() Version { return versionMustParse("3.3") }
func (r GetGPGPublicKeyResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetGPGPublicKeyResponse) deprecated() bool { return false }
// GetServiceIDResponse represents a GetServiceID response
type GetServiceIDResponse struct{}
func (r GetServiceIDResponse) minVersion() Version { return versionMustParse("5.0.0") }
func (r GetServiceIDResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetServiceIDResponse) deprecated() bool { return false }
// CertificateResponseEntry represents an individual cert entry in a GetCertificatesResponse
type CertificateResponseEntry struct {
CertificateAlias string `json:"certificateAlias"`
IssuedTo string `json:"issuedTo"`
IssuedBy string `json:"issuedBy"`
IssuedOn *JSONTime `json:"issuedOn"`
ValidUntil *JSONTime `json:"validUntil"`
Fingerprint string `json:"fingerPrint"`
}
// GetCertificatesResponse represents a GetCertificates response
type GetCertificatesResponse []*CertificateResponseEntry
// GetCertificatesResponseTestData is test data for GetCertificatesResponse
const GetCertificatesResponseTestData = "get_certificates.json"
func (r GetCertificatesResponse) minVersion() Version { return versionMustParse("5.4.0") }
func (r GetCertificatesResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r GetCertificatesResponse) deprecated() bool { return false }
// EffectiveItemPermissionsResponse represents a EffectiveItemPermissions response
type EffectiveItemPermissionsResponse struct {
URI string `json:"uri"`
Principals map[string]map[string][]string `json:"principals"`
}
// EffectiveItemPermissionsResponseTestData is test data for EffectiveItemPermissionsResponse
const EffectiveItemPermissionsResponseTestData = "effective_item_permissions.json"
func (r EffectiveItemPermissionsResponse) minVersion() Version { return versionMustParse("2.3.4") }
func (r EffectiveItemPermissionsResponse) maxVersion() Version {
return versionMustParse(CurrentVersion)
}
func (r EffectiveItemPermissionsResponse) deprecated() bool { return false }
// SecurityConfigurationResponse represents a SecurityConfiguration response
type SecurityConfigurationResponse struct{}
func (r SecurityConfigurationResponse) minVersion() Version { return versionMustParse("2.2.0") }
func (r SecurityConfigurationResponse) maxVersion() Version { return versionMustParse(CurrentVersion) }
func (r SecurityConfigurationResponse) deprecated() bool { return false }