forked from auth0/go-auth0
/
signing_key.go
80 lines (62 loc) · 2.6 KB
/
signing_key.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
package management
import (
"context"
"time"
)
// SigningKey is used for signing tokens.
type SigningKey struct {
// The key id of the signing key.
KID *string `json:"kid,omitempty"`
// The public certificate of the signing key.
Cert *string `json:"cert,omitempty"`
// The public certificate of the signing key in pkcs7 format.
PKCS7 *string `json:"pkcs7,omitempty"`
// True if the key is the the current key.
Current *bool `json:"current,omitempty"`
// True if the key is the the next key.
Next *bool `json:"next,omitempty"`
// True if the key is the the previous key.
Previous *bool `json:"previous,omitempty"`
// The date and time when the key became the current key.
CurrentSince *time.Time `json:"current_since,omitempty"`
// The date and time when the current key was rotated.
CurrentUntil *time.Time `json:"current_until,omitempty"`
// The cert fingerprint.
Fingerprint *string `json:"fingerprint,omitempty"`
// The cert thumbprint.
Thumbprint *string `json:"thumbprint,omitempty"`
// True if the key is revoked.
Revoked *bool `json:"revoked,omitempty"`
// The date and time when the key was revoked.
RevokedAt *time.Time `json:"revoked_at,omitempty"`
}
// SigningKeyManager manages Auth0 SigningKey resources.
type SigningKeyManager manager
// List all Application Signing Keys.
//
// See: https://auth0.com/docs/api/management/v2#!/Keys/get_signing_keys
func (m *SigningKeyManager) List(ctx context.Context, opts ...RequestOption) (ks []*SigningKey, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("keys", "signing"), &ks, opts...)
return
}
// Read an Application Signing Key by its key id.
//
// See: https://auth0.com/docs/api/management/v2#!/Keys/get_signing_key
func (m *SigningKeyManager) Read(ctx context.Context, kid string, opts ...RequestOption) (k *SigningKey, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("keys", "signing", kid), &k, opts...)
return
}
// Rotate the Application Signing Key.
//
// See: https://auth0.com/docs/api/management/v2#!/Keys/post_signing_keys
func (m *SigningKeyManager) Rotate(ctx context.Context, opts ...RequestOption) (k *SigningKey, err error) {
err = m.management.Request(ctx, "POST", m.management.URI("keys", "signing", "rotate"), &k, opts...)
return
}
// Revoke an Application Signing Key by its key id.
//
// See: https://auth0.com/docs/api/management/v2#!/Keys/put_signing_keys
func (m *SigningKeyManager) Revoke(ctx context.Context, kid string, opts ...RequestOption) (k *SigningKey, err error) {
err = m.management.Request(ctx, "PUT", m.management.URI("keys", "signing", kid, "revoke"), &k, opts...)
return
}