Skip to content

Commit

Permalink
Merge branch 'main' into fix-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
LiZhenCheng9527 authored Mar 28, 2024
2 parents 850608c + 3d51933 commit 0c07bfc
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ If you would like to be included in this table, please submit a PR to this file
* Status: production
* (Option) https://tetrate.io/wp-content/uploads/2023/03/tetrate-logo-dark.svg
* (Option) Description:

## Airspace Link
* Organizatioin: Airspace Link
* Website: https://airspacelink.com/
* Category: End User
* Environments: Azure
* Use Cases:
- Airspace Link is using Envoy Gateway to route all public APIs to Kubernetes clusters, developers are manipulating routes descriptions using agnostic manifest files, which are then automatically provisioned using Envoy Gateway.
* Status: production
* Logo: https://airhub.airspacelink.com/images/asl-flat-logo.png
5 changes: 5 additions & 0 deletions api/v1alpha1/oidc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type OIDC struct {
// +optional
Scopes []string `json:"scopes,omitempty"`

// The OIDC resources to be used in the
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
// +optional
Resources []string `json:"resources,omitempty"`

// The redirect URL to be used in the OIDC
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
// If not specified, uses the default redirect URI "%REQ(x-forwarded-proto)%://%REQ(:authority)%/oauth2/callback"
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ spec:
Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
If not specified, uses the default redirect URI "%REQ(x-forwarded-proto)%://%REQ(:authority)%/oauth2/callback"
type: string
resources:
description: The OIDC resources to be used in the [Authentication
Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
items:
type: string
type: array
scopes:
description: The OIDC scopes to be used in the [Authentication
Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
Expand Down
1 change: 1 addition & 0 deletions internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ func (t *Translator) buildOIDC(
ClientID: oidc.ClientID,
ClientSecret: clientSecretBytes,
Scopes: scopes,
Resources: oidc.Resources,
RedirectURL: redirectURL,
RedirectPath: redirectPath,
LogoutPath: logoutPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@ securityPolicies:
clientSecret:
name: "client2-secret"
scopes: ["openid", "email", "profile"]
resources: ["api"]
redirectURL: "https://www.example.com/foo/oauth2/callback"
logoutPath: "/foo/logout"
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ securityPolicies:
issuer: https://oauth.foo.com
tokenEndpoint: https://oauth.foo.com/token
redirectURL: https://www.example.com/foo/oauth2/callback
resources:
- api
scopes:
- openid
- email
Expand Down Expand Up @@ -263,6 +265,8 @@ xdsIR:
tokenEndpoint: https://oauth.foo.com/token
redirectPath: /foo/oauth2/callback
redirectURL: https://www.example.com/foo/oauth2/callback
resources:
- api
scopes:
- openid
- email
Expand Down
4 changes: 4 additions & 0 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ type OIDC struct {
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`

// The OIDC resources to be used in the
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
Resources []string `json:"resources,omitempty" yaml:"resources,omitempty"`

// The redirect URL to be used in the OIDC
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
RedirectURL string `json:"redirectURL,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions internal/ir/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/xds/translator/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func oauth2Config(oidc *ir.OIDC) (*oauth2v3.OAuth2, error) {
// every OIDC provider supports basic auth
AuthType: oauth2v3.OAuth2Config_BASIC_AUTH,
AuthScopes: oidc.Scopes,
Resources: oidc.Resources,
},
}
return oauth2, nil
Expand Down
10 changes: 10 additions & 0 deletions internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func buildXdsRoute(httpRoute *ir.HTTPRoute) (*routev3.Route, error) {
routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors)
}

if !httpRoute.IsHTTP2 {
// Allow websocket upgrades for HTTP 1.1
// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism
routeAction.UpgradeConfigs = []*routev3.RouteAction_UpgradeConfig{
{
UpgradeType: "websocket",
},
}
}

router.Action = &routev3.Route_Route{Route: routeAction}
default:
var routeAction *routev3.RouteAction
Expand Down
4 changes: 4 additions & 0 deletions internal/xds/translator/testdata/in/xds-ir/oidc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ http:
- openid
- email
- profile
resources:
- api
redirectURL: "https://www.example.com/foo/oauth2/callback"
redirectPath: "/foo/oauth2/callback"
logoutPath: "/foo/logout"
Expand All @@ -56,6 +58,8 @@ http:
- openid
- email
- profile
resources:
- api
redirectURL: "https://www.example.com/bar/oauth2/callback"
redirectPath: "/bar/oauth2/callback"
logoutPath: "/bar/logout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
pattern:
regex: ^/origin/\/*
substitution: /
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
pattern:
regex: /.+
substitution: /rewrite
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
cluster: rewrite-route-dest
hostRewriteLiteral: 3.3.3.3
prefixRewrite: /rewrite
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
route:
cluster: rewrite-route-dest
prefixRewrite: /rewrite
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
path:
exact: /foo/oauth2/callback
redirectUri: https://www.example.com/foo/oauth2/callback
resources:
- api
signoutPath:
path:
exact: /foo/logout
Expand Down Expand Up @@ -89,6 +91,8 @@
path:
exact: /bar/oauth2/callback
redirectUri: https://www.example.com/bar/oauth2/callback
resources:
- api
signoutPath:
path:
exact: /bar/logout
Expand Down
1 change: 1 addition & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,7 @@ _Appears in:_
| `clientID` | _string_ | true | The client ID to be used in the OIDC [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest). |
| `clientSecret` | _[SecretObjectReference](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.SecretObjectReference)_ | true | The Kubernetes secret which contains the OIDC client secret to be used in the [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest). <br /><br /> This is an Opaque secret. The client secret should be stored in the key "client-secret". |
| `scopes` | _string array_ | false | The OIDC scopes to be used in the [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest). The "openid" scope is always added to the list of scopes if not already specified. |
| `resources` | _string array_ | false | The OIDC resources to be used in the [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest). |
| `redirectURL` | _string_ | true | The redirect URL to be used in the OIDC [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest). If not specified, uses the default redirect URI "%REQ(x-forwarded-proto)%://%REQ(:authority)%/oauth2/callback" |
| `logoutPath` | _string_ | true | The path to log a user out, clearing their credential cookies. If not specified, uses a default logout path "/logout" |

Expand Down

0 comments on commit 0c07bfc

Please sign in to comment.