forked from go-auth0/auth0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_server.go
74 lines (54 loc) · 2.34 KB
/
resource_server.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
package management
type ResourceServer struct {
// A generated string identifying the resource server.
ID string `json:"id,omitempty"`
// The name of the resource server. Must contain at least one character.
// Does not allow '<' or '>'
Name string `json:"name,omitempty"`
// The identifier of the resource server.
Identifier string `json:"identifier,omitempty"`
// Scopes supported by the resource server.
Scopes []*ResourceServerScope `json:"scopes,omitempty"`
// The algorithm used to sign tokens ["HS256" or "RS256"].
SigningAlgorithm string `json:"signing_alg,omitempty"`
// The secret used to sign tokens when using symmetric algorithms.
SigningSecret string `json:"signing_secret,omitempty"`
// Allows issuance of refresh tokens for this entity.
AllowOfflineAccess bool `json:"allow_offline_access,omitempty"`
// The amount of time in seconds that the token will be valid after being
// issued.
TokenLifetime int `json:"token_lifetime,omitempty"`
// Flag this entity as capable of skipping consent
SkipConsentForVerifiableFirstPartyClients bool `json:"skip_consent_for_verifiable_first_party_clients,omitempty"`
// A URI from which to retrieve JWKs for this resource server used for
// verifying the JWT sent to Auth0 for token introspection.
VerificationLocation string `json:"verificationLocation,omitempty"`
Options map[string]interface{} `json:"options,omitempty"`
}
type ResourceServerScope struct {
// The scope name. Use the format <action>:<resource> for example
// 'delete:client_grants'.
Value string `json:"value,omitempty"`
// Description of the scope
Description string `json:"description,omitempty"`
}
type ResourceServerManager struct {
m *Management
}
func NewResourceServerManager(m *Management) *ResourceServerManager {
return &ResourceServerManager{m}
}
func (r *ResourceServerManager) Create(rs *ResourceServer) (err error) {
return r.m.post(r.m.getURI("resource-servers"), rs)
}
func (r *ResourceServerManager) Read(id string) (*ResourceServer, error) {
rs := new(ResourceServer)
err := r.m.get(r.m.getURI("resource-servers", id), rs)
return rs, err
}
func (r *ResourceServerManager) Update(id string, rs *ResourceServer) (err error) {
return r.m.patch(r.m.getURI("resource-servers", id), rs)
}
func (r *ResourceServerManager) Delete(id string) (err error) {
return r.m.delete(r.m.getURI("resource-servers", id))
}