Skip to content

Commit d91bb38

Browse files
authored
oauth2 token exchange credentials (#213)
1 parent e4e82e6 commit d91bb38

File tree

10 files changed

+251
-44
lines changed

10 files changed

+251
-44
lines changed

api/v1alpha1/connection_types.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
)
66

77
type ConnectionOptions struct {
8-
AccessToken *AccessTokenAuth `json:"accessToken,omitempty"`
9-
StaticCredentials *StaticCredentialsAuth `json:"staticCredentials,omitempty"`
8+
AccessToken *AccessTokenAuth `json:"accessToken,omitempty"`
9+
StaticCredentials *StaticCredentialsAuth `json:"staticCredentials,omitempty"`
10+
Oauth2TokenExhange *Oauth2TokenExchange `json:"oauth2TokenExchange,omitempty"`
1011
}
1112

1213
type AccessTokenAuth struct {
@@ -18,6 +19,24 @@ type StaticCredentialsAuth struct {
1819
Password *CredentialSource `json:"password,omitempty"`
1920
}
2021

22+
type Oauth2TokenExchange struct {
23+
Endpoint string `json:"endpoint"`
24+
PrivateKey *CredentialSource `json:"privateKey"`
25+
JWTHeader *JWTHeader `json:",inline"`
26+
JWTClaims *JWTClaims `json:",inline"`
27+
}
28+
29+
type JWTHeader struct {
30+
KeyID string `json:"keyID,omitempty"`
31+
SignAlg string `json:"signAlg,omitempty"`
32+
}
33+
type JWTClaims struct {
34+
Issuer string `json:"issuer,omitempty"`
35+
Subject string `json:"subject,omitempty"`
36+
Audience string `json:"audience,omitempty"`
37+
ID string `json:"id,omitempty"`
38+
}
39+
2140
type CredentialSource struct {
2241
SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef"`
2342
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/ydb-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.5.14
18+
version: 0.5.15
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.5.14"
24+
appVersion: "0.5.15"

deploy/ydb-operator/crds/storage.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,6 +4858,50 @@ spec:
48584858
required:
48594859
- secretKeyRef
48604860
type: object
4861+
oauth2TokenExchange:
4862+
properties:
4863+
audience:
4864+
type: string
4865+
endpoint:
4866+
type: string
4867+
id:
4868+
type: string
4869+
issuer:
4870+
type: string
4871+
keyID:
4872+
type: string
4873+
privateKey:
4874+
properties:
4875+
secretKeyRef:
4876+
description: SecretKeySelector selects a key of a Secret.
4877+
properties:
4878+
key:
4879+
description: The key of the secret to select from. Must
4880+
be a valid secret key.
4881+
type: string
4882+
name:
4883+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
4884+
TODO: Add other useful fields. apiVersion, kind,
4885+
uid?'
4886+
type: string
4887+
optional:
4888+
description: Specify whether the Secret or its key
4889+
must be defined
4890+
type: boolean
4891+
required:
4892+
- key
4893+
type: object
4894+
required:
4895+
- secretKeyRef
4896+
type: object
4897+
signAlg:
4898+
type: string
4899+
subject:
4900+
type: string
4901+
required:
4902+
- endpoint
4903+
- privateKey
4904+
type: object
48614905
staticCredentials:
48624906
properties:
48634907
password:

go.mod

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ go 1.20
55
require (
66
github.com/banzaicloud/k8s-objectmatcher v1.7.0
77
github.com/go-logr/logr v1.2.4
8+
github.com/golang-jwt/jwt/v4 v4.4.1
89
github.com/google/go-cmp v0.5.9
910
github.com/onsi/ginkgo/v2 v2.9.4
1011
github.com/onsi/gomega v1.27.6
1112
github.com/pkg/errors v0.9.1
1213
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.50.0
13-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20230801151335-81e01be38941
14-
github.com/ydb-platform/ydb-go-sdk/v3 v3.53.0
15-
google.golang.org/grpc v1.53.0
16-
google.golang.org/protobuf v1.28.1
14+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240528144234-5d5a685e41f7
15+
github.com/ydb-platform/ydb-go-sdk/v3 v3.74.2
16+
google.golang.org/grpc v1.57.1
17+
google.golang.org/protobuf v1.33.0
1718
gopkg.in/yaml.v3 v3.0.1
1819
k8s.io/api v0.26.1
1920
k8s.io/apimachinery v0.26.1
@@ -38,7 +39,6 @@ require (
3839
github.com/go-openapi/swag v0.22.3 // indirect
3940
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
4041
github.com/gogo/protobuf v1.3.2 // indirect
41-
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
4242
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4343
github.com/golang/protobuf v1.5.3 // indirect
4444
github.com/google/gnostic v0.6.9 // indirect
@@ -63,17 +63,17 @@ require (
6363
go.uber.org/atomic v1.7.0 // indirect
6464
go.uber.org/multierr v1.6.0 // indirect
6565
go.uber.org/zap v1.24.0 // indirect
66-
golang.org/x/net v0.10.0 // indirect
67-
golang.org/x/oauth2 v0.4.0 // indirect
68-
golang.org/x/sync v0.2.0 // indirect
69-
golang.org/x/sys v0.8.0 // indirect
70-
golang.org/x/term v0.8.0 // indirect
71-
golang.org/x/text v0.9.0 // indirect
66+
golang.org/x/net v0.23.0 // indirect
67+
golang.org/x/oauth2 v0.7.0 // indirect
68+
golang.org/x/sync v0.3.0 // indirect
69+
golang.org/x/sys v0.18.0 // indirect
70+
golang.org/x/term v0.18.0 // indirect
71+
golang.org/x/text v0.14.0 // indirect
7272
golang.org/x/time v0.3.0 // indirect
7373
golang.org/x/tools v0.9.1 // indirect
7474
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
7575
google.golang.org/appengine v1.6.7 // indirect
76-
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
76+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
7777
gopkg.in/inf.v0 v0.9.1 // indirect
7878
gopkg.in/yaml.v2 v2.4.0 // indirect
7979
k8s.io/apiextensions-apiserver v0.26.1 // indirect

0 commit comments

Comments
 (0)