/
signing_key.go
83 lines (64 loc) · 2.51 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
81
82
83
package management
import "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 Authok SigningKey resources.
type SigningKeyManager struct {
*Management
}
func newSigningKeyManager(m *Management) *SigningKeyManager {
return &SigningKeyManager{m}
}
// List all Application Signing Keys.
//
// See: https://authok.com/docs/api/management/v1#!/Keys/get_signing_keys
func (m *SigningKeyManager) List(opts ...RequestOption) (ks []*SigningKey, err error) {
err = m.Request("GET", m.URI("keys", "signing"), &ks, opts...)
return
}
// Read an Application Signing Key by its key id.
//
// See: https://authok.com/docs/api/management/v1#!/Keys/get_signing_key
func (m *SigningKeyManager) Read(kid string, opts ...RequestOption) (k *SigningKey, err error) {
err = m.Request("GET", m.URI("keys", "signing", kid), &k, opts...)
return
}
// Rotate the Application Signing Key.
//
// See: https://authok.com/docs/api/management/v1#!/Keys/post_signing_keys
func (m *SigningKeyManager) Rotate(opts ...RequestOption) (k *SigningKey, err error) {
err = m.Request("POST", m.URI("keys", "signing", "rotate"), &k, opts...)
return
}
// Revoke an Application Signing Key by its key id.
//
// See: https://authok.com/docs/api/management/v1#!/Keys/put_signing_keys
func (m *SigningKeyManager) Revoke(kid string, opts ...RequestOption) (k *SigningKey, err error) {
err = m.Request("PUT", m.URI("keys", "signing", kid, "revoke"), &k, opts...)
return
}