Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit eacd61a

Browse files
committed
Remove k8s.io/kubernetes as a dependency
Signed-off-by: JoshVanL <[email protected]>
1 parent 3230b37 commit eacd61a

File tree

1,307 files changed

+49153
-169414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,307 files changed

+49153
-169414
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ generate: depend ## generates mocks and assets files
8383
test: generate verify ## run all go tests
8484
go test $$(go list ./pkg/... ./cmd/... | grep -v pkg/e2e)
8585

86-
e2e: e2e-1.14 ## run end to end tests
86+
e2e: e2e-1.15 ## run end to end tests
8787

8888
e2e-1.15: build ## run end to end tests for kubernetes version 1.15
8989
KUBE_OIDC_PROXY_NODE_IMAGE=1.15.0 go test ./pkg/e2e/. -v --count=1

cmd/options/options.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright Jetstack Ltd. See LICENSE for details.
2+
package options
3+
4+
import (
5+
"fmt"
6+
7+
"github.com/spf13/pflag"
8+
9+
cliflag "k8s.io/component-base/cli/flag"
10+
)
11+
12+
type OIDCAuthenticationOptions struct {
13+
APIAudiences []string
14+
CAFile string
15+
ClientID string
16+
IssuerURL string
17+
UsernameClaim string
18+
UsernamePrefix string
19+
GroupsClaim string
20+
GroupsPrefix string
21+
SigningAlgs []string
22+
RequiredClaims map[string]string
23+
}
24+
25+
func (o *OIDCAuthenticationOptions) Validate() error {
26+
if o != nil && (len(o.IssuerURL) > 0) != (len(o.ClientID) > 0) {
27+
return fmt.Errorf("oidc-issuer-url and oidc-client-id should be specified together")
28+
}
29+
30+
return nil
31+
}
32+
33+
func (o *OIDCAuthenticationOptions) AddFlags(fs *pflag.FlagSet) {
34+
fs.StringSliceVar(&o.APIAudiences, "api-audiences", o.APIAudiences, ""+
35+
"Identifiers of the API. The service account token authenticator will validate that "+
36+
"tokens used against the API are bound to at least one of these audiences. If the "+
37+
"--service-account-issuer flag is configured and this flag is not, this field "+
38+
"defaults to a single element list containing the issuer URL .")
39+
40+
fs.StringVar(&o.IssuerURL, "oidc-issuer-url", o.IssuerURL, ""+
41+
"The URL of the OpenID issuer, only HTTPS scheme will be accepted. "+
42+
"If set, it will be used to verify the OIDC JSON Web Token (JWT).")
43+
44+
fs.StringVar(&o.ClientID, "oidc-client-id", o.ClientID,
45+
"The client ID for the OpenID Connect client, must be set if oidc-issuer-url is set.")
46+
47+
fs.StringVar(&o.CAFile, "oidc-ca-file", o.CAFile, ""+
48+
"If set, the OpenID server's certificate will be verified by one of the authorities "+
49+
"in the oidc-ca-file, otherwise the host's root CA set will be used.")
50+
51+
fs.StringVar(&o.UsernameClaim, "oidc-username-claim", "sub", ""+
52+
"The OpenID claim to use as the user name. Note that claims other than the default ('sub') "+
53+
"is not guaranteed to be unique and immutable. This flag is experimental, please see "+
54+
"the authentication documentation for further details.")
55+
56+
fs.StringVar(&o.UsernamePrefix, "oidc-username-prefix", "", ""+
57+
"If provided, all usernames will be prefixed with this value. If not provided, "+
58+
"username claims other than 'email' are prefixed by the issuer URL to avoid "+
59+
"clashes. To skip any prefixing, provide the value '-'.")
60+
61+
fs.StringVar(&o.GroupsClaim, "oidc-groups-claim", "", ""+
62+
"If provided, the name of a custom OpenID Connect claim for specifying user groups. "+
63+
"The claim value is expected to be a string or array of strings. This flag is experimental, "+
64+
"please see the authentication documentation for further details.")
65+
66+
fs.StringVar(&o.GroupsPrefix, "oidc-groups-prefix", "", ""+
67+
"If provided, all groups will be prefixed with this value to prevent conflicts with "+
68+
"other authentication strategies.")
69+
70+
fs.StringSliceVar(&o.SigningAlgs, "oidc-signing-algs", []string{"RS256"}, ""+
71+
"Comma-separated list of allowed JOSE asymmetric signing algorithms. JWTs with a "+
72+
"'alg' header value not in this list will be rejected. "+
73+
"Values are defined by RFC 7518 https://tools.ietf.org/html/rfc7518#section-3.1.")
74+
75+
fs.Var(cliflag.NewMapStringStringNoSplit(&o.RequiredClaims), "oidc-required-claim", ""+
76+
"A key=value pair that describes a required claim in the ID Token. "+
77+
"If set, the claim is verified to be present in the ID Token with a matching value. "+
78+
"Repeat this flag to specify multiple claims.")
79+
}

cmd/run.go

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ package cmd
44
import (
55
"errors"
66
"fmt"
7+
"net"
78
"strconv"
89
"time"
910

1011
"github.com/spf13/cobra"
1112
"k8s.io/apiserver/pkg/authentication/request/bearertoken"
1213
"k8s.io/apiserver/pkg/server"
14+
apiserveroptions "k8s.io/apiserver/pkg/server/options"
1315
"k8s.io/apiserver/pkg/util/term"
1416
"k8s.io/apiserver/plugin/pkg/authenticator/token/oidc"
1517
"k8s.io/cli-runtime/pkg/genericclioptions"
1618
"k8s.io/client-go/rest"
1719
cliflag "k8s.io/component-base/cli/flag"
1820
"k8s.io/component-base/cli/globalflag"
19-
apiserveroptions "k8s.io/kubernetes/pkg/kubeapiserver/options"
2021

22+
"github.com/jetstack/kube-oidc-proxy/cmd/options"
2123
"github.com/jetstack/kube-oidc-proxy/pkg/probe"
2224
"github.com/jetstack/kube-oidc-proxy/pkg/proxy"
2325
"github.com/jetstack/kube-oidc-proxy/pkg/version"
@@ -29,25 +31,38 @@ const (
2931

3032
func NewRunCommand(stopCh <-chan struct{}) *cobra.Command {
3133
// flag option structs
32-
oidcOptions := &apiserveroptions.BuiltInAuthenticationOptions{
33-
OIDC: &apiserveroptions.OIDCAuthenticationOptions{},
34+
oidcOptions := new(options.OIDCAuthenticationOptions)
35+
36+
ssoptions := &apiserveroptions.SecureServingOptions{
37+
BindAddress: net.ParseIP("0.0.0.0"),
38+
BindPort: 6443,
39+
Required: true,
40+
ServerCert: apiserveroptions.GeneratableKeyCert{
41+
PairName: "kube-oidc-proxy",
42+
CertDirectory: "/var/run/kubernetes",
43+
},
3444
}
35-
secureServingOptions := apiserveroptions.NewSecureServingOptions()
36-
secureServingOptions.ServerCert.PairName = "kube-oidc-proxy"
45+
ssoptionsWithLB := ssoptions.WithLoopback()
46+
//secureServingOptions = secureServingOptions.WithLoopback()
47+
3748
clientConfigFlags := genericclioptions.NewConfigFlags(true)
3849

3950
healthCheck := probe.New(strconv.Itoa(readinessProbePort))
4051

4152
// proxy command
4253
cmd := &cobra.Command{
43-
Use: "k8s-oidc-proxy",
44-
Long: "k8s-oidc-proxy is a reverse proxy to authenticate users to Kubernetes API servers with Open ID Connect Authentication.",
54+
Use: "kube-oidc-proxy",
55+
Long: "kube-oidc-proxy is a reverse proxy to authenticate users to Kubernetes API servers with Open ID Connect Authentication.",
4556
RunE: func(cmd *cobra.Command, args []string) error {
4657
if cmd.Flag("version").Value.String() == "true" {
4758
version.PrintVersionAndExit()
4859
}
4960

50-
if secureServingOptions.SecureServingOptions.BindPort == readinessProbePort {
61+
if err := oidcOptions.Validate(); err != nil {
62+
return err
63+
}
64+
65+
if ssoptionsWithLB.SecureServingOptions.BindPort == readinessProbePort {
5166
return errors.New("unable to securely serve on port 8080, used by readiness prob")
5267
}
5368

@@ -65,15 +80,15 @@ func NewRunCommand(stopCh <-chan struct{}) *cobra.Command {
6580
// oidc config
6681
oidcAuther, err := oidc.New(oidc.Options{
6782
APIAudiences: oidcOptions.APIAudiences,
68-
CAFile: oidcOptions.OIDC.CAFile,
69-
ClientID: oidcOptions.OIDC.ClientID,
70-
GroupsClaim: oidcOptions.OIDC.GroupsClaim,
71-
GroupsPrefix: oidcOptions.OIDC.GroupsPrefix,
72-
IssuerURL: oidcOptions.OIDC.IssuerURL,
73-
RequiredClaims: oidcOptions.OIDC.RequiredClaims,
74-
SupportedSigningAlgs: oidcOptions.OIDC.SigningAlgs,
75-
UsernameClaim: oidcOptions.OIDC.UsernameClaim,
76-
UsernamePrefix: oidcOptions.OIDC.UsernamePrefix,
83+
CAFile: oidcOptions.CAFile,
84+
ClientID: oidcOptions.ClientID,
85+
GroupsClaim: oidcOptions.GroupsClaim,
86+
GroupsPrefix: oidcOptions.GroupsPrefix,
87+
IssuerURL: oidcOptions.IssuerURL,
88+
RequiredClaims: oidcOptions.RequiredClaims,
89+
SupportedSigningAlgs: oidcOptions.SigningAlgs,
90+
UsernameClaim: oidcOptions.UsernameClaim,
91+
UsernamePrefix: oidcOptions.UsernamePrefix,
7792
})
7893
if err != nil {
7994
return err
@@ -82,7 +97,7 @@ func NewRunCommand(stopCh <-chan struct{}) *cobra.Command {
8297
// oidc auther from config
8398
reqAuther := bearertoken.New(oidcAuther)
8499
secureServingInfo := new(server.SecureServingInfo)
85-
if err := secureServingOptions.ApplyTo(&secureServingInfo, nil); err != nil {
100+
if err := ssoptionsWithLB.ApplyTo(&secureServingInfo, nil); err != nil {
86101
return err
87102
}
88103

@@ -110,7 +125,7 @@ func NewRunCommand(stopCh <-chan struct{}) *cobra.Command {
110125
oidcfs := namedFlagSets.FlagSet("OIDC")
111126
oidcOptions.AddFlags(oidcfs)
112127

113-
secureServingOptions.AddFlags(namedFlagSets.FlagSet("secure serving"))
128+
ssoptionsWithLB.AddFlags(namedFlagSets.FlagSet("secure serving"))
114129

115130
clientConfigFlags.CacheDir = nil
116131
clientConfigFlags.Impersonate = nil

go.mod

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,27 @@ require (
66
github.com/Masterminds/semver v1.4.2
77
github.com/golang/mock v0.0.0-20160127222235-bd3c8e81be01
88
github.com/heptiolabs/healthcheck v0.0.0-20180807145615-6ff867650f40
9-
github.com/sirupsen/logrus v1.4.1
9+
github.com/sirupsen/logrus v1.4.2
1010
github.com/spf13/cobra v0.0.5
11+
github.com/spf13/pflag v1.0.3
1112
gopkg.in/square/go-jose.v2 v2.3.1
1213
k8s.io/api v0.0.0
1314
k8s.io/apimachinery v0.0.0
14-
k8s.io/apiserver v0.0.0
15+
k8s.io/apiserver v0.0.0-20190721103406-1e59c150c171
1516
k8s.io/cli-runtime v0.0.0
1617
k8s.io/client-go v11.0.0+incompatible
1718
k8s.io/component-base v0.0.0
1819
k8s.io/klog v0.3.3
19-
k8s.io/kubernetes v0.0.0-00010101000000-000000000000
2020
sigs.k8s.io/kind v0.0.0-00010101000000-000000000000
2121
)
2222

2323
replace (
24+
github.com/golang/mock => github.com/golang/mock v1.3.1
2425
k8s.io/api => k8s.io/api v0.0.0-20190620084959-7cf5895f2711
2526
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190620085554-14e95df34f1f
2627
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
27-
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190620085212-47dc9a115b18
2828
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190620085706-2090e6d8f84c
2929
k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
30-
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190219215739-d1e3091efae0
31-
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20190620090013-c9a0fc045dc1
32-
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190311093542-50b561225d70
3330
k8s.io/component-base => k8s.io/component-base v0.0.0-20190620085130-185d68e6e6ea
34-
k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190531030430-6117653b35f1
35-
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20190620090116-299a7b270edc
36-
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20190620085325-f29e2b4a4f84
37-
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20190620085942-b7f18460b210
38-
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a3
39-
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20190620085809-589f994ddf7f
40-
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20190620085912-4acac5405ec6
41-
k8s.io/kubectl => k8s.io/kubectl v0.0.0-20190602132728-7075c07e78bf
42-
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20190620085838-f1cb295a73c9
43-
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20190620090156-2138f2c9de18
44-
k8s.io/metrics => k8s.io/metrics v0.0.0-20190620085625-3b22d835f165
45-
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20190620085408-1aef9010884e
46-
sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2
47-
)
48-
49-
replace (
50-
github.com/golang/mock => github.com/golang/mock v1.3.1
51-
k8s.io/kubernetes => k8s.io/kubernetes v1.15.0
5231
sigs.k8s.io/kind => sigs.k8s.io/kind v0.4.0
5332
)

0 commit comments

Comments
 (0)