-
Notifications
You must be signed in to change notification settings - Fork 251
/
types.go
690 lines (567 loc) · 21.9 KB
/
types.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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
// This source code file is AUTO-GENERATED by github.com/taskcluster/jsonschema2go
package tcauth
import (
"encoding/json"
"errors"
tcclient "github.com/taskcluster/taskcluster/v48/clients/client-go"
)
type (
// Response for a request to get access to an S3 bucket.
AWSS3CredentialsResponse struct {
// Temporary STS credentials for use when operating on S3
Credentials TemporarySecurityCredentials `json:"credentials"`
// Date and time of when the temporary credentials expires.
Expires tcclient.Time `json:"expires"`
}
// Response from a request to authenticate a hawk request.
AuthenticationFailedResponse struct {
// Message saying why the authentication failed.
Message string `json:"message"`
// If `auth-failed`, the request failed to authenticate (e.g., invalid credentials).
//
// Possible values:
// * "auth-failed"
Status string `json:"status"`
}
// Response from a request to authenticate a hawk request.
AuthenticationSuccessfulResponse struct {
// The `clientId` that made this request. This may be the `id` supplied in
// the Authorization header, or in the case of a named temporary credential
// may be embedded in the payload. In any case, this clientId can be used
// for logging, auditing, and identifying the credential but **must** not be
// used for access control. That's what scopes are for.
//
// Syntax: ^[A-Za-z0-9!@/:.+|_-]+$
ClientID string `json:"clientId"`
// The expiration time that the returned scopes are valid for.
// This should be treated as the latest time at which the authorization
// is valid. For most cases, where the access being authorized occurs
// immediately, this field can be ignored, as the value will always be
// in the future.
Expires tcclient.Time `json:"expires"`
// Payload as extracted from `Authentication` header. This property is
// only present if a hash is available. You are not required to validate
// this hash, but if you do, please check `scheme` to ensure that it's
// on a scheme you support.
Hash json.RawMessage `json:"hash,omitempty"`
// Authentication scheme the client used. Generally, you don't need to
// read this property unless `hash` is provided and you want to validate
// the payload hash. Additional values may be added in the future.
//
// Possible values:
// * "hawk"
Scheme string `json:"scheme"`
// List of scopes the client is authorized to access. Scopes must be
// composed of printable ASCII characters and spaces.
//
// Array items:
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
// If `auth-success`, the request has successfully authenticated.
// This does not imply authorization (i.e. scope satisfaction not guaranteed).
//
// Possible values:
// * "auth-success"
Status string `json:"status"`
}
// Response to a request for an Shared-Access-Signature to access an Azure
// Blob Storage container.
AzureBlobSharedAccessSignature struct {
// Date and time of when the Shared-Access-Signature expires.
Expiry tcclient.Time `json:"expiry"`
// Shared-Access-Signature string. This is the querystring parameters to
// be appened after `?` or `&` depending on whether or not a querystring is
// already present in the URL.
Sas string `json:"sas"`
}
// A list of Azure accounts managed by taskcluster-auth
AzureListAccountResponse struct {
// A list of accountIds that are managed by auth. These are
// the accounts that can have SAS credentials fetched for tables
// within them.
//
// Array items:
Accounts []string `json:"accounts"`
}
// A list of Azure containers in an account
AzureListContainersResponse struct {
// A list of containers that are in an account. Credentials are available for
// these containers from the `azureBlobSAS` method.
//
// Array items:
Containers []string `json:"containers"`
// Opaque `continuationToken` to be given as query-string option to get the
// next set of containers.
// This property is only present if another request is necessary to fetch all
// results. In practice the next request with a `continuationToken` may not
// return additional results, but it can. Thus, you can only be sure to have
// all the results if you've called this method with `continuationToken`
// until you get a result without a `continuationToken`.
ContinuationToken string `json:"continuationToken,omitempty"`
}
// A list of Azure tables in an account
AzureListTableResponse struct {
// Opaque `continuationToken` to be given as query-string option to get the
// next set of tables.
// This property is only present if another request is necessary to fetch all
// results. In practice the next request with a `continuationToken` may not
// return additional results, but it can. Thus, you can only be sure to have
// all the results if you've called `azureAccountTables` with `continuationToken`
// until you get a result without a `continuationToken`.
ContinuationToken string `json:"continuationToken,omitempty"`
// A list of tables that are in an account. These are
// the tables that can have SAS credentials fetched for them.
//
// Array items:
Tables []string `json:"tables"`
}
// Response to a request for an Shared-Access-Signature to access and Azure
// Table Storage table.
AzureTableSharedAccessSignature struct {
// Date and time of when the Shared-Access-Signature expires.
Expiry tcclient.Time `json:"expiry"`
// Shared-Access-Signature string. This is the querystring parameters to
// be appened after `?` or `&` depending on whether or not a querystring is
// already present in the URL.
Sas string `json:"sas"`
}
// Properties to create a client.
CreateClientRequest struct {
// If `true`, the service may delete this client after it has expired. If
// `false` (the default), the client will remain after expiration, although
// it cannot be used for authentication in that state.
//
// Default: false
DeleteOnExpiration bool `json:"deleteOnExpiration,omitempty"`
// Description of what these credentials are used for in markdown.
// Should include who is the owner, point of contact.
//
// Max length: 10240
Description string `json:"description"`
// Date and time where the clients access is set to expire
Expires tcclient.Time `json:"expires"`
// List of scopes the client has (unexpanded).
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes,omitempty"`
}
// All details about a client including the `accessToken`
CreateClientResponse struct {
// AccessToken used for authenticating requests, you should store this
// you won't be able to retrive it again!
//
// Syntax: ^[a-zA-Z0-9_-]{22,66}$
AccessToken string `json:"accessToken"`
// ClientId of the client
//
// Syntax: ^[A-Za-z0-9!@/:.+|_-]+$
ClientID string `json:"clientId"`
// Date and time when this client was created
Created tcclient.Time `json:"created"`
// If `true`, the service may delete this client after it has expired. If
// `false`, the client will remain after expiration, although it cannot be
// used for authentication in that state.
DeleteOnExpiration bool `json:"deleteOnExpiration"`
// Description of what these credentials are used for in markdown.
// Should include who is the owner, point of contact.
//
// Max length: 10240
Description string `json:"description"`
// If true, this client is disabled and cannot be used. This usually occurs when the
// scopes available to the user owning the client no longer satisfy the client.
Disabled bool `json:"disabled"`
// List of scopes granted to this client by matching roles, including the
// client's scopes and the implicit role `client-id:<clientId>`.
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
ExpandedScopes []string `json:"expandedScopes"`
// Date and time where the clients access is set to expire
Expires tcclient.Time `json:"expires"`
// Date of last time this client was used. Will only be updated every 6 hours
// or so this may be off by up-to 6 hours. But it still gives a solid hint
// as to whether or not this client is in use.
LastDateUsed tcclient.Time `json:"lastDateUsed"`
// Date and time of last modification
LastModified tcclient.Time `json:"lastModified"`
// Date and time of when the `accessToken` was reset last time.
LastRotated tcclient.Time `json:"lastRotated"`
// List of scopes the client has (unexpanded).
//
// Default: []
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// Data to create or update a role.
CreateRoleRequest struct {
// Description of what this role is used for in markdown.
// Should include who is the owner, point of contact.
//
// Max length: 10240
Description string `json:"description"`
// List of scopes the role grants access to. Scopes must be composed of
// printable ASCII characters and spaces.
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// Access credentials and urls for the Sentry project.
// Credentials will expire in 24-48 hours, you should refresh them within
// 24 hours.
Dsn struct {
// Access credential and URL for public error reports.
// These credentials can be used for up-to 24 hours.
// This is for use in client-side applications only.
Public string `json:"public"`
// Access credential and URL for private error reports.
// These credentials can be used for up-to 24 hours.
// This is for use in serser-side applications and should **not** be
// leaked.
Secret string `json:"secret"`
}
// Response for a request to get a GCP temporary credential.
GCPCredentialsResponse struct {
// Temporary oauth2 access token to access the given service account
AccessToken string `json:"accessToken"`
// The access token expire time
ExpireTime tcclient.Time `json:"expireTime"`
}
// List of roles
GetAllRolesNoPagination []GetRoleResponse
// If no limit is given, all roles are returned. Since this
// list may become long, callers can use the `limit` and `continuationToken`
// query arguments to page through the responses.
GetAllRolesResponse struct {
// A continuation token is returned if there are more results than listed
// here. You can optionally provide the token in the request payload to
// load the additional results.
ContinuationToken string `json:"continuationToken,omitempty"`
// A list of requested roles
Roles []GetRoleResponse `json:"roles"`
}
// Get all details about a client, useful for tools modifying a client
GetClientResponse struct {
// ClientId of the client scopes is requested about
//
// Syntax: ^[A-Za-z0-9!@/:.+|_-]+$
ClientID string `json:"clientId"`
// Date and time when this client was created
Created tcclient.Time `json:"created"`
// If `true`, the service may delete this client after it has expired. If
// `false`, the client will remain after expiration, although it cannot be
// used for authentication in that state.
DeleteOnExpiration bool `json:"deleteOnExpiration"`
// Description of what these credentials are used for in markdown.
// Should include who is the owner, point of contact.
//
// Max length: 10240
Description string `json:"description"`
// If true, this client is disabled and cannot be used. This usually occurs when the
// scopes available to the user owning the client no longer satisfy the client.
Disabled bool `json:"disabled"`
// List of scopes granted to this client by matching roles. Scopes must be
// composed of printable ASCII characters and spaces.
//
// Array items:
// Scope that client is granted by a role
//
// Syntax: ^[ -~]*$
ExpandedScopes []string `json:"expandedScopes"`
// Date and time where the clients access is set to expire
Expires tcclient.Time `json:"expires"`
// Date of last time this client was used. Will only be updated every 6 hours
// or so this may be off by up-to 6 hours. But it still gives a solid hint
// as to whether or not this client is in use.
LastDateUsed tcclient.Time `json:"lastDateUsed"`
// Date and time of last modification
LastModified tcclient.Time `json:"lastModified"`
// Date and time of when the `accessToken` was reset last time.
LastRotated tcclient.Time `json:"lastRotated"`
// List of scopes the client has (unexpanded). Scopes must be composed of
// printable ASCII characters and spaces.
//
// Default: []
//
// Array items:
// Scope
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// If no limit is given, the roleIds of all roles are returned. Since this
// list may become long, callers can use the `limit` and `continuationToken`
// query arguments to page through the responses.
GetRoleIdsResponse struct {
// A continuation token is returned if there are more results than listed
// here. You can optionally provide the token in the request payload to
// load the additional results.
ContinuationToken string `json:"continuationToken,omitempty"`
// A list of requested roleIds
//
// Array items:
RoleIds []string `json:"roleIds"`
}
// Get all details about a role
GetRoleResponse struct {
// Date and time when this role was created
Created tcclient.Time `json:"created"`
// Description of what this role is used for in markdown.
// Should include who is the owner, point of contact.
//
// Max length: 10240
Description string `json:"description"`
// List of scopes granted anyone who assumes this role, including anything
// granted by roles that can be assumed when you have this role.
// Hence, this includes any scopes in-directly granted as well.
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
ExpandedScopes []string `json:"expandedScopes"`
// Date and time of last modification
LastModified tcclient.Time `json:"lastModified"`
// roleId of the role requested
//
// Syntax: ^[\x20-\x7e]+$
RoleID string `json:"roleId"`
// List of scopes the role grants access to. Scopes must be composed of
// printable ASCII characters and spaces.
//
// Array items:
// A single scope. A scope must be composed of
// printable ASCII characters and spaces. Scopes ending in more than
// one `*` character are forbidden.
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// Request to authenticate a hawk request.
HawkSignatureAuthenticationRequest struct {
// Authorization header, **must** only be specified if request being
// authenticated has a `Authorization` header.
Authorization string `json:"authorization,omitempty"`
// Host for which the request came in, this is typically the `Host` header
// excluding the port if any.
Host string `json:"host"`
// HTTP method of the request being authenticated.
//
// Possible values:
// * "get"
// * "post"
// * "put"
// * "head"
// * "delete"
// * "options"
// * "trace"
// * "copy"
// * "lock"
// * "mkcol"
// * "move"
// * "purge"
// * "propfind"
// * "proppatch"
// * "unlock"
// * "report"
// * "mkactivity"
// * "checkout"
// * "merge"
// * "m-search"
// * "notify"
// * "subscribe"
// * "unsubscribe"
// * "patch"
// * "search"
// * "connect"
Method string `json:"method"`
// Port on which the request came in, this is typically `80` or `443`.
// If you are running behind a reverse proxy look for the `x-forwarded-port`
// header.
//
// Mininum: 0
// Maximum: 65535
Port int64 `json:"port"`
// Resource the request operates on including querystring. This is the
// string that follows the HTTP method.
// **Note,** order of querystring elements is important.
Resource string `json:"resource"`
// Source IP of the authentication request or request that requires
// authentication. This is only used for audit logging.
//
// One of:
// * SourceIP
// * SourceIP1
SourceIP string `json:"sourceIp,omitempty"`
}
// Response from a request to authenticate a hawk request.
//
// One of:
// * AuthenticationSuccessfulResponse
// * AuthenticationFailedResponse
// * NoAuthenticationResponse
HawkSignatureAuthenticationResponse json.RawMessage
// List of clients
ListClientResponse struct {
Clients []GetClientResponse `json:"clients"`
// A continuation token is returned if there are more results than listed
// here. You can optionally provide the token in the request payload to
// load the additional results.
ContinuationToken string `json:"continuationToken,omitempty"`
}
// Response from a request to authenticate a hawk request.
NoAuthenticationResponse struct {
// The expiration time that the returned scopes are valid for.
// This should be treated as the latest time at which the authorization
// is valid. For most cases, where the access being authorized occurs
// immediately, this field can be ignored, as the value will always be
// in the future.
Expires tcclient.Time `json:"expires"`
// Authentication scheme the client used. Generally, you don't need to
// read this property unless `hash` is provided and you want to validate
// the payload hash. Additional values may be added in the future.
//
// Possible values:
// * "none"
Scheme string `json:"scheme"`
// List of scopes the client is authorized to access. Scopes must be
// composed of printable ASCII characters and spaces.
//
// Array items:
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
// If `no-auth`, the request provided no credentials or bewit.
//
// Possible values:
// * "no-auth"
Status string `json:"status"`
}
// Sentry DSN for submitting errors.
SentryDSNResponse struct {
// Access credentials and urls for the Sentry project.
// Credentials will expire in 24-48 hours, you should refresh them within
// 24 hours.
Dsn Dsn `json:"dsn"`
// Expiration time for the credentials. The credentials should not be used
// after this time. They might not be revoked immediately, but will be at
// some arbitrary point after this date-time.
Expires tcclient.Time `json:"expires"`
// Project name that the DSN grants access to.
Project string `json:"project"`
}
// A set of scopes
SetOfScopes struct {
// List of scopes. Scopes must be composed of printable ASCII characters and spaces.
//
// Array items:
// Scope
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// Source IP of the authentication request or request that requires
// authentication. This is only used for audit logging.
SourceIP string
// Source IP of the authentication request or request that requires
// authentication. This is only used for audit logging.
SourceIP1 string
// Temporary STS credentials for use when operating on S3
TemporarySecurityCredentials struct {
// Access key identifier that identifies the temporary security
// credentials.
AccessKeyID string `json:"accessKeyId"`
// Secret access key used to sign requests
SecretAccessKey string `json:"secretAccessKey"`
// A token that must passed with request to use the temporary
// security credentials.
SessionToken string `json:"sessionToken"`
}
// Details on how the test request should be authenticated.
TestAuthenticateRequest struct {
// List of scopes that should be client used should be given.
//
// Default: []
//
// Array items:
// Scope
//
// Syntax: ^[ -~]*$
ClientScopes []string `json:"clientScopes"`
// List of scopes the request should require.
//
// Default: []
//
// Array items:
// Scope
//
// Syntax: ^[ -~]*$
RequiredScopes []string `json:"requiredScopes"`
}
// Details on how the test request was authenticated.
TestAuthenticateResponse struct {
// ClientId from the request as it will be logged
//
// Syntax: ^[A-Za-z0-9!@/:.+|_-]+$
ClientID string `json:"clientId"`
// List of scopes the request was authorized.
//
// Default: []
//
// Array items:
// Scope
//
// Syntax: ^[ -~]*$
Scopes []string `json:"scopes"`
}
// Token for connecting a worker to websocktunnel proxy
WebsocktunnelTokenResponse struct {
// The time at which the JWT will expire.
Expires tcclient.Time `json:"expires"`
// The JWT to be used as `Bearer <token>` when connecting to the service.
Token string `json:"token"`
// Audience identifying the websocktunnel servers that will honor this token; this will be the
// same as the requested `wstAudience`.
//
// Syntax: ^[a-zA-Z0-9_-]{1,38}$
WstAudience string `json:"wstAudience"`
// Id for the websocktunnel client connection; this will be the same as the requested `wstClient`.
//
// Syntax: ^[a-zA-Z0-9_~.%-]+$
WstClient string `json:"wstClient"`
}
)
// MarshalJSON calls json.RawMessage method of the same name. Required since
// HawkSignatureAuthenticationResponse is of type json.RawMessage...
func (this *HawkSignatureAuthenticationResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
}
// UnmarshalJSON is a copy of the json.RawMessage implementation.
func (this *HawkSignatureAuthenticationResponse) UnmarshalJSON(data []byte) error {
if this == nil {
return errors.New("HawkSignatureAuthenticationResponse: UnmarshalJSON on nil pointer")
}
*this = append((*this)[0:0], data...)
return nil
}