forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_setting_oidc.go
45 lines (35 loc) · 1.23 KB
/
admin_setting_oidc.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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tfe
import (
"context"
)
// Compile-time proof of interface implementation.
var _ OIDCSettings = (*adminOIDCSettings)(nil)
// OidcSettings describes all the OIDC admin settings for the Admin Setting API.
// https://developer.hashicorp.com/terraform/enterprise/api-docs/admin/settings
type OIDCSettings interface {
// Rotate the key used for signing OIDC tokens for workload identity
RotateKey(ctx context.Context) error
// Trim old version of the key used for signing OIDC tokens for workload identity
TrimKey(ctx context.Context) error
}
type adminOIDCSettings struct {
client *Client
}
// Rotate the key used for signing OIDC tokens for workload identity
func (a *adminOIDCSettings) RotateKey(ctx context.Context) error {
req, err := a.client.NewRequest("POST", "admin/oidc-settings/actions/rotate-key", nil)
if err != nil {
return err
}
return req.Do(ctx, nil)
}
// Trim old version of the key used for signing OIDC tokens for workload identity
func (a *adminOIDCSettings) TrimKey(ctx context.Context) error {
req, err := a.client.NewRequest("POST", "admin/oidc-settings/actions/trim-key", nil)
if err != nil {
return err
}
return req.Do(ctx, nil)
}