Skip to content

Commit 968d930

Browse files
committed
upload OIDC discovery data to disco backend
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
1 parent d31c31a commit 968d930

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

internal/cyberark/dataupload/dataupload.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ type Snapshot struct {
5757
ClusterDescription string `json:"cluster_description,omitempty"`
5858
// K8SVersion is the version of Kubernetes which the cluster is running.
5959
K8SVersion string `json:"k8s_version"`
60+
// OIDCConfig contains OIDC configuration data from the API server's
61+
// `/.well-known/openid-configuration` endpoint
62+
OIDCConfig map[string]any `json:"openid_configuration,omitempty"`
63+
// OIDCConfigError contains any error encountered while fetching the OIDC configuration
64+
OIDCConfigError string `json:"openid_configuration_error,omitempty"`
65+
// JWKS contains JWKS data from the API server's `/openid/v1/jwks` endpoint
66+
JWKS map[string]any `json:"jwks,omitempty"`
67+
// JWKSError contains any error encountered while fetching the JWKS
68+
JWKSError string `json:"jwks_error,omitempty"`
6069
// Secrets is a list of Secret resources in the cluster. Not all Secret
6170
// types are included and only a subset of the Secret data is included.
6271
Secrets []runtime.Object `json:"secrets"`

pkg/client/client_cyberark.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,25 @@ func baseSnapshotFromOptions(opts Options) dataupload.Snapshot {
9292
}
9393
}
9494

95+
// extractOIDCFromReading converts the opaque data from a DiscoveryData
96+
// data reading to allow access to the OIDC fields within.
97+
func extractOIDCFromReading(reading *api.DataReading, target *dataupload.Snapshot) error {
98+
if reading == nil {
99+
return fmt.Errorf("programmer mistake: the DataReading must not be nil")
100+
}
101+
data, ok := reading.Data.(*api.OIDCDiscoveryData)
102+
if !ok {
103+
return fmt.Errorf(
104+
"programmer mistake: the DataReading must have data type *api.DiscoveryData. "+
105+
"This DataReading (%s) has data type %T", reading.DataGatherer, reading.Data)
106+
}
107+
target.OIDCConfig = data.OIDCConfig
108+
target.OIDCConfigError = data.OIDCConfigError
109+
target.JWKS = data.JWKS
110+
target.JWKSError = data.JWKSError
111+
return nil
112+
}
113+
95114
// extractClusterIDAndServerVersionFromReading converts the opaque data from a DiscoveryData
96115
// data reading to allow access to the Kubernetes version fields within.
97116
func extractClusterIDAndServerVersionFromReading(reading *api.DataReading, target *dataupload.Snapshot) error {
@@ -149,6 +168,7 @@ func extractResourceListFromReading(reading *api.DataReading, target *[]runtime.
149168
// and populates the relevant field(s) of the Snapshot based on the DataReading's data.
150169
// Deleted resources are excluded from the snapshot because they are not needed by CyberArk.
151170
var defaultExtractorFunctions = map[string]func(*api.DataReading, *dataupload.Snapshot) error{
171+
"ark/oidc": extractOIDCFromReading,
152172
"ark/discovery": extractClusterIDAndServerVersionFromReading,
153173
"ark/secrets": func(r *api.DataReading, s *dataupload.Snapshot) error {
154174
return extractResourceListFromReading(r, &s.Secrets)

0 commit comments

Comments
 (0)