Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: relax https for jwks #2328

Merged
merged 6 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ securityPolicies:
- header: one-route-example-key
claim: claim1
- name: example2
issuer: https://two.example.com
issuer: http://two.example.com
arkodg marked this conversation as resolved.
Show resolved Hide resolved
audiences:
- two.foo.com
remoteJWKS:
uri: https://two.example.com/jwt/public-key/jwks.json
uri: http://two.example.com/jwt/public-key/jwks.json
claimToHeaders:
- header: two-route-example-key
claim: claim2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ securityPolicies:
claimToHeaders:
- claim: claim2
header: two-route-example-key
issuer: https://two.example.com
issuer: http://two.example.com
name: example2
remoteJWKS:
uri: https://two.example.com/jwt/public-key/jwks.json
uri: http://two.example.com/jwt/public-key/jwks.json
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
Expand Down Expand Up @@ -293,10 +293,10 @@ xdsIR:
claimToHeaders:
- claim: claim2
header: two-route-example-key
issuer: https://two.example.com
issuer: http://two.example.com
name: example2
remoteJWKS:
uri: https://two.example.com/jwt/public-key/jwks.json
uri: http://two.example.com/jwt/public-key/jwks.json
name: grpcroute/default/grpcroute-1/rule/0/match/-1/*
envoy-gateway/gateway-2:
accessLog:
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/translator/jwt.go
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
for i := range route.JWT.Providers {
irProvider := route.JWT.Providers[i]
// Create the cluster for the remote jwks, if it doesn't exist.
jwksCluster, err := url2Cluster(irProvider.RemoteJWKS.URI)
jwksCluster, err := url2Cluster(irProvider.RemoteJWKS.URI, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func (*jwt) patchResources(tCtx *types.ResourceVersionTable, routes []*ir.HTTPRo
)

provider := route.JWT.Providers[i]
jwks, err = url2Cluster(provider.RemoteJWKS.URI)
jwks, err = url2Cluster(provider.RemoteJWKS.URI, false)
if err != nil {
errs = multierror.Append(errs, err)
continue
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/translator/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func oauth2FilterName(route *ir.HTTPRoute) string {
}

func oauth2Config(route *ir.HTTPRoute) (*oauth2v3.OAuth2, error) {
cluster, err := url2Cluster(route.OIDC.Provider.TokenEndpoint)
cluster, err := url2Cluster(route.OIDC.Provider.TokenEndpoint, true)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -218,7 +218,7 @@ func createOAuth2TokenEndpointClusters(tCtx *types.ResourceVersionTable,
err error
)

cluster, err = url2Cluster(route.OIDC.Provider.TokenEndpoint)
cluster, err = url2Cluster(route.OIDC.Provider.TokenEndpoint, true)
if err != nil {
errs = multierror.Append(errs, err)
continue
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/translator/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type urlCluster struct {
}

// url2Cluster returns a urlCluster from the provided url.
func url2Cluster(strURL string) (*urlCluster, error) {
func url2Cluster(strURL string, secure bool) (*urlCluster, error) {
epType := EndpointTypeDNS

// The URL should have already been validated in the gateway API translator.
Expand All @@ -41,7 +41,7 @@ func url2Cluster(strURL string) (*urlCluster, error) {
return nil, err
}

if u.Scheme != "https" {
if secure && u.Scheme != "https" {
return nil, fmt.Errorf("unsupported URI scheme %s", u.Scheme)
}

Expand Down