Repository navigation
Expand file tree
/
Copy pathadmin_types.go
More file actions
104 lines (90 loc) · 5.27 KB
/
Copy pathadmin_types.go
File metadata and controls
104 lines (90 loc) · 5.27 KB
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
package scim
import "time"
// ---------------------------------------------------------------------------
// Admin API requests and responses
//
// These are the routes a dashboard calls to connect an IdP: create a config,
// mint a token to paste into the IdP, rotate it, revoke it. They are a
// separate surface from the SCIM 2.0 protocol in routes.go, which an IdP
// calls with one of these tokens, and they are mounted under /v1 rather than
// the SCIM base path so an IdP's bearer token can never reach them.
// ---------------------------------------------------------------------------
// ListSCIMConfigsRequest binds GET /orgs/:orgId/scim/configs.
type ListSCIMConfigsRequest struct {
OrgID string `path:"orgId" description:"Organization ID"`
}
// ConfigListResponse is a page of SCIM configurations.
type ConfigListResponse struct {
Configs []*SCIMConfig `json:"configs" description:"SCIM configurations for the organization"`
}
// CreateSCIMConfigRequest binds POST /orgs/:orgId/scim/configs.
type CreateSCIMConfigRequest struct {
OrgID string `path:"orgId" description:"Organization ID"`
Name string `json:"name" description:"A name for this connection, e.g. the IdP's name"`
Enabled *bool `json:"enabled,omitempty" description:"Whether provisioning is accepted. Defaults to true"`
AutoCreate *bool `json:"auto_create,omitempty" description:"Create users on first push"`
AutoSuspend *bool `json:"auto_suspend,omitempty" description:"Suspend users the IdP deactivates"`
GroupSync *bool `json:"group_sync,omitempty" description:"Sync SCIM groups to teams"`
DefaultRole string `json:"default_role,omitempty" description:"Org role given to provisioned users"`
Metadata map[string]string `json:"metadata,omitempty" description:"Free-form metadata"`
}
// GetSCIMConfigRequest binds GET and DELETE /scim/configs/:configId.
type GetSCIMConfigRequest struct {
ConfigID string `path:"configId" description:"SCIM configuration ID"`
}
// UpdateSCIMConfigRequest binds PATCH /scim/configs/:configId. Every field is
// a pointer so that leaving one out means "do not change it", which is what
// separates a PATCH from a PUT.
type UpdateSCIMConfigRequest struct {
ConfigID string `path:"configId" description:"SCIM configuration ID"`
Name *string `json:"name,omitempty" description:"New name"`
Enabled *bool `json:"enabled,omitempty" description:"Turn provisioning on or off"`
AutoCreate *bool `json:"auto_create,omitempty" description:"Create users on first push"`
AutoSuspend *bool `json:"auto_suspend,omitempty" description:"Suspend users the IdP deactivates"`
GroupSync *bool `json:"group_sync,omitempty" description:"Sync SCIM groups to teams"`
DefaultRole *string `json:"default_role,omitempty" description:"Org role given to provisioned users"`
Metadata map[string]string `json:"metadata,omitempty" description:"Replaces the stored metadata"`
}
// ListSCIMTokensRequest binds GET /scim/configs/:configId/tokens.
type ListSCIMTokensRequest struct {
ConfigID string `path:"configId" description:"SCIM configuration ID"`
}
// TokenListResponse is a config's tokens. The plaintext is never here:
// it exists once, in the response that created it.
type TokenListResponse struct {
Tokens []*Token `json:"tokens" description:"Tokens for this configuration"`
}
// CreateSCIMTokenRequest binds POST /scim/configs/:configId/tokens.
type CreateSCIMTokenRequest struct {
ConfigID string `path:"configId" description:"SCIM configuration ID"`
Name string `json:"name" description:"A name for this token, e.g. which IdP holds it"`
ExpiresAt *time.Time `json:"expires_at,omitempty" description:"When it stops working. Omit for no expiry"`
}
// RotateSCIMTokenRequest binds POST /scim/tokens/:tokenId/rotate.
type RotateSCIMTokenRequest struct {
TokenID string `path:"tokenId" description:"Token being replaced"`
Name string `json:"name,omitempty" description:"Name for the replacement"`
// GraceSeconds keeps the old token working for a while after the new one
// is minted, so an IdP can be updated without a window where provisioning
// fails. Zero revokes the old one at once.
GraceSeconds int `json:"grace_seconds,omitempty" description:"How long the replaced token keeps working, in seconds"`
}
// RevokeSCIMTokenRequest binds DELETE /scim/tokens/:tokenId.
type RevokeSCIMTokenRequest struct {
TokenID string `path:"tokenId" description:"Token to revoke"`
}
// TokenCreatedResponse carries a freshly minted token.
//
// Plaintext appears here and nowhere else, ever: the store keeps a hash. A
// caller that loses it has to rotate. The base URL is included because it is
// the other half of what gets pasted into an IdP, and having to assemble it
// from documentation is how people paste the wrong one.
type TokenCreatedResponse struct {
Token *Token `json:"token" description:"The token record"`
Plaintext string `json:"plaintext" description:"The bearer token. Shown once and never again"`
BaseURL string `json:"base_url" description:"SCIM 2.0 base URL to configure in the identity provider"`
}
// StatusResponse is the answer to a delete.
type StatusResponse struct {
Status string `json:"status" description:"Outcome"`
}