git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #2213 from kvanzuijlen/release-v7.5.0

Release v7.5.0

commit01386bf30348f75590df61a3408187696fef6d4b authorJoel Speed <Joel.speed@hotmail.co.uk> dateMon 4 Sep 2023, 11:35 (3 years ago) parenta6e8ec8bfc04fa
17 files changed+2317−16
CHANGELOG.md+31−12 README.md+1−1 contrib/local-environment/docker-compose-keycloak.yaml+1−1 contrib/local-environment/docker-compose.yaml+1−1 docs/docs/installation.md+1−1 docs/versioned_docs/version-7.5.x/behaviour.md+11 docs/versioned_docs/version-7.5.x/community/security.md+49 docs/versioned_docs/version-7.5.x/configuration/alpha_config.md+530 docs/versioned_docs/version-7.5.x/configuration/alpha_config.md.tmpl+125 docs/versioned_docs/version-7.5.x/configuration/auth.md+691 docs/versioned_docs/version-7.5.x/configuration/overview.md+605 docs/versioned_docs/version-7.5.x/configuration/sessions.md+71 docs/versioned_docs/version-7.5.x/configuration/tls.md+86 docs/versioned_docs/version-7.5.x/features/endpoints.md+47 docs/versioned_docs/version-7.5.x/installation.md+26 docs/versioned_sidebars/version-7.5.x-sidebars.json+40 docs/versions.json+1
CHANGELOG.md+31−12
@@ -6,25 +6,44 @@
66
77## Breaking Changes
88
9+## Changes since v7.5.0
10+
11+# V7.5.0
12+
13+## Release Highlights
14+- 🐛 Several bugs have been squashed
15+- 🕵️‍♀️ Vulnerabilities have been addressed
16+- ⭐️ Added a readiness endpoint to check if the application is ready to receive traffic
17+- ⭐️ Google Application Default Credentials support (i.e. for running on Google Cloud Platform)
18+- ⭐ Session cookie support
19+
20+## Important Notes
21+
22+- This release includes fixes for a number of CVEs, we recommend to upgrade as soon as possible.
23+
24+## Breaking Changes
25+
26+N/A
27+
928## Changes since v7.4.0
10−- [#2133](https://github.com/oauth2-proxy/oauth2-proxy/pull/2133) Use X-Forwarded-Uri if it exists for pathRegex match
11−- [#2028](https://github.com/oauth2-proxy/oauth2-proxy/pull/2028) Update golang.org/x/net to v0.7.0 ato address GHSA-vvpx-j8f3-3w6h
29+- [#2028](https://github.com/oauth2-proxy/oauth2-proxy/pull/2028) Update golang.org/x/net to v0.7.0 ato address GHSA-vvpx-j8f3-3w6h (@amrmahdi)
30+- [#2133](https://github.com/oauth2-proxy/oauth2-proxy/pull/2133) Use X-Forwarded-Uri if it exists for pathRegex match (@mzndr)
1231- [#1873](https://github.com/oauth2-proxy/oauth2-proxy/pull/1873) Fix empty users with some OIDC providers (@babs)
13−- [#1882](https://github.com/oauth2-proxy/oauth2-proxy/pull/1882) Make `htpasswd.GetUsers` racecondition safe
14−- [#1883](https://github.com/oauth2-proxy/oauth2-proxy/pull/1883) Ensure v8 manifest variant is set on docker images
15−- [#1906](https://github.com/oauth2-proxy/oauth2-proxy/pull/1906) Fix PKCE code verifier generation to never use UTF-8 characters
32+- [#1882](https://github.com/oauth2-proxy/oauth2-proxy/pull/1882) Make `htpasswd.GetUsers` racecondition safe (@babs)
33+- [#1883](https://github.com/oauth2-proxy/oauth2-proxy/pull/1883) Ensure v8 manifest variant is set on docker images (@braunsonm)
34+- [#1906](https://github.com/oauth2-proxy/oauth2-proxy/pull/1906) Fix PKCE code verifier generation to never use UTF-8 characters (@braunsonm)
1635- [#1839](https://github.com/oauth2-proxy/oauth2-proxy/pull/1839) Add readiness checks for deeper health checks (@kobim)
17−- [#1927](https://github.com/oauth2-proxy/oauth2-proxy/pull/1927) Fix default scope settings for none oidc providers
36+- [#1927](https://github.com/oauth2-proxy/oauth2-proxy/pull/1927) Fix default scope settings for none oidc providers (@tuunit)
1837- [#1713](https://github.com/oauth2-proxy/oauth2-proxy/pull/1713) Add session cookie support (@t-katsumura @tanuki884)
1938- [#1951](https://github.com/oauth2-proxy/oauth2-proxy/pull/1951) Fix validate URL, check if query string marker (?) or separator (&) needs to be appended (@miguelborges99)
20−- [#1920](https://github.com/oauth2-proxy/oauth2-proxy/pull/1920) Make sure emailClaim is not overriden if userIDClaim is not set
21−- [#2010](https://github.com/oauth2-proxy/oauth2-proxy/pull/2010) Log the difference between invalid email and not authorized session
22−- [#1988](https://github.com/oauth2-proxy/oauth2-proxy/pull/1988) Ensure sign-in page background is uniform throughout the page
39+- [#1920](https://github.com/oauth2-proxy/oauth2-proxy/pull/1920) Make sure emailClaim is not overriden if userIDClaim is not set (@mdreem)
40+- [#2010](https://github.com/oauth2-proxy/oauth2-proxy/pull/2010) Log the difference between invalid email and not authorized session (@omBratteng)
41+- [#1988](https://github.com/oauth2-proxy/oauth2-proxy/pull/1988) Ensure sign-in page background is uniform throughout the page (@corybolar)
2342- [#2013](https://github.com/oauth2-proxy/oauth2-proxy/pull/2013) Upgrade alpine to version 3.17.2 and library dependencies (@miguelborges99)
2443- [#2047](https://github.com/oauth2-proxy/oauth2-proxy/pull/2047) CVE-2022-41717: DoS in Go net/http may lead to DoS (@miguelborges99)
2544- [#2126](https://github.com/oauth2-proxy/oauth2-proxy/pull/2126) Added support for GKE Workload Identity (@kvanzuijlen)
26−- [#1921](https://github.com/oauth2-proxy/oauth2-proxy/pull/1921) Check jsonpath syntax before interpretation
27−- [#2025](https://github.com/oauth2-proxy/oauth2-proxy/pull/2025) Embed static stylesheets and dependencies
45+- [#1921](https://github.com/oauth2-proxy/oauth2-proxy/pull/1921) Check jsonpath syntax before interpretation (@eloo-abi)
46+- [#2025](https://github.com/oauth2-proxy/oauth2-proxy/pull/2025) Embed static stylesheets and dependencies (@corybolar)
2847
2948# V7.4.0
3049
@@ -44,7 +63,7 @@
4463 - group membership check is now validated while using the the azure provider.
4564 - Azure OAuth v2.0 (https://login.microsoftonline.com/{tenant_id}/v2.0) is now available along with Azure OAuth v1.0. See https://github.com/oauth2-proxy/oauth2-proxy/blob/master/docs/docs/configuration/auth.md#azure-auth-provider for more details
4665 - When using v2.0 Azure Auth endpoint (`https://login.microsoftonline.com/{tenant-id}/v2.0`) as `--oidc_issuer_url`, in conjunction with `--resource` flag, be sure to append `/.default` at the end of the resource name. See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#the-default-scope for more details.
47−- This release includes fixes for a number of CVEs, we recomend to upgrade as soon as possible.
66+- This release includes fixes for a number of CVEs, we recommend to upgrade as soon as possible.
4867
4968## Breaking Changes
5069
README.md+1−1
@@ -23,7 +23,7 @@ Going forward, all images shall be available at `quay.io/oauth2-proxy/oauth2-pro
2323
24241. Choose how to deploy:
2525
26− a. Download [Prebuilt Binary](https://github.com/oauth2-proxy/oauth2-proxy/releases) (current release is `v7.4.0`)
26+ a. Download [Prebuilt Binary](https://github.com/oauth2-proxy/oauth2-proxy/releases) (current release is `v7.5.0`)
2727
2828 b. Build with `$ go install github.com/oauth2-proxy/oauth2-proxy/v7@latest` which will put the binary in `$GOROOT/bin`
2929
contrib/local-environment/docker-compose-keycloak.yaml+1−1
@@ -15,7 +15,7 @@ services:
1515
1616 oauth2-proxy:
1717 container_name: oauth2-proxy
18− image: quay.io/oauth2-proxy/oauth2-proxy:v7.4.0
18+ image: quay.io/oauth2-proxy/oauth2-proxy:v7.5.0
1919 command: --config /oauth2-proxy.cfg
2020 hostname: oauth2-proxy
2121 volumes:
contrib/local-environment/docker-compose.yaml+1−1
@@ -13,7 +13,7 @@ version: '3.0'
1313services:
1414 oauth2-proxy:
1515 container_name: oauth2-proxy
16− image: quay.io/oauth2-proxy/oauth2-proxy:v7.4.0
16+ image: quay.io/oauth2-proxy/oauth2-proxy:v7.5.0
1717 command: --config /oauth2-proxy.cfg
1818 ports:
1919 - 4180:4180/tcp
docs/docs/installation.md+1−1
@@ -6,7 +6,7 @@ slug: /
66
771. Choose how to deploy:
88
9− a. Download [Prebuilt Binary](https://github.com/oauth2-proxy/oauth2-proxy/releases) (current release is `v7.4.0`)
9+ a. Download [Prebuilt Binary](https://github.com/oauth2-proxy/oauth2-proxy/releases) (current release is `v7.5.0`)
1010
1111 b. Build with `$ go install github.com/oauth2-proxy/oauth2-proxy/v7@latest` which will put the binary in `$GOPATH/bin`
1212
docs/versioned_docs/version-7.5.x/behaviour.mdnew file+11
@@ -0,0 +1,11 @@
1+---
2+id: behaviour
3+title: Behaviour
4+---
5+
6+1. Any request passing through the proxy (and not matched by `--skip-auth-regex`) is checked for the proxy's session cookie (`--cookie-name`) (or, if allowed, a JWT token - see `--skip-jwt-bearer-tokens`).
7+2. If authentication is required but missing then the user is asked to log in and redirected to the authentication provider (unless it is an Ajax request, i.e. one with `Accept: application/json`, in which case 401 Unauthorized is returned)
8+3. After returning from the authentication provider, the oauth tokens are stored in the configured session store (cookie, redis, ...) and a cookie is set
9+4. The request is forwarded to the upstream server with added user info and authentication headers (depending on the configuration)
10+
11+Notice that the proxy also provides a number of useful [endpoints](features/endpoints.md).
docs/versioned_docs/version-7.5.x/community/security.mdnew file+49
@@ -0,0 +1,49 @@
1+---
2+id: security
3+title: Security
4+---
5+
6+:::note
7+OAuth2 Proxy is a community project.
8+Maintainers do not work on this project full time, and as such,
9+while we endeavour to respond to disclosures as quickly as possible,
10+this may take longer than in projects with corporate sponsorship.
11+:::
12+
13+## Security Disclosures
14+
15+:::important
16+If you believe you have found a vulnerability within OAuth2 Proxy or any of its
17+dependencies, please do NOT open an issue or PR on GitHub, please do NOT post
18+any details publicly.
19+:::
20+
21+Security disclosures MUST be done in private.
22+If you have found an issue that you would like to bring to the attention of the
23+maintenance team for OAuth2 Proxy, please compose an email and send it to the
24+list of maintainers in our [MAINTAINERS](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/MAINTAINERS) file.
25+
26+Please include as much detail as possible.
27+Ideally, your disclosure should include:
28+- A reproducible case that can be used to demonstrate the exploit
29+- How you discovered this vulnerability
30+- A potential fix for the issue (if you have thought of one)
31+- Versions affected (if not present in master)
32+- Your GitHub ID
33+
34+### How will we respond to disclosures?
35+
36+We use [GitHub Security Advisories](https://docs.github.com/en/github/managing-security-vulnerabilities/about-github-security-advisories)
37+to privately discuss fixes for disclosed vulnerabilities.
38+If you include a GitHub ID with your disclosure we will add you as a collaborator
39+for the advisory so that you can join the discussion and validate any fixes
40+we may propose.
41+
42+For minor issues and previously disclosed vulnerabilities (typically for
43+dependencies), we may use regular PRs for fixes and forego the security advisory.
44+
45+Once a fix has been agreed upon, we will merge the fix and create a new release.
46+If we have multiple security issues in flight simultaneously, we may delay
47+merging fixes until all patches are ready.
48+We may also backport the fix to previous releases,
49+but this will be at the discretion of the maintainers.
docs/versioned_docs/version-7.5.x/configuration/alpha_config.mdnew file+530
@@ -0,0 +1,530 @@
1+---
2+id: alpha-config
3+title: Alpha Configuration
4+---
5+
6+:::warning
7+This page contains documentation for alpha features.
8+We reserve the right to make breaking changes to the features detailed within this page with no notice.
9+
10+Options described in this page may be changed, removed, renamed or moved without prior warning.
11+Please beware of this before you use alpha configuration options.
12+:::
13+
14+This page details a set of **alpha** configuration options in a new format.
15+Going forward we are intending to add structured configuration in YAML format to
16+replace the existing TOML based configuration file and flags.
17+
18+Below is a reference for the structure of the configuration, with
19+[AlphaOptions](#alphaoptions) as the root of the configuration.
20+
21+When using alpha configuration, your config file will look something like below:
22+
23+```yaml
24+upstreams:
25+ - id: ...
26+ ...
27+injectRequestHeaders:
28+ - name: ...
29+ ...
30+injectResponseHeaders:
31+ - name: ...
32+ ...
33+```
34+
35+Please browse the [reference](#configuration-reference) below for the structure
36+of the new configuration format.
37+
38+## Using Alpha Configuration
39+
40+To use the new **alpha** configuration, generate a YAML file based on the format
41+described in the [reference](#configuration-reference) below.
42+
43+Provide the path to this file using the `--alpha-config` flag.
44+
45+:::note
46+When using the `--alpha-config` flag, some options are no longer available.
47+See [removed options](#removed-options) below for more information.
48+:::
49+
50+### Converting configuration to the new structure
51+
52+Before adding the new `--alpha-config` option, start OAuth2 Proxy using the
53+`convert-config-to-alpha` flag to convert existing configuration to the new format.
54+
55+```bash
56+oauth2-proxy --convert-config-to-alpha --config ./path/to/existing/config.cfg
57+```
58+
59+This will convert any options supported by the new format to YAML and print the
60+new configuration to `STDOUT`.
61+
62+Copy this to a new file, remove any options from your existing configuration
63+noted in [removed options](#removed-options) and then start OAuth2 Proxy using
64+the new config.
65+
66+```bash
67+oauth2-proxy --alpha-config ./path/to/new/config.yaml --config ./path/to/existing/config.cfg
68+```
69+
70+## Removed options
71+
72+The following flags/options and their respective environment variables are no
73+longer available when using alpha configuration:
74+
75+<!-- Legacy Upstream FlagSet -->
76+- `flush-interval`/`flush_interval`
77+- `pass-host-header`/`pass_host_header`
78+- `proxy-websockets`/`proxy_websockets`
79+- `ssl-upstream-insecure-skip-verify`/`ssl_upstream_insecure_skip_verify`
80+- `upstream`/`upstreams`
81+
82+<!-- Legacy Headers FlagSet -->
83+- `pass-basic-auth`/`pass_basic_auth`
84+- `pass-access-token`/`pass_access_token`
85+- `pass-user-headers`/`pass_user_headers`
86+- `pass-authorization-header`/`pass_authorization_header`
87+- `set-basic-auth`/`set_basic_auth`
88+- `set-xauthrequest`/`set_xauthrequest`
89+- `set-authorization-header`/`set_authorization_header`
90+- `prefer-email-to-user`/`prefer_email_to_user`
91+- `basic-auth-password`/`basic_auth_password`
92+- `skip-auth-strip-headers`/`skip_auth_strip_headers`
93+
94+<!-- Legacy provider FlagSet -->
95+- `client-id`/`client_id`
96+- `client-secret`/`client_secret`, and `client-secret-file`/`client_secret_file`
97+- `provider`
98+- `provider-display-name`/`provider_display_name`
99+- `provider-ca-file`/`provider_ca_files`
100+- `login-url`/`login_url`
101+- `redeem-url`/`redeem_url`
102+- `profile-url`/`profile_url`
103+- `resource`
104+- `validate-url`/`validate_url`
105+- `scope`
106+- `prompt`
107+- `approval-prompt`/`approval_prompt`
108+- `acr-values`/`acr_values`
109+- `user-id-claim`/`user_id_claim`
110+- `allowed-group`/`allowed_groups`
111+- `allowed-role`/`allowed_roles`
112+- `jwt-key`/`jwt_key`
113+- `jwt-key-file`/`jwt_key_file`
114+- `pubjwk-url`/`pubjwk_url`
115+
116+and all provider-specific options, i.e. any option whose name includes `oidc`,
117+`azure`, `bitbucket`, `github`, `gitlab`, `google` or `keycloak`. Attempting to
118+use any of these options via flags or via config when `--alpha-config` is
119+set will result in an error.
120+
121+:::important
122+You must remove these options before starting OAuth2 Proxy with `--alpha-config`
123+:::
124+
125+## Configuration Reference
126+<!--- THIS FILE IS AUTOGENERATED!!! DO NOT EDIT!!! -->
127+
128+### ADFSOptions
129+
130+(**Appears on:** [Provider](#provider))
131+
132+
133+
134+| Field | Type | Description |
135+| ----- | ---- | ----------- |
136+| `skipScope` | _bool_ | Skip adding the scope parameter in login request<br/>Default value is 'false' |
137+
138+### AlphaOptions
139+
140+AlphaOptions contains alpha structured configuration options.
141+Usage of these options allows users to access alpha features that are not
142+available as part of the primary configuration structure for OAuth2 Proxy.
143+
144+:::warning
145+The options within this structure are considered alpha.
146+They may change between releases without notice.
147+:::
148+
149+| Field | Type | Description |
150+| ----- | ---- | ----------- |
151+| `upstreamConfig` | _[UpstreamConfig](#upstreamconfig)_ | UpstreamConfig is used to configure upstream servers.<br/>Once a user is authenticated, requests to the server will be proxied to<br/>these upstream servers based on the path mappings defined in this list. |
152+| `injectRequestHeaders` | _[[]Header](#header)_ | InjectRequestHeaders is used to configure headers that should be added<br/>to requests to upstream servers.<br/>Headers may source values from either the authenticated user's session<br/>or from a static secret value. |
153+| `injectResponseHeaders` | _[[]Header](#header)_ | InjectResponseHeaders is used to configure headers that should be added<br/>to responses from the proxy.<br/>This is typically used when using the proxy as an external authentication<br/>provider in conjunction with another proxy such as NGINX and its<br/>auth_request module.<br/>Headers may source values from either the authenticated user's session<br/>or from a static secret value. |
154+| `server` | _[Server](#server)_ | Server is used to configure the HTTP(S) server for the proxy application.<br/>You may choose to run both HTTP and HTTPS servers simultaneously.<br/>This can be done by setting the BindAddress and the SecureBindAddress simultaneously.<br/>To use the secure server you must configure a TLS certificate and key. |
155+| `metricsServer` | _[Server](#server)_ | MetricsServer is used to configure the HTTP(S) server for metrics.<br/>You may choose to run both HTTP and HTTPS servers simultaneously.<br/>This can be done by setting the BindAddress and the SecureBindAddress simultaneously.<br/>To use the secure server you must configure a TLS certificate and key. |
156+| `providers` | _[Providers](#providers)_ | Providers is used to configure multiple providers. |
157+
158+### AzureOptions
159+
160+(**Appears on:** [Provider](#provider))
161+
162+
163+
164+| Field | Type | Description |
165+| ----- | ---- | ----------- |
166+| `tenant` | _string_ | Tenant directs to a tenant-specific or common (tenant-independent) endpoint<br/>Default value is 'common' |
167+| `graphGroupField` | _string_ | GraphGroupField configures the group field to be used when building the groups list from Microsoft Graph<br/>Default value is 'id' |
168+
169+### BitbucketOptions
170+
171+(**Appears on:** [Provider](#provider))
172+
173+
174+
175+| Field | Type | Description |
176+| ----- | ---- | ----------- |
177+| `team` | _string_ | Team sets restrict logins to members of this team |
178+| `repository` | _string_ | Repository sets restrict logins to user with access to this repository |
179+
180+### ClaimSource
181+
182+(**Appears on:** [HeaderValue](#headervalue))
183+
184+ClaimSource allows loading a header value from a claim within the session
185+
186+| Field | Type | Description |
187+| ----- | ---- | ----------- |
188+| `claim` | _string_ | Claim is the name of the claim in the session that the value should be<br/>loaded from. |
189+| `prefix` | _string_ | Prefix is an optional prefix that will be prepended to the value of the<br/>claim if it is non-empty. |
190+| `basicAuthPassword` | _[SecretSource](#secretsource)_ | BasicAuthPassword converts this claim into a basic auth header.<br/>Note the value of claim will become the basic auth username and the<br/>basicAuthPassword will be used as the password value. |
191+
192+### Duration
193+#### (`string` alias)
194+
195+(**Appears on:** [Upstream](#upstream))
196+
197+Duration is as string representation of a period of time.
198+A duration string is a is a possibly signed sequence of decimal numbers,
199+each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
200+Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
201+
202+
203+### GitHubOptions
204+
205+(**Appears on:** [Provider](#provider))
206+
207+
208+
209+| Field | Type | Description |
210+| ----- | ---- | ----------- |
211+| `org` | _string_ | Org sets restrict logins to members of this organisation |
212+| `team` | _string_ | Team sets restrict logins to members of this team |
213+| `repo` | _string_ | Repo sets restrict logins to collaborators of this repository |
214+| `token` | _string_ | Token is the token to use when verifying repository collaborators<br/>it must have push access to the repository |
215+| `users` | _[]string_ | Users allows users with these usernames to login<br/>even if they do not belong to the specified org and team or collaborators |
216+
217+### GitLabOptions
218+
219+(**Appears on:** [Provider](#provider))
220+
221+
222+
223+| Field | Type | Description |
224+| ----- | ---- | ----------- |
225+| `group` | _[]string_ | Group sets restrict logins to members of this group |
226+| `projects` | _[]string_ | Projects restricts logins to members of any of these projects |
227+
228+### GoogleOptions
229+
230+(**Appears on:** [Provider](#provider))
231+
232+
233+
234+| Field | Type | Description |
235+| ----- | ---- | ----------- |
236+| `group` | _[]string_ | Groups sets restrict logins to members of this google group |
237+| `adminEmail` | _string_ | AdminEmail is the google admin to impersonate for api calls |
238+| `serviceAccountJson` | _string_ | ServiceAccountJSON is the path to the service account json credentials |
239+| `useApplicationDefaultCredentials` | _bool_ | UseApplicationDefaultCredentials is a boolean whether to use Application Default Credentials instead of a ServiceAccountJSON |
240+
241+### Header
242+
243+(**Appears on:** [AlphaOptions](#alphaoptions))
244+
245+Header represents an individual header that will be added to a request or
246+response header.
247+
248+| Field | Type | Description |
249+| ----- | ---- | ----------- |
250+| `name` | _string_ | Name is the header name to be used for this set of values.<br/>Names should be unique within a list of Headers. |
251+| `preserveRequestValue` | _bool_ | PreserveRequestValue determines whether any values for this header<br/>should be preserved for the request to the upstream server.<br/>This option only applies to injected request headers.<br/>Defaults to false (headers that match this header will be stripped). |
252+| `values` | _[[]HeaderValue](#headervalue)_ | Values contains the desired values for this header |
253+
254+### HeaderValue
255+
256+(**Appears on:** [Header](#header))
257+
258+HeaderValue represents a single header value and the sources that can
259+make up the header value
260+
261+| Field | Type | Description |
262+| ----- | ---- | ----------- |
263+| `value` | _[]byte_ | Value expects a base64 encoded string value. |
264+| `fromEnv` | _string_ | FromEnv expects the name of an environment variable. |
265+| `fromFile` | _string_ | FromFile expects a path to a file containing the secret value. |
266+| `claim` | _string_ | Claim is the name of the claim in the session that the value should be<br/>loaded from. |
267+| `prefix` | _string_ | Prefix is an optional prefix that will be prepended to the value of the<br/>claim if it is non-empty. |
268+| `basicAuthPassword` | _[SecretSource](#secretsource)_ | BasicAuthPassword converts this claim into a basic auth header.<br/>Note the value of claim will become the basic auth username and the<br/>basicAuthPassword will be used as the password value. |
269+
270+### KeycloakOptions
271+
272+(**Appears on:** [Provider](#provider))
273+
274+
275+
276+| Field | Type | Description |
277+| ----- | ---- | ----------- |
278+| `groups` | _[]string_ | Group enables to restrict login to members of indicated group |
279+| `roles` | _[]string_ | Role enables to restrict login to users with role (only available when using the keycloak-oidc provider) |
280+
281+### LoginGovOptions
282+
283+(**Appears on:** [Provider](#provider))
284+
285+
286+
287+| Field | Type | Description |
288+| ----- | ---- | ----------- |
289+| `jwtKey` | _string_ | JWTKey is a private key in PEM format used to sign JWT, |
290+| `jwtKeyFile` | _string_ | JWTKeyFile is a path to the private key file in PEM format used to sign the JWT |
291+| `pubjwkURL` | _string_ | PubJWKURL is the JWK pubkey access endpoint |
292+
293+### LoginURLParameter
294+
295+(**Appears on:** [Provider](#provider))
296+
297+LoginURLParameter is the configuration for a single query parameter that
298+can be passed through from the `/oauth2/start` endpoint to the IdP login
299+URL. The "default" option specifies the default value or values (if any)
300+that will be passed to the IdP for this parameter, and "allow" is a list
301+of options for ways in which this parameter can be set or overridden via
302+the query string to `/oauth2/start`.
303+If _only_ a default is specified and no "allow" then the parameter is
304+effectively fixed - the default value will always be used and anything
305+passed to the start URL will be ignored. If _only_ "allow" is specified
306+but no default then the parameter will only be passed on to the IdP if
307+the caller provides it, and no value will be sent otherwise.
308+
309+Examples:
310+
311+# A parameter whose value is fixed
312+
313+```
314+name: organization
315+default:
316+- myorg
317+```
318+
319+A parameter that is not passed by default, but may be set to one of a
320+fixed set of values
321+
322+```
323+name: prompt
324+allow:
325+- value: login
326+- value: consent
327+- value: select_account
328+```
329+
330+A parameter that is passed by default but may be overridden by one of
331+a fixed set of values
332+
333+```
334+name: prompt
335+default: ["login"]
336+allow:
337+- value: consent
338+- value: select_account
339+```
340+
341+A parameter that may be overridden, but only by values that match a
342+regular expression. For example to restrict `login_hint` to email
343+addresses in your organization's domain:
344+
345+```
346+name: login_hint
347+allow:
348+- pattern: '^[^@]*@example\.com$'
349+# this allows at most one "@" sign, and requires "example.com" domain.
350+```
351+
352+Note that the YAML rules around exactly which characters are allowed
353+and/or require escaping in different types of string literals are
354+convoluted. For regular expressions the single quoted form is simplest
355+as backslash is not considered to be an escape character. Alternatively
356+use the "chomped block" format `|-`:
357+
358+```
359+ - pattern: |-
360+ ^[^@]*@example\.com$
361+
362+```
363+
364+The hyphen is important, a `|` block would have a trailing newline
365+character.
366+
367+| Field | Type | Description |
368+| ----- | ---- | ----------- |
369+| `name` | _string_ | Name specifies the name of the query parameter. |
370+| `default` | _[]string_ | _(Optional)_ Default specifies a default value or values that will be<br/>passed to the IdP if not overridden. |
371+| `allow` | _[[]URLParameterRule](#urlparameterrule)_ | _(Optional)_ Allow specifies rules about how the default (if any) may be<br/>overridden via the query string to `/oauth2/start`. Only<br/>values that match one or more of the allow rules will be<br/>forwarded to the IdP. |
372+
373+### OIDCOptions
374+
375+(**Appears on:** [Provider](#provider))
376+
377+
378+
379+| Field | Type | Description |
380+| ----- | ---- | ----------- |
381+| `issuerURL` | _string_ | IssuerURL is the OpenID Connect issuer URL<br/>eg: https://accounts.google.com |
382+| `insecureAllowUnverifiedEmail` | _bool_ | InsecureAllowUnverifiedEmail prevents failures if an email address in an id_token is not verified<br/>default set to 'false' |
383+| `insecureSkipIssuerVerification` | _bool_ | InsecureSkipIssuerVerification skips verification of ID token issuers. When false, ID Token Issuers must match the OIDC discovery URL<br/>default set to 'false' |
384+| `insecureSkipNonce` | _bool_ | InsecureSkipNonce skips verifying the ID Token's nonce claim that must match<br/>the random nonce sent in the initial OAuth flow. Otherwise, the nonce is checked<br/>after the initial OAuth redeem & subsequent token refreshes.<br/>default set to 'true'<br/>Warning: In a future release, this will change to 'false' by default for enhanced security. |
385+| `skipDiscovery` | _bool_ | SkipDiscovery allows to skip OIDC discovery and use manually supplied Endpoints<br/>default set to 'false' |
386+| `jwksURL` | _string_ | JwksURL is the OpenID Connect JWKS URL<br/>eg: https://www.googleapis.com/oauth2/v3/certs |
387+| `emailClaim` | _string_ | EmailClaim indicates which claim contains the user email,<br/>default set to 'email' |
388+| `groupsClaim` | _string_ | GroupsClaim indicates which claim contains the user groups<br/>default set to 'groups' |
389+| `userIDClaim` | _string_ | UserIDClaim indicates which claim contains the user ID<br/>default set to 'email' |
390+| `audienceClaims` | _[]string_ | AudienceClaim allows to define any claim that is verified against the client id<br/>By default `aud` claim is used for verification. |
391+| `extraAudiences` | _[]string_ | ExtraAudiences is a list of additional audiences that are allowed<br/>to pass verification in addition to the client id. |
392+
393+### Provider
394+
395+(**Appears on:** [Providers](#providers))
396+
397+Provider holds all configuration for a single provider
398+
399+| Field | Type | Description |
400+| ----- | ---- | ----------- |
401+| `clientID` | _string_ | ClientID is the OAuth Client ID that is defined in the provider<br/>This value is required for all providers. |
402+| `clientSecret` | _string_ | ClientSecret is the OAuth Client Secret that is defined in the provider<br/>This value is required for all providers. |
403+| `clientSecretFile` | _string_ | ClientSecretFile is the name of the file<br/>containing the OAuth Client Secret, it will be used if ClientSecret is not set. |
404+| `keycloakConfig` | _[KeycloakOptions](#keycloakoptions)_ | KeycloakConfig holds all configurations for Keycloak provider. |
405+| `azureConfig` | _[AzureOptions](#azureoptions)_ | AzureConfig holds all configurations for Azure provider. |
406+| `ADFSConfig` | _[ADFSOptions](#adfsoptions)_ | ADFSConfig holds all configurations for ADFS provider. |
407+| `bitbucketConfig` | _[BitbucketOptions](#bitbucketoptions)_ | BitbucketConfig holds all configurations for Bitbucket provider. |
408+| `githubConfig` | _[GitHubOptions](#githuboptions)_ | GitHubConfig holds all configurations for GitHubC provider. |
409+| `gitlabConfig` | _[GitLabOptions](#gitlaboptions)_ | GitLabConfig holds all configurations for GitLab provider. |
410+| `googleConfig` | _[GoogleOptions](#googleoptions)_ | GoogleConfig holds all configurations for Google provider. |
411+| `oidcConfig` | _[OIDCOptions](#oidcoptions)_ | OIDCConfig holds all configurations for OIDC provider<br/>or providers utilize OIDC configurations. |
412+| `loginGovConfig` | _[LoginGovOptions](#logingovoptions)_ | LoginGovConfig holds all configurations for LoginGov provider. |
413+| `id` | _string_ | ID should be a unique identifier for the provider.<br/>This value is required for all providers. |
414+| `provider` | _[ProviderType](#providertype)_ | Type is the OAuth provider<br/>must be set from the supported providers group,<br/>otherwise 'Google' is set as default |
415+| `name` | _string_ | Name is the providers display name<br/>if set, it will be shown to the users in the login page. |
416+| `caFiles` | _[]string_ | CAFiles is a list of paths to CA certificates that should be used when connecting to the provider.<br/>If not specified, the default Go trust sources are used instead |
417+| `loginURL` | _string_ | LoginURL is the authentication endpoint |
418+| `loginURLParameters` | _[[]LoginURLParameter](#loginurlparameter)_ | LoginURLParameters defines the parameters that can be passed from the start URL to the IdP login URL |
419+| `redeemURL` | _string_ | RedeemURL is the token redemption endpoint |
420+| `profileURL` | _string_ | ProfileURL is the profile access endpoint |
421+| `resource` | _string_ | ProtectedResource is the resource that is protected (Azure AD and ADFS only) |
422+| `validateURL` | _string_ | ValidateURL is the access token validation endpoint |
423+| `scope` | _string_ | Scope is the OAuth scope specification |
424+| `allowedGroups` | _[]string_ | AllowedGroups is a list of restrict logins to members of this group |
425+| `code_challenge_method` | _string_ | The code challenge method |
426+
427+### ProviderType
428+#### (`string` alias)
429+
430+(**Appears on:** [Provider](#provider))
431+
432+ProviderType is used to enumerate the different provider type options
433+Valid options are: adfs, azure, bitbucket, digitalocean facebook, github,
434+gitlab, google, keycloak, keycloak-oidc, linkedin, login.gov, nextcloud
435+and oidc.
436+
437+
438+### Providers
439+
440+#### ([[]Provider](#provider) alias)
441+
442+(**Appears on:** [AlphaOptions](#alphaoptions))
443+
444+Providers is a collection of definitions for providers.
445+
446+
447+### SecretSource
448+
449+(**Appears on:** [ClaimSource](#claimsource), [HeaderValue](#headervalue), [TLS](#tls))
450+
451+SecretSource references an individual secret value.
452+Only one source within the struct should be defined at any time.
453+
454+| Field | Type | Description |
455+| ----- | ---- | ----------- |
456+| `value` | _[]byte_ | Value expects a base64 encoded string value. |
457+| `fromEnv` | _string_ | FromEnv expects the name of an environment variable. |
458+| `fromFile` | _string_ | FromFile expects a path to a file containing the secret value. |
459+
460+### Server
461+
462+(**Appears on:** [AlphaOptions](#alphaoptions))
463+
464+Server represents the configuration for an HTTP(S) server
465+
466+| Field | Type | Description |
467+| ----- | ---- | ----------- |
468+| `BindAddress` | _string_ | BindAddress is the address on which to serve traffic.<br/>Leave blank or set to "-" to disable. |
469+| `SecureBindAddress` | _string_ | SecureBindAddress is the address on which to serve secure traffic.<br/>Leave blank or set to "-" to disable. |
470+| `TLS` | _[TLS](#tls)_ | TLS contains the information for loading the certificate and key for the<br/>secure traffic and further configuration for the TLS server. |
471+
472+### TLS
473+
474+(**Appears on:** [Server](#server))
475+
476+TLS contains the information for loading a TLS certificate and key
477+as well as an optional minimal TLS version that is acceptable.
478+
479+| Field | Type | Description |
480+| ----- | ---- | ----------- |
481+| `Key` | _[SecretSource](#secretsource)_ | Key is the TLS key data to use.<br/>Typically this will come from a file. |
482+| `Cert` | _[SecretSource](#secretsource)_ | Cert is the TLS certificate data to use.<br/>Typically this will come from a file. |
483+| `MinVersion` | _string_ | MinVersion is the minimal TLS version that is acceptable.<br/>E.g. Set to "TLS1.3" to select TLS version 1.3 |
484+| `CipherSuites` | _[]string_ | CipherSuites is a list of TLS cipher suites that are allowed.<br/>E.g.:<br/>- TLS_RSA_WITH_RC4_128_SHA<br/>- TLS_RSA_WITH_AES_256_GCM_SHA384<br/>If not specified, the default Go safe cipher list is used.<br/>List of valid cipher suites can be found in the [crypto/tls documentation](https://pkg.go.dev/crypto/tls#pkg-constants). |
485+
486+### URLParameterRule
487+
488+(**Appears on:** [LoginURLParameter](#loginurlparameter))
489+
490+URLParameterRule represents a rule by which query parameters
491+passed to the `/oauth2/start` endpoint are checked to determine whether
492+they are valid overrides for the given parameter passed to the IdP's
493+login URL. Either Value or Pattern should be supplied, not both.
494+
495+| Field | Type | Description |
496+| ----- | ---- | ----------- |
497+| `value` | _string_ | A Value rule matches just this specific value |
498+| `pattern` | _string_ | A Pattern rule gives a regular expression that must be matched by<br/>some substring of the value. The expression is _not_ automatically<br/>anchored to the start and end of the value, if you _want_ to restrict<br/>the whole parameter value you must anchor it yourself with `^` and `$`. |
499+
500+### Upstream
501+
502+(**Appears on:** [UpstreamConfig](#upstreamconfig))
503+
504+Upstream represents the configuration for an upstream server.
505+Requests will be proxied to this upstream if the path matches the request path.
506+
507+| Field | Type | Description |
508+| ----- | ---- | ----------- |
509+| `id` | _string_ | ID should be a unique identifier for the upstream.<br/>This value is required for all upstreams. |
510+| `path` | _string_ | Path is used to map requests to the upstream server.<br/>The closest match will take precedence and all Paths must be unique.<br/>Path can also take a pattern when used with RewriteTarget.<br/>Path segments can be captured and matched using regular experessions.<br/>Eg:<br/>- `^/foo$`: Match only the explicit path `/foo`<br/>- `^/bar/$`: Match any path prefixed with `/bar/`<br/>- `^/baz/(.*)$`: Match any path prefixed with `/baz` and capture the remaining path for use with RewriteTarget |
511+| `rewriteTarget` | _string_ | RewriteTarget allows users to rewrite the request path before it is sent to<br/>the upstream server.<br/>Use the Path to capture segments for reuse within the rewrite target.<br/>Eg: With a Path of `^/baz/(.*)`, a RewriteTarget of `/foo/$1` would rewrite<br/>the request `/baz/abc/123` to `/foo/abc/123` before proxying to the<br/>upstream server. |
512+| `uri` | _string_ | The URI of the upstream server. This may be an HTTP(S) server of a File<br/>based URL. It may include a path, in which case all requests will be served<br/>under that path.<br/>Eg:<br/>- http://localhost:8080<br/>- https://service.localhost<br/>- https://service.localhost/path<br/>- file://host/path<br/>If the URI's path is "/base" and the incoming request was for "/dir",<br/>the upstream request will be for "/base/dir". |
513+| `insecureSkipTLSVerify` | _bool_ | InsecureSkipTLSVerify will skip TLS verification of upstream HTTPS hosts.<br/>This option is insecure and will allow potential Man-In-The-Middle attacks<br/>betweem OAuth2 Proxy and the usptream server.<br/>Defaults to false. |
514+| `static` | _bool_ | Static will make all requests to this upstream have a static response.<br/>The response will have a body of "Authenticated" and a response code<br/>matching StaticCode.<br/>If StaticCode is not set, the response will return a 200 response. |
515+| `staticCode` | _int_ | StaticCode determines the response code for the Static response.<br/>This option can only be used with Static enabled. |
516+| `flushInterval` | _[Duration](#duration)_ | FlushInterval is the period between flushing the response buffer when<br/>streaming response from the upstream.<br/>Defaults to 1 second. |
517+| `passHostHeader` | _bool_ | PassHostHeader determines whether the request host header should be proxied<br/>to the upstream server.<br/>Defaults to true. |
518+| `proxyWebSockets` | _bool_ | ProxyWebSockets enables proxying of websockets to upstream servers<br/>Defaults to true. |
519+| `timeout` | _[Duration](#duration)_ | Timeout is the maximum duration the server will wait for a response from the upstream server.<br/>Defaults to 30 seconds. |
520+
521+### UpstreamConfig
522+
523+(**Appears on:** [AlphaOptions](#alphaoptions))
524+
525+UpstreamConfig is a collection of definitions for upstream servers.
526+
527+| Field | Type | Description |
528+| ----- | ---- | ----------- |
529+| `proxyRawPath` | _bool_ | ProxyRawPath will pass the raw url path to upstream allowing for url's<br/>like: "/%2F/" which would otherwise be redirected to "/" |
530+| `upstreams` | _[[]Upstream](#upstream)_ | Upstreams represents the configuration for the upstream servers.<br/>Requests will be proxied to this upstream if the path matches the request path. |
docs/versioned_docs/version-7.5.x/configuration/alpha_config.md.tmplnew file+125
@@ -0,0 +1,125 @@
1+---
2+id: alpha-config
3+title: Alpha Configuration
4+---
5+
6+:::warning
7+This page contains documentation for alpha features.
8+We reserve the right to make breaking changes to the features detailed within this page with no notice.
9+
10+Options described in this page may be changed, removed, renamed or moved without prior warning.
11+Please beware of this before you use alpha configuration options.
12+:::
13+
14+This page details a set of **alpha** configuration options in a new format.
15+Going forward we are intending to add structured configuration in YAML format to
16+replace the existing TOML based configuration file and flags.
17+
18+Below is a reference for the structure of the configuration, with
19+[AlphaOptions](#alphaoptions) as the root of the configuration.
20+
21+When using alpha configuration, your config file will look something like below:
22+
23+```yaml
24+upstreams:
25+ - id: ...
26+ ...
27+injectRequestHeaders:
28+ - name: ...
29+ ...
30+injectResponseHeaders:
31+ - name: ...
32+ ...
33+```
34+
35+Please browse the [reference](#configuration-reference) below for the structure
36+of the new configuration format.
37+
38+## Using Alpha Configuration
39+
40+To use the new **alpha** configuration, generate a YAML file based on the format
41+described in the [reference](#configuration-reference) below.
42+
43+Provide the path to this file using the `--alpha-config` flag.
44+
45+:::note
46+When using the `--alpha-config` flag, some options are no longer available.
47+See [removed options](#removed-options) below for more information.
48+:::
49+
50+### Converting configuration to the new structure
51+
52+Before adding the new `--alpha-config` option, start OAuth2 Proxy using the
53+`convert-config-to-alpha` flag to convert existing configuration to the new format.
54+
55+```bash
56+oauth2-proxy --convert-config-to-alpha --config ./path/to/existing/config.cfg
57+```
58+
59+This will convert any options supported by the new format to YAML and print the
60+new configuration to `STDOUT`.
61+
62+Copy this to a new file, remove any options from your existing configuration
63+noted in [removed options](#removed-options) and then start OAuth2 Proxy using
64+the new config.
65+
66+```bash
67+oauth2-proxy --alpha-config ./path/to/new/config.yaml --config ./path/to/existing/config.cfg
68+```
69+
70+## Removed options
71+
72+The following flags/options and their respective environment variables are no
73+longer available when using alpha configuration:
74+
75+<!-- Legacy Upstream FlagSet -->
76+- `flush-interval`/`flush_interval`
77+- `pass-host-header`/`pass_host_header`
78+- `proxy-websockets`/`proxy_websockets`
79+- `ssl-upstream-insecure-skip-verify`/`ssl_upstream_insecure_skip_verify`
80+- `upstream`/`upstreams`
81+
82+<!-- Legacy Headers FlagSet -->
83+- `pass-basic-auth`/`pass_basic_auth`
84+- `pass-access-token`/`pass_access_token`
85+- `pass-user-headers`/`pass_user_headers`
86+- `pass-authorization-header`/`pass_authorization_header`
87+- `set-basic-auth`/`set_basic_auth`
88+- `set-xauthrequest`/`set_xauthrequest`
89+- `set-authorization-header`/`set_authorization_header`
90+- `prefer-email-to-user`/`prefer_email_to_user`
91+- `basic-auth-password`/`basic_auth_password`
92+- `skip-auth-strip-headers`/`skip_auth_strip_headers`
93+
94+<!-- Legacy provider FlagSet -->
95+- `client-id`/`client_id`
96+- `client-secret`/`client_secret`, and `client-secret-file`/`client_secret_file`
97+- `provider`
98+- `provider-display-name`/`provider_display_name`
99+- `provider-ca-file`/`provider_ca_files`
100+- `login-url`/`login_url`
101+- `redeem-url`/`redeem_url`
102+- `profile-url`/`profile_url`
103+- `resource`
104+- `validate-url`/`validate_url`
105+- `scope`
106+- `prompt`
107+- `approval-prompt`/`approval_prompt`
108+- `acr-values`/`acr_values`
109+- `user-id-claim`/`user_id_claim`
110+- `allowed-group`/`allowed_groups`
111+- `allowed-role`/`allowed_roles`
112+- `jwt-key`/`jwt_key`
113+- `jwt-key-file`/`jwt_key_file`
114+- `pubjwk-url`/`pubjwk_url`
115+
116+and all provider-specific options, i.e. any option whose name includes `oidc`,
117+`azure`, `bitbucket`, `github`, `gitlab`, `google` or `keycloak`. Attempting to
118+use any of these options via flags or via config when `--alpha-config` is
119+set will result in an error.
120+
121+:::important
122+You must remove these options before starting OAuth2 Proxy with `--alpha-config`
123+:::
124+
125+## Configuration Reference
docs/versioned_docs/version-7.5.x/configuration/auth.mdnew file+691
@@ -0,0 +1,691 @@
1+---
2+id: oauth_provider
3+title: OAuth Provider Configuration
4+---
5+
6+You will need to register an OAuth application with a Provider (Google, GitHub or another provider), and configure it with Redirect URI(s) for the domain you intend to run `oauth2-proxy` on.
7+
8+Valid providers are :
9+
10+- [Google](#google-auth-provider) _default_
11+- [Azure](#azure-auth-provider)
12+- [ADFS](#adfs-auth-provider)
13+- [Facebook](#facebook-auth-provider)
14+- [GitHub](#github-auth-provider)
15+- [Keycloak](#keycloak-auth-provider)
16+- [GitLab](#gitlab-auth-provider)
17+- [LinkedIn](#linkedin-auth-provider)
18+- [Microsoft Azure AD](#microsoft-azure-ad-provider)
19+- [OpenID Connect](#openid-connect-provider)
20+- [login.gov](#logingov-provider)
21+- [Nextcloud](#nextcloud-provider)
22+- [DigitalOcean](#digitalocean-auth-provider)
23+- [Bitbucket](#bitbucket-auth-provider)
24+- [Gitea](#gitea-auth-provider)
25+
26+The provider can be selected using the `provider` configuration value.
27+
28+Please note that not all providers support all claims. The `preferred_username` claim is currently only supported by the OpenID Connect provider.
29+
30+### Google Auth Provider
31+
32+For Google, the registration steps are:
33+
34+1. Create a new project: https://console.developers.google.com/project
35+2. Choose the new project from the top right project dropdown (only if another project is selected)
36+3. In the project Dashboard center pane, choose **"APIs & Services"**
37+4. In the left Nav pane, choose **"Credentials"**
38+5. In the center pane, choose **"OAuth consent screen"** tab. Fill in **"Product name shown to users"** and hit save.
39+6. In the center pane, choose **"Credentials"** tab.
40+ - Open the **"New credentials"** drop down
41+ - Choose **"OAuth client ID"**
42+ - Choose **"Web application"**
43+ - Application name is freeform, choose something appropriate
44+ - Authorized JavaScript origins is your domain ex: `https://internal.yourcompany.com`
45+ - Authorized redirect URIs is the location of oauth2/callback ex: `https://internal.yourcompany.com/oauth2/callback`
46+ - Choose **"Create"**
47+7. Take note of the **Client ID** and **Client Secret**
48+
49+It's recommended to refresh sessions on a short interval (1h) with `cookie-refresh` setting which validates that the account is still authorized.
50+
51+#### Restrict auth to specific Google groups on your domain. (optional)
52+
53+1. Create a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) and download the json
54+file if you're not using [Application Default Credentials / Workload Identity / Workload Identity Federation (recommended)](#using-application-default-credentials-adc--workload-identity--workload-identity-federation-recommended).
55+2. Make note of the Client ID for a future step.
56+3. Under "APIs & Auth", choose APIs.
57+4. Click on Admin SDK and then Enable API.
58+5. Follow the steps on https://developers.google.com/admin-sdk/directory/v1/guides/delegation#delegate_domain-wide_authority_to_your_service_account and give the client id from step 2 the following oauth scopes:
59+
60+
61+##### Using Application Default Credentials (ADC) / Workload Identity / Workload Identity Federation (recommended)
62+oauth2-proxy can make use of [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials).
63+When deployed within GCP, this means that it can automatically use the service account attached to the resource. When deployed to GKE, ADC
64+can be leveraged through a feature called Workload Identity. Follow Google's [guide](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)
65+to set up Workload Identity.
66+
67+When deployed outside of GCP, [Workload Identity Federation](https://cloud.google.com/docs/authentication/provide-credentials-adc#wlif) might be an option.
68+
69+```
70+https://www.googleapis.com/auth/admin.directory.group.readonly
71+https://www.googleapis.com/auth/admin.directory.user.readonly
72+```
73+
74+6. Follow the steps on https://support.google.com/a/answer/60757 to enable Admin API access.
75+7. Create or choose an existing administrative email address on the Gmail domain to assign to the `google-admin-email` flag. This email will be impersonated by this client to make calls to the Admin SDK. See the note on the link from step 5 for the reason why.
76+8. Create or choose an existing email group and set that email to the `google-group` flag. You can pass multiple instances of this flag with different groups
77+ and the user will be checked against all the provided groups.
78+9. Lock down the permissions on the json file downloaded from step 1 so only oauth2-proxy is able to read the file and set the path to the file in the `google-service-account-json` flag.
79+10. Restart oauth2-proxy.
80+
81+Note: The user is checked against the group members list on initial authentication and every time the token is refreshed ( about once an hour ).
82+
83+### Azure Auth Provider
84+
85+1. Add an application: go to [https://portal.azure.com](https://portal.azure.com), choose **Azure Active Directory**, select
86+**App registrations** and then click on **New registration**.
87+2. Pick a name, check the supported account type(single-tenant, multi-tenant, etc). In the **Redirect URI** section create a new
88+**Web** platform entry for each app that you want to protect by the oauth2 proxy(e.g.
89+https://internal.yourcompanycom/oauth2/callback). Click **Register**.
90+3. Next we need to add group read permissions for the app registration, on the **API Permissions** page of the app, click on
91+**Add a permission**, select **Microsoft Graph**, then select **Application permissions**, then click on **Group** and select
92+**Group.Read.All**. Hit **Add permissions** and then on **Grant admin consent** (you might need an admin to do this).
93+<br/>**IMPORTANT**: Even if this permission is listed with **"Admin consent required=No"** the consent might actually be required, due to AAD policies you won't be able to see. If you get a **"Need admin approval"** during login, most likely this is what you're missing!
94+4. Next, if you are planning to use v2.0 Azure Auth endpoint, go to the **Manifest** page and set `"accessTokenAcceptedVersion": 2`
95+in the App registration manifest file.
96+5. On the **Certificates & secrets** page of the app, add a new client secret and note down the value after hitting **Add**.
97+6. Configure the proxy with:
98+- for V1 Azure Auth endpoint (Azure Active Directory Endpoints - https://login.microsoftonline.com/common/oauth2/authorize)
99+
100+```
101+ --provider=azure
102+ --client-id=<application ID from step 3>
103+ --client-secret=<value from step 5>
104+ --azure-tenant={tenant-id}
105+ --oidc-issuer-url=https://sts.windows.net/{tenant-id}/
106+```
107+
108+- for V2 Azure Auth endpoint (Microsoft Identity Platform Endpoints - https://login.microsoftonline.com/common/oauth2/v2.0/authorize)
109+```
110+ --provider=azure
111+ --client-id=<application ID from step 3>
112+ --client-secret=<value from step 5>
113+ --azure-tenant={tenant-id}
114+ --oidc-issuer-url=https://login.microsoftonline.com/{tenant-id}/v2.0
115+```
116+
117+***Notes***:
118+- When using v2.0 Azure Auth endpoint (`https://login.microsoftonline.com/{tenant-id}/v2.0`) as `--oidc_issuer_url`, in conjunction
119+with `--resource` flag, be sure to append `/.default` at the end of the resource name. See
120+https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#the-default-scope for more details.
121+- When using the Azure Auth provider with nginx and the cookie session store you may find the cookie is too large and doesn't
122+get passed through correctly. Increasing the proxy_buffer_size in nginx or implementing the [redis session storage](sessions.md#redis-storage)
123+should resolve this.
124+
125+### ADFS Auth Provider
126+
127+1. Open the ADFS administration console on your Windows Server and add a new Application Group
128+2. Provide a name for the integration, select Server Application from the Standalone applications section and click Next
129+3. Follow the wizard to get the client-id, client-secret and configure the application credentials
130+4. Configure the proxy with
131+
132+```
133+ --provider=adfs
134+ --client-id=<application ID from step 3>
135+ --client-secret=<value from step 3>
136+```
137+
138+Note: When using the ADFS Auth provider with nginx and the cookie session store you may find the cookie is too large and doesn't get passed through correctly. Increasing the proxy_buffer_size in nginx or implementing the [redis session storage](sessions.md#redis-storage) should resolve this.
139+
140+### Facebook Auth Provider
141+
142+1. Create a new FB App from <https://developers.facebook.com/>
143+2. Under FB Login, set your Valid OAuth redirect URIs to `https://internal.yourcompany.com/oauth2/callback`
144+
145+### GitHub Auth Provider
146+
147+1. Create a new project: https://github.com/settings/developers
148+2. Under `Authorization callback URL` enter the correct url ie `https://internal.yourcompany.com/oauth2/callback`
149+
150+The GitHub auth provider supports two additional ways to restrict authentication to either organization and optional team level access, or to collaborators of a repository. Restricting by these options is normally accompanied with `--email-domain=*`
151+
152+NOTE: When `--github-user` is set, the specified users are allowed to login even if they do not belong to the specified org and team or collaborators.
153+
154+To restrict by organization only, include the following flag:
155+
156+ -github-org="": restrict logins to members of this organisation
157+
158+To restrict within an organization to specific teams, include the following flag in addition to `-github-org`:
159+
160+ -github-team="": restrict logins to members of any of these teams (slug), separated by a comma
161+
162+If you would rather restrict access to collaborators of a repository, those users must either have push access to a public repository or any access to a private repository:
163+
164+ -github-repo="": restrict logins to collaborators of this repository formatted as orgname/repo
165+
166+If you'd like to allow access to users with **read only** access to a **public** repository you will need to provide a [token](https://github.com/settings/tokens) for a user that has write access to the repository. The token must be created with at least the `public_repo` scope:
167+
168+ -github-token="": the token to use when verifying repository collaborators
169+
170+To allow a user to login with their username even if they do not belong to the specified org and team or collaborators, separated by a comma
171+
172+ -github-user="": allow logins by username, separated by a comma
173+
174+If you are using GitHub enterprise, make sure you set the following to the appropriate url:
175+
176+ -login-url="http(s)://<enterprise github host>/login/oauth/authorize"
177+ -redeem-url="http(s)://<enterprise github host>/login/oauth/access_token"
178+ -validate-url="http(s)://<enterprise github host>/api/v3"
179+
180+### Keycloak Auth Provider
181+
182+:::note
183+This is the legacy provider for Keycloak, use [Keycloak OIDC Auth Provider](#keycloak-oidc-auth-provider) if possible.
184+:::
185+
186+1. Create new client in your Keycloak realm with **Access Type** 'confidental' and **Valid Redirect URIs** 'https://internal.yourcompany.com/oauth2/callback'
187+2. Take note of the Secret in the credential tab of the client
188+3. Create a mapper with **Mapper Type** 'Group Membership' and **Token Claim Name** 'groups'.
189+
190+Make sure you set the following to the appropriate url:
191+
192+```
193+ --provider=keycloak
194+ --client-id=<client you have created>
195+ --client-secret=<your client's secret>
196+ --login-url="http(s)://<keycloak host>/auth/realms/<your realm>/protocol/openid-connect/auth"
197+ --redeem-url="http(s)://<keycloak host>/auth/realms/<your realm>/protocol/openid-connect/token"
198+ --profile-url="http(s)://<keycloak host>/auth/realms/<your realm>/protocol/openid-connect/userinfo"
199+ --validate-url="http(s)://<keycloak host>/auth/realms/<your realm>/protocol/openid-connect/userinfo"
200+ --keycloak-group=<first_allowed_user_group>
201+ --keycloak-group=<second_allowed_user_group>
202+```
203+
204+For group based authorization, the optional `--keycloak-group` (legacy) or `--allowed-group` (global standard)
205+flags can be used to specify which groups to limit access to.
206+
207+If these are unset but a `groups` mapper is set up above in step (3), the provider will still
208+populate the `X-Forwarded-Groups` header to your upstream server with the `groups` data in the
209+Keycloak userinfo endpoint response.
210+
211+The group management in keycloak is using a tree. If you create a group named admin in keycloak
212+you should define the 'keycloak-group' value to /admin.
213+
214+### Keycloak OIDC Auth Provider
215+
216+```
217+ --provider=keycloak-oidc
218+ --client-id=<your client's id>
219+ --client-secret=<your client's secret>
220+ --redirect-url=https://internal.yourcompany.com/oauth2/callback
221+ --oidc-issuer-url=https://<keycloak host>/auth/realms/<your realm>
222+ --email-domain=<yourcompany.com> // Validate email domain for users, see option documentation
223+ --allowed-role=<realm role name> // Optional, required realm role
224+ --allowed-role=<client id>:<client role name> // Optional, required client role
225+ --allowed-group=</group name> // Optional, requires group client scope
226+ --code-challenge-method=S256 // PKCE
227+```
228+
229+:::note
230+Keycloak has updated its admin console and as of version 19.0.0, the new admin console is enabled by default. The legacy admin console has been announced for removal with the release of version 21.0.0.
231+:::
232+
233+**Keycloak legacy admin console**
234+
235+1. Create new client in your Keycloak realm with **Access Type** 'confidential', **Client protocol** 'openid-connect' and **Valid Redirect URIs** 'https://internal.yourcompany.com/oauth2/callback'
236+2. Take note of the Secret in the credential tab of the client
237+3. Create a mapper with **Mapper Type** 'Group Membership' and **Token Claim Name** 'groups'.
238+4. Create a mapper with **Mapper Type** 'Audience' and **Included Client Audience** and **Included Custom Audience** set to your client name.
239+
240+**Keycloak new admin console (default as of v19.0.0)**
241+
242+The following example shows how to create a simple OIDC client using the new Keycloak admin2 console. However, for best practices, it is recommended to consult the Keycloak documentation.
243+
244+The OIDC client must be configured with an _audience mapper_ to include the client's name in the `aud` claim of the JWT token.
245+The `aud` claim specifies the intended recipient of the token, and OAuth2 Proxy expects a match against the values of either `--client-id` or `--oidc-extra-audience`.
246+
247+_In Keycloak, claims are added to JWT tokens through the use of mappers at either the realm level using "client scopes" or through "dedicated" client mappers._
248+
249+**Creating the client**
250+
251+1. Create a new OIDC client in your Keycloak realm by navigating to:
252+ **Clients** -> **Create client**
253+* **Client Type** 'OpenID Connect'
254+* **Client ID** `<your client's id>`, please complete the remaining fields as appropriate and click **Next**.
255+ * **Client authentication** 'On'
256+ * **Authentication flow**
257+ * **Standard flow** 'selected'
258+ * **Direct access grants** 'deselect'
259+ * _Save the configuration._
260+ * **Settings / Access settings**:
261+ * **Valid redirect URIs** `https://internal.yourcompany.com/oauth2/callback`
262+ * _Save the configuration._
263+ * Under the **Credentials** tab you will now be able to locate `<your client's secret>`.
264+2. Configure a dedicated *audience mapper* for your client by navigating to **Clients** -> **<your client's id>** -> **Client scopes**.
265+* Access the dedicated mappers pane by clicking **<your client's id>-dedicated**, located under *Assigned client scope*.
266+ _(It should have a description of "Dedicated scope and mappers for this client")_
267+ * Click **Configure a new mapper** and select **Audience**
268+ * **Name** 'aud-mapper-<your client's id>'
269+ * **Included Client Audience** select `<your client's id>` from the dropdown.
270+ * _OAuth2 proxy can be set up to pass both the access and ID JWT tokens to your upstream services.
271+ If you require additional audience entries, you can use the **Included Custom Audience** field in addition to the "Included Client Audience" dropdown. Note that the "aud" claim of a JWT token should be limited and only specify its intended recipients._
272+ * **Add to ID token** 'On'
273+ * **Add to access token** 'On' - [#1916](https://github.com/oauth2-proxy/oauth2-proxy/pull/1916)
274+ * _Save the configuration._
275+* Any subsequent dedicated client mappers can be defined by clicking **Dedicated scopes** -> **Add mapper** -> **By configuration** -> *Select mapper*
276+
277+You should now be able to create a test user in Keycloak and get access to the OAuth2 Proxy instance, make sure to set an email address matching `<yourcompany.com>` and select _Email verified_.
278+
279+**Authorization**
280+
281+_OAuth2 Proxy will perform authorization by requiring a valid user, this authorization can be extended to take into account a user's membership in Keycloak `groups`, `realm roles`, and `client roles` using the keycloak-oidc provider options
282+`--allowed-role` or `--allowed-group`_
283+
284+**Roles**
285+
286+_A standard Keycloak installation comes with the required mappers for **realm roles** and **client roles** through the pre-defined client scope "roles".
287+This ensures that any roles assigned to a user are included in the `JWT` tokens when using an OIDC client that has the "Full scope allowed" feature activated, the feature is enabled by default._
288+
289+_Creating a realm role_
290+* Navigate to **Realm roles** -> **Create role**
291+ * **Role name**, *`<realm role name>`* -> **save**
292+
293+_Creating a client role_
294+* Navigate to **Clients** -> `<your client's id>` -> **Roles** -> **Create role**
295+ * **Role name**, *`<client role name>`* -> **save**
296+
297+
298+_Assign a role to a user_
299+
300+**Users** -> _Username_ -> **Role mapping** -> **Assign role** -> _filter by roles or clients and select_ -> **Assign**.
301+
302+Keycloak "realm roles" can be authorized using the `--allowed-role=<realm role name>` option, while "client roles" can be evaluated using `--allowed-role=<your client's id>:<client role name>`.
303+
304+You may limit the _realm roles_ included in the JWT tokens for any given client by navigating to:
305+**Clients** -> `<your client's id>` -> **Client scopes** -> _<your client's id>-dedicated_ -> **Scope**
306+Disabling **Full scope allowed** activates the **Assign role** option, allowing you to select which roles, if assigned to a user, will be included in the user's JWT tokens. This can be useful when a user has many associated roles, and you want to reduce the size and impact of the JWT token.
307+
308+
309+**Groups**
310+
311+You may also do authorization on group memberships by using the OAuth2 Proxy option `--allowed-group`.
312+We will only do a brief description of creating the required _client scope_ **groups** and refer you to read the Keycloak documentation.
313+
314+To summarize, the steps required to authorize Keycloak group membership with OAuth2 Proxy are as follows:
315+
316+* Create a new Client Scope with the name **groups** in Keycloak.
317+ * Include a mapper of type **Group Membership**.
318+ * Set the "Token Claim Name" to **groups** or customize by matching it to the `--oidc-groups-claim` option of OAuth2 Proxy.
319+ * If the "Full group path" option is selected, you need to include a "/" separator in the group names defined in the `--allowed-group` option of OAuth2 Proxy. Example: "/groupname" or "/groupname/childgroup".
320+
321+After creating the _Client Scope_ named _groups_ you will need to attach it to your client.
322+**Clients** -> `<your client's id>` -> **Client scopes** -> **Add client scope** -> Select **groups** and choose Optional and you should now have a client that maps group memberships into the JWT tokens so that Oauth2 Proxy may evaluate them.
323+
324+Create a group by navigating to **Groups** -> **Create group** and _add_ your test user as a member.
325+
326+The OAuth2 Proxy option `--allowed-group=/groupname` will now allow you to filter on group membership
327+
328+Keycloak also has the option of attaching roles to groups, please refer to the Keycloak documentation for more information.
329+
330+**Tip**
331+
332+To check if roles or groups are added to JWT tokens, you can preview a users token in the Keycloak console by following these steps:
333+**Clients** -> `<your client's id>` -> **Client scopes** -> **Evaluate**.
334+Select a _realm user_ and optional _scope parameters_ such as groups, and generate the JSON representation of an access or id token to examine its contents.
335+
336+
337+### GitLab Auth Provider
338+
339+This auth provider has been tested against Gitlab version 12.X. Due to Gitlab API changes, it may not work for version prior to 12.X (see [994](https://github.com/oauth2-proxy/oauth2-proxy/issues/994)).
340+
341+Whether you are using GitLab.com or self-hosting GitLab, follow [these steps to add an application](https://docs.gitlab.com/ce/integration/oauth_provider.html). Make sure to enable at least the `openid`, `profile` and `email` scopes, and set the redirect url to your application url e.g. https://myapp.com/oauth2/callback.
342+
343+If you need projects filtering, add the extra `read_api` scope to your application.
344+
345+The following config should be set to ensure that the oauth will work properly. To get a cookie secret follow [these steps](./overview.md#generating-a-cookie-secret)
346+
347+```
348+ --provider="gitlab"
349+ --redirect-url="https://myapp.com/oauth2/callback" // Should be the same as the redirect url for the application in gitlab
350+ --client-id=GITLAB_CLIENT_ID
351+ --client-secret=GITLAB_CLIENT_SECRET
352+ --cookie-secret=COOKIE_SECRET
353+```
354+
355+Restricting by group membership is possible with the following option:
356+
357+ --gitlab-group="mygroup,myothergroup": restrict logins to members of any of these groups (slug), separated by a comma
358+
359+If you are using self-hosted GitLab, make sure you set the following to the appropriate URL:
360+
361+ --oidc-issuer-url="<your gitlab url>"
362+
363+If your self-hosted GitLab is on a sub-directory (e.g. domain.tld/gitlab), as opposed to its own sub-domain (e.g. gitlab.domain.tld), you may need to add a redirect from domain.tld/oauth pointing at e.g. domain.tld/gitlab/oauth.
364+
365+### LinkedIn Auth Provider
366+
367+For LinkedIn, the registration steps are:
368+
369+1. Create a new project: https://www.linkedin.com/secure/developer
370+2. In the OAuth User Agreement section:
371+ - In default scope, select r_basicprofile and r_emailaddress.
372+ - In "OAuth 2.0 Redirect URLs", enter `https://internal.yourcompany.com/oauth2/callback`
373+3. Fill in the remaining required fields and Save.
374+4. Take note of the **Consumer Key / API Key** and **Consumer Secret / Secret Key**
375+
376+### Microsoft Azure AD Provider
377+
378+For adding an application to the Microsoft Azure AD follow [these steps to add an application](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app).
379+
380+Take note of your `TenantId` if applicable for your situation. The `TenantId` can be used to override the default `common` authorization server with a tenant specific server.
381+
382+### OpenID Connect Provider
383+
384+OpenID Connect is a spec for OAUTH 2.0 + identity that is implemented by many major providers and several open source projects.
385+
386+This provider was originally built against CoreOS Dex and we will use it as an example.
387+The OpenID Connect Provider (OIDC) can also be used to connect to other Identity Providers such as Okta, an example can be found below.
388+
389+#### Dex
390+
391+To configure the OIDC provider for Dex, perform the following steps:
392+
393+1. Download Dex:
394+
395+ ```
396+ go get github.com/dexidp/dex
397+ ```
398+
399+ See the [getting started guide](https://dexidp.io/docs/getting-started/) for more details.
400+
401+2. Setup oauth2-proxy with the correct provider and using the default ports and callbacks. Add a configuration block to the `staticClients` section of `examples/config-dev.yaml`:
402+
403+ ```
404+ - id: oauth2-proxy
405+ redirectURIs:
406+ - 'http://127.0.0.1:4180/oauth2/callback'
407+ name: 'oauth2-proxy'
408+ secret: proxy
409+ ```
410+
411+3. Launch Dex: from `$GOPATH/github.com/dexidp/dex`, run:
412+
413+ ```
414+ bin/dex serve examples/config-dev.yaml
415+ ```
416+
417+4. In a second terminal, run the oauth2-proxy with the following args:
418+
419+ ```
420+ -provider oidc
421+ -provider-display-name "My OIDC Provider"
422+ -client-id oauth2-proxy
423+ -client-secret proxy
424+ -redirect-url http://127.0.0.1:4180/oauth2/callback
425+ -oidc-issuer-url http://127.0.0.1:5556/dex
426+ -cookie-secure=false
427+ -cookie-secret=secret
428+ -email-domain kilgore.trout
429+ ```
430+
431+ To serve the current working directory as a web site under the `/static` endpoint, add:
432+
433+ ```
434+ -upstream file://$PWD/#/static/
435+ ```
436+
437+5. Test the setup by visiting http://127.0.0.1:4180 or http://127.0.0.1:4180/static .
438+
439+See also [our local testing environment](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/contrib/local-environment) for a self-contained example using Docker and etcd as storage for Dex.
440+
441+#### Okta
442+
443+To configure the OIDC provider for Okta, perform the following steps:
444+
445+1. Log in to Okta using an administrative account. It is suggested you try this in preview first, `example.oktapreview.com`
446+2. (OPTIONAL) If you want to configure authorization scopes and claims to be passed on to multiple applications,
447+you may wish to configure an authorization server for each application. Otherwise, the provided `default` will work.
448+* Navigate to **Security** then select **API**
449+* Click **Add Authorization Server**, if this option is not available you may require an additional license for a custom authorization server.
450+* Fill out the **Name** with something to describe the application you are protecting. e.g. 'Example App'.
451+* For **Audience**, pick the URL of the application you wish to protect: https://example.corp.com
452+* Fill out a **Description**
453+* Add any **Access Policies** you wish to configure to limit application access.
454+* The default settings will work for other options.
455+[See Okta documentation for more information on Authorization Servers](https://developer.okta.com/docs/guides/customize-authz-server/overview/)
456+3. Navigate to **Applications** then select **Add Application**.
457+* Select **Web** for the **Platform** setting.
458+* Select **OpenID Connect** and click **Create**
459+* Pick an **Application Name** such as `Example App`.
460+* Set the **Login redirect URI** to `https://example.corp.com`.
461+* Under **General** set the **Allowed grant types** to `Authorization Code` and `Refresh Token`.
462+* Leave the rest as default, taking note of the `Client ID` and `Client Secret`.
463+* Under **Assignments** select the users or groups you wish to access your application.
464+4. Create a configuration file like the following:
465+
466+ ```
467+ provider = "oidc"
468+ redirect_url = "https://example.corp.com/oauth2/callback"
469+ oidc_issuer_url = "https://corp.okta.com/oauth2/abCd1234"
470+ upstreams = [
471+ "https://example.corp.com"
472+ ]
473+ email_domains = [
474+ "corp.com"
475+ ]
476+ client_id = "XXXXX"
477+ client_secret = "YYYYY"
478+ pass_access_token = true
479+ cookie_secret = "ZZZZZ"
480+ skip_provider_button = true
481+ ```
482+
483+The `oidc_issuer_url` is based on URL from your **Authorization Server**'s **Issuer** field in step 2, or simply https://corp.okta.com .
484+The `client_id` and `client_secret` are configured in the application settings.
485+Generate a unique `cookie_secret` to encrypt the cookie.
486+
487+Then you can start the oauth2-proxy with `./oauth2-proxy --config /etc/example.cfg`
488+
489+#### Okta - localhost
490+
491+1. Signup for developer account: https://developer.okta.com/signup/
492+2. Create New `Web` Application: https://${your-okta-domain}/dev/console/apps/new
493+3. Example Application Settings for localhost:
494+ * **Name:** My Web App
495+ * **Base URIs:** http://localhost:4180/
496+ * **Login redirect URIs:** http://localhost:4180/oauth2/callback
497+ * **Logout redirect URIs:** http://localhost:4180/
498+ * **Group assignments:** `Everyone`
499+ * **Grant type allowed:** `Authorization Code` and `Refresh Token`
500+4. Make note of the `Client ID` and `Client secret`, they are needed in a future step
501+5. Make note of the **default** Authorization Server Issuer URI from: https://${your-okta-domain}/admin/oauth2/as
502+6. Example config file `/etc/localhost.cfg`
503+ ```
504+ provider = "oidc"
505+ redirect_url = "http://localhost:4180/oauth2/callback"
506+ oidc_issuer_url = "https://${your-okta-domain}/oauth2/default"
507+ upstreams = [
508+ "http://0.0.0.0:8080"
509+ ]
510+ email_domains = [
511+ "*"
512+ ]
513+ client_id = "XXX"
514+ client_secret = "YYY"
515+ pass_access_token = true
516+ cookie_secret = "ZZZ"
517+ cookie_secure = false
518+ skip_provider_button = true
519+ # Note: use the following for testing within a container
520+ # http_address = "0.0.0.0:4180"
521+ ```
522+7. Then you can start the oauth2-proxy with `./oauth2-proxy --config /etc/localhost.cfg`
523+
524+### login.gov Provider
525+
526+login.gov is an OIDC provider for the US Government.
527+If you are a US Government agency, you can contact the login.gov team through the contact information
528+that you can find on https://login.gov/developers/ and work with them to understand how to get login.gov
529+accounts for integration/test and production access.
530+
531+A developer guide is available here: https://developers.login.gov/, though this proxy handles everything
532+but the data you need to create to register your application in the login.gov dashboard.
533+
534+As a demo, we will assume that you are running your application that you want to secure locally on
535+http://localhost:3000/, that you will be starting your proxy up on http://localhost:4180/, and that
536+you have an agency integration account for testing.
537+
538+First, register your application in the dashboard. The important bits are:
539+ * Identity protocol: make this `Openid connect`
540+ * Issuer: do what they say for OpenID Connect. We will refer to this string as `${LOGINGOV_ISSUER}`.
541+ * Public key: This is a self-signed certificate in .pem format generated from a 2048 bit RSA private key.
542+ A quick way to do this is `openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 -nodes -subj '/C=US/ST=Washington/L=DC/O=GSA/OU=18F/CN=localhost'`,
543+ The contents of the `key.pem` shall be referred to as `${OAUTH2_PROXY_JWT_KEY}`.
544+ * Return to App URL: Make this be `http://localhost:4180/`
545+ * Redirect URIs: Make this be `http://localhost:4180/oauth2/callback`.
546+ * Attribute Bundle: Make sure that email is selected.
547+
548+Now start the proxy up with the following options:
549+```
550+./oauth2-proxy -provider login.gov \
551+ -client-id=${LOGINGOV_ISSUER} \
552+ -redirect-url=http://localhost:4180/oauth2/callback \
553+ -oidc-issuer-url=https://idp.int.identitysandbox.gov/ \
554+ -cookie-secure=false \
555+ -email-domain=gsa.gov \
556+ -upstream=http://localhost:3000/ \
557+ -cookie-secret=somerandomstring12341234567890AB \
558+ -cookie-domain=localhost \
559+ -skip-provider-button=true \
560+ -pubjwk-url=https://idp.int.identitysandbox.gov/api/openid_connect/certs \
561+ -profile-url=https://idp.int.identitysandbox.gov/api/openid_connect/userinfo \
562+ -jwt-key="${OAUTH2_PROXY_JWT_KEY}"
563+```
564+You can also set all these options with environment variables, for use in cloud/docker environments.
565+One tricky thing that you may encounter is that some cloud environments will pass in environment
566+variables in a docker env-file, which does not allow multiline variables like a PEM file.
567+If you encounter this, then you can create a `jwt_signing_key.pem` file in the top level
568+directory of the repo which contains the key in PEM format and then do your docker build.
569+The docker build process will copy that file into your image which you can then access by
570+setting the `OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem`
571+environment variable, or by setting `--jwt-key-file=/etc/ssl/private/jwt_signing_key.pem` on the commandline.
572+
573+Once it is running, you should be able to go to `http://localhost:4180/` in your browser,
574+get authenticated by the login.gov integration server, and then get proxied on to your
575+application running on `http://localhost:3000/`. In a real deployment, you would secure
576+your application with a firewall or something so that it was only accessible from the
577+proxy, and you would use real hostnames everywhere.
578+
579+#### Skip OIDC discovery
580+
581+Some providers do not support OIDC discovery via their issuer URL, so oauth2-proxy cannot simply grab the authorization, token and jwks URI endpoints from the provider's metadata.
582+
583+In this case, you can set the `--skip-oidc-discovery` option, and supply those required endpoints manually:
584+
585+```
586+ -provider oidc
587+ -client-id oauth2-proxy
588+ -client-secret proxy
589+ -redirect-url http://127.0.0.1:4180/oauth2/callback
590+ -oidc-issuer-url http://127.0.0.1:5556
591+ -skip-oidc-discovery
592+ -login-url http://127.0.0.1:5556/authorize
593+ -redeem-url http://127.0.0.1:5556/token
594+ -oidc-jwks-url http://127.0.0.1:5556/keys
595+ -cookie-secure=false
596+ -email-domain example.com
597+```
598+
599+### Nextcloud Provider
600+
601+The Nextcloud provider allows you to authenticate against users in your
602+Nextcloud instance.
603+
604+When you are using the Nextcloud provider, you must specify the urls via
605+configuration, environment variable, or command line argument. Depending
606+on whether your Nextcloud instance is using pretty urls your urls may be of the
607+form `/index.php/apps/oauth2/*` or `/apps/oauth2/*`.
608+
609+Refer to the [OAuth2
610+documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/oauth2.html)
611+to setup the client id and client secret. Your "Redirection URI" will be
612+`https://internalapp.yourcompany.com/oauth2/callback`.
613+
614+```
615+ -provider nextcloud
616+ -client-id <from nextcloud admin>
617+ -client-secret <from nextcloud admin>
618+ -login-url="<your nextcloud url>/index.php/apps/oauth2/authorize"
619+ -redeem-url="<your nextcloud url>/index.php/apps/oauth2/api/v1/token"
620+ -validate-url="<your nextcloud url>/ocs/v2.php/cloud/user?format=json"
621+```
622+
623+Note: in *all* cases the validate-url will *not* have the `index.php`.
624+
625+### DigitalOcean Auth Provider
626+
627+1. [Create a new OAuth application](https://cloud.digitalocean.com/account/api/applications)
628+ * You can fill in the name, homepage, and description however you wish.
629+ * In the "Application callback URL" field, enter: `https://oauth-proxy/oauth2/callback`, substituting `oauth2-proxy` with the actual hostname that oauth2-proxy is running on. The URL must match oauth2-proxy's configured redirect URL.
630+2. Note the Client ID and Client Secret.
631+
632+To use the provider, pass the following options:
633+
634+```
635+ --provider=digitalocean
636+ --client-id=<Client ID>
637+ --client-secret=<Client Secret>
638+```
639+
640+ Alternatively, set the equivalent options in the config file. The redirect URL defaults to `https://<requested host header>/oauth2/callback`. If you need to change it, you can use the `--redirect-url` command-line option.
641+
642+### Bitbucket Auth Provider
643+
644+1. [Add a new OAuth consumer](https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html)
645+ * In "Callback URL" use `https://<oauth2-proxy>/oauth2/callback`, substituting `<oauth2-proxy>` with the actual hostname that oauth2-proxy is running on.
646+ * In Permissions section select:
647+ * Account -> Email
648+ * Team membership -> Read
649+ * Repositories -> Read
650+2. Note the Client ID and Client Secret.
651+
652+To use the provider, pass the following options:
653+
654+```
655+ --provider=bitbucket
656+ --client-id=<Client ID>
657+ --client-secret=<Client Secret>
658+```
659+
660+The default configuration allows everyone with Bitbucket account to authenticate. To restrict the access to the team members use additional configuration option: `--bitbucket-team=<Team name>`. To restrict the access to only these users who has access to one selected repository use `--bitbucket-repository=<Repository name>`.
661+
662+
663+### Gitea Auth Provider
664+
665+1. Create a new application: `https://< your gitea host >/user/settings/applications`
666+2. Under `Redirect URI` enter the correct URL i.e. `https://<proxied host>/oauth2/callback`
667+3. Note the Client ID and Client Secret.
668+4. Pass the following options to the proxy:
669+
670+```
671+ --provider="github"
672+ --redirect-url="https://<proxied host>/oauth2/callback"
673+ --provider-display-name="Gitea"
674+ --client-id="< client_id as generated by Gitea >"
675+ --client-secret="< client_secret as generated by Gitea >"
676+ --login-url="https://< your gitea host >/login/oauth/authorize"
677+ --redeem-url="https://< your gitea host >/login/oauth/access_token"
678+ --validate-url="https://< your gitea host >/api/v1"
679+```
680+
681+
682+## Email Authentication
683+
684+To authorize by email domain use `--email-domain=yourcompany.com`. To authorize individual email addresses use `--authenticated-emails-file=/path/to/file` with one email per line. To authorize all email addresses use `--email-domain=*`.
685+
686+## Adding a new Provider
687+
688+Follow the examples in the [`providers` package](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/providers/) to define a new
689+`Provider` instance. Add a new `case` to
690+[`providers.New()`](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/providers/providers.go) to allow `oauth2-proxy` to use the
691+new `Provider`.
docs/versioned_docs/version-7.5.x/configuration/overview.mdnew file+605
@@ -0,0 +1,605 @@
1+---
2+id: overview
3+title: Overview
4+---
5+
6+`oauth2-proxy` can be configured via [command line options](#command-line-options), [environment variables](#environment-variables) or [config file](#config-file) (in decreasing order of precedence, i.e. command line options will overwrite environment variables and environment variables will overwrite configuration file settings).
7+
8+### Generating a Cookie Secret
9+
10+To generate a strong cookie secret use one of the below commands:
11+
12+import Tabs from '@theme/Tabs';
13+import TabItem from '@theme/TabItem';
14+
15+<Tabs
16+ defaultValue="python"
17+ values={[
18+ {label: 'Python', value: 'python'},
19+ {label: 'Bash', value: 'bash'},
20+ {label: 'OpenSSL', value: 'openssl'},
21+ {label: 'PowerShell', value: 'powershell'},
22+ {label: 'Terraform', value: 'terraform'},
23+ ]}>
24+ <TabItem value="python">
25+
26+ ```shell
27+ python -c 'import os,base64; print(base64.urlsafe_b64encode(os.urandom(32)).decode())'
28+ ```
29+
30+ </TabItem>
31+ <TabItem value="bash">
32+
33+ ```shell
34+ dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 | tr -d -- '\n' | tr -- '+/' '-_'; echo
35+ ```
36+
37+ </TabItem>
38+ <TabItem value="openssl">
39+
40+ ```shell
41+ openssl rand -base64 32 | tr -- '+/' '-_'
42+ ```
43+
44+ </TabItem>
45+ <TabItem value="powershell">
46+
47+ ```shell
48+ # Add System.Web assembly to session, just in case
49+ Add-Type -AssemblyName System.Web
50+ [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Web.Security.Membership]::GeneratePassword(32,4))).Replace("+","-").Replace("/","_")
51+ ```
52+
53+ </TabItem>
54+ <TabItem value="terraform">
55+
56+ ```shell
57+ # Valid 32 Byte Base64 URL encoding set that will decode to 24 []byte AES-192 secret
58+ resource "random_password" "cookie_secret" {
59+ length = 32
60+ override_special = "-_"
61+ }
62+ ```
63+
64+ </TabItem>
65+</Tabs>
66+
67+### Config File
68+
69+Every command line argument can be specified in a config file by replacing hyphens (-) with underscores (\_). If the argument can be specified multiple times, the config option should be plural (trailing s).
70+
71+An example [oauth2-proxy.cfg](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/contrib/oauth2-proxy.cfg.example) config file is in the contrib directory. It can be used by specifying `--config=/etc/oauth2-proxy.cfg`
72+
73+### Command Line Options
74+
75+| Option | Type | Description | Default |
76+| ------ | ---- | ----------- | ------- |
77+| `--acr-values` | string | optional, see [docs](https://openid.net/specs/openid-connect-eap-acr-values-1_0.html#acrValues) | `""` |
78+| `--api-route` | string \| list | return HTTP 401 instead of redirecting to authentication server if token is not valid. Format: path_regex | |
79+| `--approval-prompt` | string | OAuth approval_prompt | `"force"` |
80+| `--auth-logging` | bool | Log authentication attempts | true |
81+| `--auth-logging-format` | string | Template for authentication log lines | see [Logging Configuration](#logging-configuration) |
82+| `--authenticated-emails-file` | string | authenticate against emails via file (one per line) | |
83+| `--azure-tenant` | string | go to a tenant-specific or common (tenant-independent) endpoint. | `"common"` |
84+| `--basic-auth-password` | string | the password to set when passing the HTTP Basic Auth header | |
85+| `--client-id` | string | the OAuth Client ID, e.g. `"123456.apps.googleusercontent.com"` | |
86+| `--client-secret` | string | the OAuth Client Secret | |
87+| `--client-secret-file` | string | the file with OAuth Client Secret | |
88+| `--code-challenge-method` | string | use PKCE code challenges with the specified method. Either 'plain' or 'S256' (recommended) | |
89+| `--config` | string | path to config file | |
90+| `--cookie-domain` | string \| list | Optional cookie domains to force cookies to (e.g. `.yourcompany.com`). The longest domain matching the request's host will be used (or the shortest cookie domain if there is no match). | |
91+| `--cookie-expire` | duration | expire timeframe for cookie. If set to 0, cookie becomes a session-cookie which will expire when the browser is closed. | 168h0m0s |
92+| `--cookie-httponly` | bool | set HttpOnly cookie flag | true |
93+| `--cookie-name` | string | the name of the cookie that the oauth_proxy creates. Should be changed to use a [cookie prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#cookie_prefixes) (`__Host-` or `__Secure-`) if `--cookie-secure` is set. | `"_oauth2_proxy"` |
94+| `--cookie-path` | string | an optional cookie path to force cookies to (e.g. `/poc/`) | `"/"` |
95+| `--cookie-refresh` | duration | refresh the cookie after this duration; `0` to disable; not supported by all providers&nbsp;\[[1](#footnote1)\] | |
96+| `--cookie-secret` | string | the seed string for secure cookies (optionally base64 encoded) | |
97+| `--cookie-secure` | bool | set [secure (HTTPS only) cookie flag](https://owasp.org/www-community/controls/SecureFlag) | true |
98+| `--cookie-samesite` | string | set SameSite cookie attribute (`"lax"`, `"strict"`, `"none"`, or `""`). | `""` |
99+| `--cookie-csrf-per-request` | bool | Enable having different CSRF cookies per request, making it possible to have parallel requests. | false |
100+| `--cookie-csrf-expire` | duration | expire timeframe for CSRF cookie | 15m |
101+| `--custom-templates-dir` | string | path to custom html templates | |
102+| `--custom-sign-in-logo` | string | path or a URL to an custom image for the sign_in page logo. Use `"-"` to disable default logo. |
103+| `--display-htpasswd-form` | bool | display username / password login form if an htpasswd file is provided | true |
104+| `--email-domain` | string \| list | authenticate emails with the specified domain (may be given multiple times). Use `*` to authenticate any email | |
105+| `--errors-to-info-log` | bool | redirects error-level logging to default log channel instead of stderr | false |
106+| `--extra-jwt-issuers` | string | if `--skip-jwt-bearer-tokens` is set, a list of extra JWT `issuer=audience` (see a token's `iss`, `aud` fields) pairs (where the issuer URL has a `.well-known/openid-configuration` or a `.well-known/jwks.json`) | |
107+| `--exclude-logging-path` | string | comma separated list of paths to exclude from logging, e.g. `"/ping,/path2"` |`""` (no paths excluded) |
108+| `--flush-interval` | duration | period between flushing response buffers when streaming responses | `"1s"` |
109+| `--force-https` | bool | enforce https redirect | `false` |
110+| `--force-json-errors` | bool | force JSON errors instead of HTTP error pages or redirects | `false` |
111+| `--banner` | string | custom (html) banner string. Use `"-"` to disable default banner. | |
112+| `--footer` | string | custom (html) footer string. Use `"-"` to disable default footer. | |
113+| `--github-org` | string | restrict logins to members of this organisation | |
114+| `--github-team` | string | restrict logins to members of any of these teams (slug), separated by a comma | |
115+| `--github-repo` | string | restrict logins to collaborators of this repository formatted as `orgname/repo` | |
116+| `--github-token` | string | the token to use when verifying repository collaborators (must have push access to the repository) | |
117+| `--github-user` | string \| list | To allow users to login by username even if they do not belong to the specified org and team or collaborators | |
118+| `--gitlab-group` | string \| list | restrict logins to members of any of these groups (slug), separated by a comma | |
119+| `--gitlab-projects` | string \| list | restrict logins to members of any of these projects (may be given multiple times) formatted as `orgname/repo=accesslevel`. Access level should be a value matching [Gitlab access levels](https://docs.gitlab.com/ee/api/members.html#valid-access-levels), defaulted to 20 if absent | |
120+| `--google-admin-email` | string | the google admin to impersonate for api calls | |
121+| `--google-group` | string | restrict logins to members of this google group (may be given multiple times). | |
122+| `--google-service-account-json` | string | the path to the service account json credentials | |
123+| `--google-use-application-default-credentials` | bool | use application default credentials instead of service account json (i.e. GKE Workload Identity) | |
124+| `--htpasswd-file` | string | additionally authenticate against a htpasswd file. Entries must be created with `htpasswd -B` for bcrypt encryption | |
125+| `--htpasswd-user-group` | string \| list | the groups to be set on sessions for htpasswd users | |
126+| `--http-address` | string | `[http://]<addr>:<port>` or `unix://<path>` to listen on for HTTP clients. Square brackets are required for ipv6 address, e.g. `http://[::1]:4180` | `"127.0.0.1:4180"` |
127+| `--https-address` | string | `[https://]<addr>:<port>` to listen on for HTTPS clients. Square brackets are required for ipv6 address, e.g. `https://[::1]:443` | `":443"` |
128+| `--logging-compress` | bool | Should rotated log files be compressed using gzip | false |
129+| `--logging-filename` | string | File to log requests to, empty for `stdout` | `""` (stdout) |
130+| `--logging-local-time` | bool | Use local time in log files and backup filenames instead of UTC | true (local time) |
131+| `--logging-max-age` | int | Maximum number of days to retain old log files | 7 |
132+| `--logging-max-backups` | int | Maximum number of old log files to retain; 0 to disable | 0 |
133+| `--logging-max-size` | int | Maximum size in megabytes of the log file before rotation | 100 |
134+| `--jwt-key` | string | private key in PEM format used to sign JWT, so that you can say something like `--jwt-key="${OAUTH2_PROXY_JWT_KEY}"`: required by login.gov | |
135+| `--jwt-key-file` | string | path to the private key file in PEM format used to sign the JWT so that you can say something like `--jwt-key-file=/etc/ssl/private/jwt_signing_key.pem`: required by login.gov | |
136+| `--login-url` | string | Authentication endpoint | |
137+| `--insecure-oidc-allow-unverified-email` | bool | don't fail if an email address in an id_token is not verified | false |
138+| `--insecure-oidc-skip-issuer-verification` | bool | allow the OIDC issuer URL to differ from the expected (currently required for Azure multi-tenant compatibility) | false |
139+| `--insecure-oidc-skip-nonce` | bool | skip verifying the OIDC ID Token's nonce claim | true |
140+| `--oidc-issuer-url` | string | the OpenID Connect issuer URL, e.g. `"https://accounts.google.com"` | |
141+| `--oidc-jwks-url` | string | OIDC JWKS URI for token verification; required if OIDC discovery is disabled | |
142+| `--oidc-email-claim` | string | which OIDC claim contains the user's email | `"email"` |
143+| `--oidc-groups-claim` | string | which OIDC claim contains the user groups | `"groups"` |
144+| `--oidc-audience-claim` | string | which OIDC claim contains the audience | `"aud"` |
145+| `--oidc-extra-audience` | string \| list | additional audiences which are allowed to pass verification | `"[]"` |
146+| `--pass-access-token` | bool | pass OAuth access_token to upstream via X-Forwarded-Access-Token header. When used with `--set-xauthrequest` this adds the X-Auth-Request-Access-Token header to the response | false |
147+| `--pass-authorization-header` | bool | pass OIDC IDToken to upstream via Authorization Bearer header | false |
148+| `--pass-basic-auth` | bool | pass HTTP Basic Auth, X-Forwarded-User, X-Forwarded-Email and X-Forwarded-Preferred-Username information to upstream | true |
149+| `--prefer-email-to-user` | bool | Prefer to use the Email address as the Username when passing information to upstream. Will only use Username if Email is unavailable, e.g. htaccess authentication. Used in conjunction with `--pass-basic-auth` and `--pass-user-headers` | false |
150+| `--pass-host-header` | bool | pass the request Host Header to upstream | true |
151+| `--pass-user-headers` | bool | pass X-Forwarded-User, X-Forwarded-Groups, X-Forwarded-Email and X-Forwarded-Preferred-Username information to upstream | true |
152+| `--profile-url` | string | Profile access endpoint | |
153+| `--prompt` | string | [OIDC prompt](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest); if present, `approval-prompt` is ignored | `""` |
154+| `--provider` | string | OAuth provider | google |
155+| `--provider-ca-file` | string \| list | Paths to CA certificates that should be used when connecting to the provider. If not specified, the default Go trust sources are used instead. |
156+| `--provider-display-name` | string | Override the provider's name with the given string; used for the sign-in page | (depends on provider) |
157+| `--ping-path` | string | the ping endpoint that can be used for basic health checks | `"/ping"` |
158+| `--ping-user-agent` | string | a User-Agent that can be used for basic health checks | `""` (don't check user agent) |
159+| `--ready-path` | string | the ready endpoint that can be used for deep health checks | `"/ready"` |
160+| `--metrics-address` | string | the address prometheus metrics will be scraped from | `""` |
161+| `--proxy-prefix` | string | the url root path that this proxy should be nested under (e.g. /`<oauth2>/sign_in`) | `"/oauth2"` |
162+| `--proxy-websockets` | bool | enables WebSocket proxying | true |
163+| `--pubjwk-url` | string | JWK pubkey access endpoint: required by login.gov | |
164+| `--real-client-ip-header` | string | Header used to determine the real IP of the client, requires `--reverse-proxy` to be set (one of: X-Forwarded-For, X-Real-IP, or X-ProxyUser-IP) | X-Real-IP |
165+| `--redeem-url` | string | Token redemption endpoint | |
166+| `--redirect-url` | string | the OAuth Redirect URL, e.g. `"https://internalapp.yourcompany.com/oauth2/callback"` | |
167+| `--redis-cluster-connection-urls` | string \| list | List of Redis cluster connection URLs (e.g. `redis://HOST[:PORT]`). Used in conjunction with `--redis-use-cluster` | |
168+| `--redis-connection-url` | string | URL of redis server for redis session storage (e.g. `redis://HOST[:PORT]`) | |
169+| `--redis-insecure-skip-tls-verify` | bool | skip TLS verification when connecting to Redis | false |
170+| `--redis-password` | string | Redis password. Applicable for all Redis configurations. Will override any password set in `--redis-connection-url` | |
171+| `--redis-sentinel-password` | string | Redis sentinel password. Used only for sentinel connection; any redis node passwords need to use `--redis-password` | |
172+| `--redis-sentinel-master-name` | string | Redis sentinel master name. Used in conjunction with `--redis-use-sentinel` | |
173+| `--redis-sentinel-connection-urls` | string \| list | List of Redis sentinel connection URLs (e.g. `redis://HOST[:PORT]`). Used in conjunction with `--redis-use-sentinel` | |
174+| `--redis-use-cluster` | bool | Connect to redis cluster. Must set `--redis-cluster-connection-urls` to use this feature | false |
175+| `--redis-use-sentinel` | bool | Connect to redis via sentinels. Must set `--redis-sentinel-master-name` and `--redis-sentinel-connection-urls` to use this feature | false |
176+| `--redis-connection-idle-timeout` | int | Redis connection idle timeout seconds. If Redis [timeout](https://redis.io/docs/reference/clients/#client-timeouts) option is set to non-zero, the `--redis-connection-idle-timeout` must be less than Redis timeout option. Exmpale: if either redis.conf includes `timeout 15` or using `CONFIG SET timeout 15` the `--redis-connection-idle-timeout` must be at least `--redis-connection-idle-timeout=14` | 0 |
177+| `--request-id-header` | string | Request header to use as the request ID in logging | X-Request-Id |
178+| `--request-logging` | bool | Log requests | true |
179+| `--request-logging-format` | string | Template for request log lines | see [Logging Configuration](#logging-configuration) |
180+| `--resource` | string | The resource that is protected (Azure AD only) | |
181+| `--reverse-proxy` | bool | are we running behind a reverse proxy, controls whether headers like X-Real-IP are accepted and allows X-Forwarded-{Proto,Host,Uri} headers to be used on redirect selection | false |
182+| `--scope` | string | OAuth scope specification | |
183+| `--session-cookie-minimal` | bool | strip OAuth tokens from cookie session stores if they aren't needed (cookie session store only) | false |
184+| `--session-store-type` | string | [Session data storage backend](sessions.md); redis or cookie | cookie |
185+| `--set-xauthrequest` | bool | set X-Auth-Request-User, X-Auth-Request-Groups, X-Auth-Request-Email and X-Auth-Request-Preferred-Username response headers (useful in Nginx auth_request mode). When used with `--pass-access-token`, X-Auth-Request-Access-Token is added to response headers. | false |
186+| `--set-authorization-header` | bool | set Authorization Bearer response header (useful in Nginx auth_request mode) | false |
187+| `--set-basic-auth` | bool | set HTTP Basic Auth information in response (useful in Nginx auth_request mode) | false |
188+| `--show-debug-on-error` | bool | show detailed error information on error pages (WARNING: this may contain sensitive information - do not use in production) | false |
189+| `--signature-key` | string | GAP-Signature request signature key (algorithm:secretkey) | |
190+| `--silence-ping-logging` | bool | disable logging of requests to ping & ready endpoints | false |
191+| `--skip-auth-preflight` | bool | will skip authentication for OPTIONS requests | false |
192+| `--skip-auth-regex` | string \| list | (DEPRECATED for `--skip-auth-route`) bypass authentication for requests paths that match (may be given multiple times) | |
193+| `--skip-auth-route` | string \| list | bypass authentication for requests that match the method & path. Format: method=path_regex OR method!=path_regex. For all methods: path_regex OR !=path_regex | |
194+| `--skip-auth-strip-headers` | bool | strips `X-Forwarded-*` style authentication headers & `Authorization` header if they would be set by oauth2-proxy | true |
195+| `--skip-jwt-bearer-tokens` | bool | will skip requests that have verified JWT bearer tokens (the token must have [`aud`](https://en.wikipedia.org/wiki/JSON_Web_Token#Standard_fields) that matches this client id or one of the extras from `extra-jwt-issuers`) | false |
196+| `--skip-oidc-discovery` | bool | bypass OIDC endpoint discovery. `--login-url`, `--redeem-url` and `--oidc-jwks-url` must be configured in this case | false |
197+| `--skip-provider-button` | bool | will skip sign-in-page to directly reach the next step: oauth/start | false |
198+| `--ssl-insecure-skip-verify` | bool | skip validation of certificates presented when using HTTPS providers | false |
199+| `--ssl-upstream-insecure-skip-verify` | bool | skip validation of certificates presented when using HTTPS upstreams | false |
200+| `--standard-logging` | bool | Log standard runtime information | true |
201+| `--standard-logging-format` | string | Template for standard log lines | see [Logging Configuration](#logging-configuration) |
202+| `--tls-cert-file` | string | path to certificate file | |
203+| `--tls-cipher-suite` | string \| list | Restricts TLS cipher suites used by server to those listed (e.g. TLS_RSA_WITH_RC4_128_SHA) (may be given multiple times). If not specified, the default Go safe cipher list is used. List of valid cipher suites can be found in the [crypto/tls documentation](https://pkg.go.dev/crypto/tls#pkg-constants). | |
204+| `--tls-key-file` | string | path to private key file | |
205+| `--tls-min-version` | string | minimum TLS version that is acceptable, either `"TLS1.2"` or `"TLS1.3"` | `"TLS1.2"` |
206+| `--upstream` | string \| list | the http url(s) of the upstream endpoint, file:// paths for static files or `static://<status_code>` for static response. Routing is based on the path | |
207+| `--upstream-timeout` | duration | maximum amount of time the server will wait for a response from the upstream | 30s |
208+| `--allowed-group` | string \| list | restrict logins to members of this group (may be given multiple times) | |
209+| `--allowed-role` | string \| list | restrict logins to users with this role (may be given multiple times). Only works with the keycloak-oidc provider. | |
210+| `--validate-url` | string | Access token validation endpoint | |
211+| `--version` | n/a | print version string | |
212+| `--whitelist-domain` | string \| list | allowed domains for redirection after authentication. Prefix domain with a `.` or a `*.` to allow subdomains (e.g. `.example.com`, `*.example.com`)&nbsp;\[[2](#footnote2)\] | |
213+| `--trusted-ip` | string \| list | list of IPs or CIDR ranges to allow to bypass authentication (may be given multiple times). When combined with `--reverse-proxy` and optionally `--real-client-ip-header` this will evaluate the trust of the IP stored in an HTTP header by a reverse proxy rather than the layer-3/4 remote address. WARNING: trusting IPs has inherent security flaws, especially when obtaining the IP address from an HTTP header (reverse-proxy mode). Use this option only if you understand the risks and how to manage them. | |
214+
215+\[<a name="footnote1">1</a>\]: Only these providers support `--cookie-refresh`: GitLab, Google and OIDC
216+
217+\[<a name="footnote2">2</a>\]: When using the `whitelist-domain` option, any domain prefixed with a `.` or a `*.` will allow any subdomain of the specified domain as a valid redirect URL. By default, only empty ports are allowed. This translates to allowing the default port of the URL's protocol (80 for HTTP, 443 for HTTPS, etc.) since browsers omit them. To allow only a specific port, add it to the whitelisted domain: `example.com:8080`. To allow any port, use `*`: `example.com:*`.
218+
219+See below for provider specific options
220+
221+### Upstreams Configuration
222+
223+`oauth2-proxy` supports having multiple upstreams, and has the option to pass requests on to HTTP(S) servers or serve static files from the file system. HTTP and HTTPS upstreams are configured by providing a URL such as `http://127.0.0.1:8080/` for the upstream parameter. This will forward all authenticated requests to the upstream server. If you instead provide `http://127.0.0.1:8080/some/path/` then it will only be requests that start with `/some/path/` which are forwarded to the upstream.
224+
225+Static file paths are configured as a file:// URL. `file:///var/www/static/` will serve the files from that directory at `http://[oauth2-proxy url]/var/www/static/`, which may not be what you want. You can provide the path to where the files should be available by adding a fragment to the configured URL. The value of the fragment will then be used to specify which path the files are available at, e.g. `file:///var/www/static/#/static/` will make `/var/www/static/` available at `http://[oauth2-proxy url]/static/`.
226+
227+Multiple upstreams can either be configured by supplying a comma separated list to the `--upstream` parameter, supplying the parameter multiple times or providing a list in the [config file](#config-file). When multiple upstreams are used routing to them will be based on the path they are set up with.
228+
229+### Environment variables
230+
231+Every command line argument can be specified as an environment variable by
232+prefixing it with `OAUTH2_PROXY_`, capitalising it, and replacing hyphens (`-`)
233+with underscores (`_`). If the argument can be specified multiple times, the
234+environment variable should be plural (trailing `S`).
235+
236+This is particularly useful for storing secrets outside of a configuration file
237+or the command line.
238+
239+For example, the `--cookie-secret` flag becomes `OAUTH2_PROXY_COOKIE_SECRET`,
240+and the `--email-domain` flag becomes `OAUTH2_PROXY_EMAIL_DOMAINS`.
241+
242+## Logging Configuration
243+
244+By default, OAuth2 Proxy logs all output to stdout. Logging can be configured to output to a rotating log file using the `--logging-filename` command.
245+
246+If logging to a file you can also configure the maximum file size (`--logging-max-size`), age (`--logging-max-age`), max backup logs (`--logging-max-backups`), and if backup logs should be compressed (`--logging-compress`).
247+
248+There are three different types of logging: standard, authentication, and HTTP requests. These can each be enabled or disabled with `--standard-logging`, `--auth-logging`, and `--request-logging`.
249+
250+Each type of logging has its own configurable format and variables. By default these formats are similar to the Apache Combined Log.
251+
252+Logging of requests to the `/ping` endpoint (or using `--ping-user-agent`) and the `/ready` endpoint can be disabled with `--silence-ping-logging` reducing log volume.
253+
254+### Auth Log Format
255+Authentication logs are logs which are guaranteed to contain a username or email address of a user attempting to authenticate. These logs are output by default in the below format:
256+
257+```
258+<REMOTE_ADDRESS> - <REQUEST ID> - <user@domain.com> [19/Mar/2015:17:20:19 -0400] [<STATUS>] <MESSAGE>
259+```
260+
261+The status block will contain one of the below strings:
262+
263+- `AuthSuccess` If a user has authenticated successfully by any method
264+- `AuthFailure` If the user failed to authenticate explicitly
265+- `AuthError` If there was an unexpected error during authentication
266+
267+If you require a different format than that, you can configure it with the `--auth-logging-format` flag.
268+The default format is configured as follows:
269+
270+```
271+{{.Client}} - {{.RequestID}} - {{.Username}} [{{.Timestamp}}] [{{.Status}}] {{.Message}}
272+```
273+
274+Available variables for auth logging:
275+
276+| Variable | Example | Description |
277+| --- | --- | --- |
278+| Client | 74.125.224.72 | The client/remote IP address. Will use the X-Real-IP header it if exists & reverse-proxy is set to true. |
279+| Host | domain.com | The value of the Host header. |
280+| Message | Authenticated via OAuth2 | The details of the auth attempt. |
281+| Protocol | HTTP/1.0 | The request protocol. |
282+| RequestID | 00010203-0405-4607-8809-0a0b0c0d0e0f | The request ID pulled from the `--request-id-header`. Random UUID if empty |
283+| RequestMethod | GET | The request method. |
284+| Timestamp | 19/Mar/2015:17:20:19 -0400 | The date and time of the logging event. |
285+| UserAgent | - | The full user agent as reported by the requesting client. |
286+| Username | username@email.com | The email or username of the auth request. |
287+| Status | AuthSuccess | The status of the auth request. See above for details. |
288+
289+### Request Log Format
290+HTTP request logs will output by default in the below format:
291+
292+```
293+<REMOTE_ADDRESS> - <REQUEST ID> - <user@domain.com> [19/Mar/2015:17:20:19 -0400] <HOST_HEADER> GET <UPSTREAM_HOST> "/path/" HTTP/1.1 "<USER_AGENT>" <RESPONSE_CODE> <RESPONSE_BYTES> <REQUEST_DURATION>
294+```
295+
296+If you require a different format than that, you can configure it with the `--request-logging-format` flag.
297+The default format is configured as follows:
298+
299+```
300+{{.Client}} - {{.RequestID}} - {{.Username}} [{{.Timestamp}}] {{.Host}} {{.RequestMethod}} {{.Upstream}} {{.RequestURI}} {{.Protocol}} {{.UserAgent}} {{.StatusCode}} {{.ResponseSize}} {{.RequestDuration}}
301+```
302+
303+Available variables for request logging:
304+
305+| Variable | Example | Description |
306+| --- | --- | --- |
307+| Client | 74.125.224.72 | The client/remote IP address. Will use the X-Real-IP header it if exists & reverse-proxy is set to true. |
308+| Host | domain.com | The value of the Host header. |
309+| Protocol | HTTP/1.0 | The request protocol. |
310+| RequestDuration | 0.001 | The time in seconds that a request took to process. |
311+| RequestID | 00010203-0405-4607-8809-0a0b0c0d0e0f | The request ID pulled from the `--request-id-header`. Random UUID if empty |
312+| RequestMethod | GET | The request method. |
313+| RequestURI | "/oauth2/auth" | The URI path of the request. |
314+| ResponseSize | 12 | The size in bytes of the response. |
315+| StatusCode | 200 | The HTTP status code of the response. |
316+| Timestamp | 19/Mar/2015:17:20:19 -0400 | The date and time of the logging event. |
317+| Upstream | - | The upstream data of the HTTP request. |
318+| UserAgent | - | The full user agent as reported by the requesting client. |
319+| Username | username@email.com | The email or username of the auth request. |
320+
321+### Standard Log Format
322+All other logging that is not covered by the above two types of logging will be output in this standard logging format. This includes configuration information at startup and errors that occur outside of a session. The default format is below:
323+
324+```
325+[19/Mar/2015:17:20:19 -0400] [main.go:40] <MESSAGE>
326+```
327+
328+If you require a different format than that, you can configure it with the `--standard-logging-format` flag. The default format is configured as follows:
329+
330+```
331+[{{.Timestamp}}] [{{.File}}] {{.Message}}
332+```
333+
334+Available variables for standard logging:
335+
336+| Variable | Example | Description |
337+| --- | --- | --- |
338+| Timestamp | 19/Mar/2015:17:20:19 -0400 | The date and time of the logging event. |
339+| File | main.go:40 | The file and line number of the logging statement. |
340+| Message | HTTP: listening on 127.0.0.1:4180 | The details of the log statement. |
341+
342+## Configuring for use with the Nginx `auth_request` directive
343+
344+The [Nginx `auth_request` directive](http://nginx.org/en/docs/http/ngx_http_auth_request_module.html) allows Nginx to authenticate requests via the oauth2-proxy's `/auth` endpoint, which only returns a 202 Accepted response or a 401 Unauthorized response without proxying the request through. For example:
345+
346+```nginx
347+server {
348+ listen 443 ssl;
349+ server_name ...;
350+ include ssl/ssl.conf;
351+
352+ location /oauth2/ {
353+ proxy_pass http://127.0.0.1:4180;
354+ proxy_set_header Host $host;
355+ proxy_set_header X-Real-IP $remote_addr;
356+ proxy_set_header X-Scheme $scheme;
357+ proxy_set_header X-Auth-Request-Redirect $request_uri;
358+ # or, if you are handling multiple domains:
359+ # proxy_set_header X-Auth-Request-Redirect $scheme://$host$request_uri;
360+ }
361+ location = /oauth2/auth {
362+ proxy_pass http://127.0.0.1:4180;
363+ proxy_set_header Host $host;
364+ proxy_set_header X-Real-IP $remote_addr;
365+ proxy_set_header X-Scheme $scheme;
366+ # nginx auth_request includes headers but not body
367+ proxy_set_header Content-Length "";
368+ proxy_pass_request_body off;
369+ }
370+
371+ location / {
372+ auth_request /oauth2/auth;
373+ error_page 401 = /oauth2/sign_in;
374+
375+ # pass information via X-User and X-Email headers to backend,
376+ # requires running with --set-xauthrequest flag
377+ auth_request_set $user $upstream_http_x_auth_request_user;
378+ auth_request_set $email $upstream_http_x_auth_request_email;
379+ proxy_set_header X-User $user;
380+ proxy_set_header X-Email $email;
381+
382+ # if you enabled --pass-access-token, this will pass the token to the backend
383+ auth_request_set $token $upstream_http_x_auth_request_access_token;
384+ proxy_set_header X-Access-Token $token;
385+
386+ # if you enabled --cookie-refresh, this is needed for it to work with auth_request
387+ auth_request_set $auth_cookie $upstream_http_set_cookie;
388+ add_header Set-Cookie $auth_cookie;
389+
390+ # When using the --set-authorization-header flag, some provider's cookies can exceed the 4kb
391+ # limit and so the OAuth2 Proxy splits these into multiple parts.
392+ # Nginx normally only copies the first `Set-Cookie` header from the auth_request to the response,
393+ # so if your cookies are larger than 4kb, you will need to extract additional cookies manually.
394+ auth_request_set $auth_cookie_name_upstream_1 $upstream_cookie_auth_cookie_name_1;
395+
396+ # Extract the Cookie attributes from the first Set-Cookie header and append them
397+ # to the second part ($upstream_cookie_* variables only contain the raw cookie content)
398+ if ($auth_cookie ~* "(; .*)") {
399+ set $auth_cookie_name_0 $auth_cookie;
400+ set $auth_cookie_name_1 "auth_cookie_name_1=$auth_cookie_name_upstream_1$1";
401+ }
402+
403+ # Send both Set-Cookie headers now if there was a second part
404+ if ($auth_cookie_name_upstream_1) {
405+ add_header Set-Cookie $auth_cookie_name_0;
406+ add_header Set-Cookie $auth_cookie_name_1;
407+ }
408+
409+ proxy_pass http://backend/;
410+ # or "root /path/to/site;" or "fastcgi_pass ..." etc
411+ }
412+}
413+```
414+
415+When you use ingress-nginx in Kubernetes, you MUST use `kubernetes/ingress-nginx` (which includes the Lua module) and the following configuration snippet for your `Ingress`.
416+Variables set with `auth_request_set` are not `set`-able in plain nginx config when the location is processed via `proxy_pass` and then may only be processed by Lua.
417+Note that `nginxinc/kubernetes-ingress` does not include the Lua module.
418+
419+```yaml
420+nginx.ingress.kubernetes.io/auth-response-headers: Authorization
421+nginx.ingress.kubernetes.io/auth-signin: https://$host/oauth2/start?rd=$escaped_request_uri
422+nginx.ingress.kubernetes.io/auth-url: https://$host/oauth2/auth
423+nginx.ingress.kubernetes.io/configuration-snippet: |
424+ auth_request_set $name_upstream_1 $upstream_cookie_name_1;
425+
426+ access_by_lua_block {
427+ if ngx.var.name_upstream_1 ~= "" then
428+ ngx.header["Set-Cookie"] = "name_1=" .. ngx.var.name_upstream_1 .. ngx.var.auth_cookie:match("(; .*)")
429+ end
430+ }
431+```
432+It is recommended to use `--session-store-type=redis` when expecting large sessions/OIDC tokens (_e.g._ with MS Azure).
433+
434+You have to substitute *name* with the actual cookie name you configured via --cookie-name parameter. If you don't set a custom cookie name the variable should be "$upstream_cookie__oauth2_proxy_1" instead of "$upstream_cookie_name_1" and the new cookie-name should be "_oauth2_proxy_1=" instead of "name_1=".
435+
436+## Configuring for use with the Traefik (v2) `ForwardAuth` middleware
437+
438+**This option requires `--reverse-proxy` option to be set.**
439+
440+### ForwardAuth with 401 errors middleware
441+
442+The [Traefik v2 `ForwardAuth` middleware](https://doc.traefik.io/traefik/middlewares/forwardauth/) allows Traefik to authenticate requests via the oauth2-proxy's `/oauth2/auth` endpoint on every request, which only returns a 202 Accepted response or a 401 Unauthorized response without proxying the whole request through. For example, on Dynamic File (YAML) Configuration:
443+
444+```yaml
445+http:
446+ routers:
447+ a-service:
448+ rule: "Host(`a-service.example.com`)"
449+ service: a-service-backend
450+ middlewares:
451+ - oauth-errors
452+ - oauth-auth
453+ tls:
454+ certResolver: default
455+ domains:
456+ - main: "example.com"
457+ sans:
458+ - "*.example.com"
459+ oauth:
460+ rule: "Host(`a-service.example.com`, `oauth.example.com`) && PathPrefix(`/oauth2/`)"
461+ middlewares:
462+ - auth-headers
463+ service: oauth-backend
464+ tls:
465+ certResolver: default
466+ domains:
467+ - main: "example.com"
468+ sans:
469+ - "*.example.com"
470+
471+ services:
472+ a-service-backend:
473+ loadBalancer:
474+ servers:
475+ - url: http://172.16.0.2:7555
476+ oauth-backend:
477+ loadBalancer:
478+ servers:
479+ - url: http://172.16.0.1:4180
480+
481+ middlewares:
482+ auth-headers:
483+ headers:
484+ sslRedirect: true
485+ stsSeconds: 315360000
486+ browserXssFilter: true
487+ contentTypeNosniff: true
488+ forceSTSHeader: true
489+ sslHost: example.com
490+ stsIncludeSubdomains: true
491+ stsPreload: true
492+ frameDeny: true
493+ oauth-auth:
494+ forwardAuth:
495+ address: https://oauth.example.com/oauth2/auth
496+ trustForwardHeader: true
497+ oauth-errors:
498+ errors:
499+ status:
500+ - "401-403"
501+ service: oauth-backend
502+ query: "/oauth2/sign_in"
503+```
504+
505+### ForwardAuth with static upstreams configuration
506+
507+Redirect to sign_in functionality provided without the use of `errors` middleware with [Traefik v2 `ForwardAuth` middleware](https://doc.traefik.io/traefik/middlewares/forwardauth/) pointing to oauth2-proxy service's `/` endpoint
508+
509+**Following options need to be set on `oauth2-proxy`:**
510+- `--upstream=static://202`: Configures a static response for authenticated sessions
511+- `--reverse-proxy=true`: Enables the use of `X-Forwarded-*` headers to determine redirects correctly
512+
513+```yaml
514+http:
515+ routers:
516+ a-service-route-1:
517+ rule: "Host(`a-service.example.com`, `b-service.example.com`) && PathPrefix(`/`)"
518+ service: a-service-backend
519+ middlewares:
520+ - oauth-auth-redirect # redirects all unauthenticated to oauth2 signin
521+ tls:
522+ certResolver: default
523+ domains:
524+ - main: "example.com"
525+ sans:
526+ - "*.example.com"
527+ a-service-route-2:
528+ rule: "Host(`a-service.example.com`) && PathPrefix(`/no-auto-redirect`)"
529+ service: a-service-backend
530+ middlewares:
531+ - oauth-auth-wo-redirect # unauthenticated session will return a 401
532+ tls:
533+ certResolver: default
534+ domains:
535+ - main: "example.com"
536+ sans:
537+ - "*.example.com"
538+ services-oauth2-route:
539+ rule: "Host(`a-service.example.com`, `b-service.example.com`) && PathPrefix(`/oauth2/`)"
540+ middlewares:
541+ - auth-headers
542+ service: oauth-backend
543+ tls:
544+ certResolver: default
545+ domains:
546+ - main: "example.com"
547+ sans:
548+ - "*.example.com"
549+ oauth2-proxy-route:
550+ rule: "Host(`oauth.example.com`) && PathPrefix(`/`)"
551+ middlewares:
552+ - auth-headers
553+ service: oauth-backend
554+ tls:
555+ certResolver: default
556+ domains:
557+ - main: "example.com"
558+ sans:
559+ - "*.example.com"
560+
561+ services:
562+ a-service-backend:
563+ loadBalancer:
564+ servers:
565+ - url: http://172.16.0.2:7555
566+ b-service-backend:
567+ loadBalancer:
568+ servers:
569+ - url: http://172.16.0.3:7555
570+ oauth-backend:
571+ loadBalancer:
572+ servers:
573+ - url: http://172.16.0.1:4180
574+
575+ middlewares:
576+ auth-headers:
577+ headers:
578+ sslRedirect: true
579+ stsSeconds: 315360000
580+ browserXssFilter: true
581+ contentTypeNosniff: true
582+ forceSTSHeader: true
583+ sslHost: example.com
584+ stsIncludeSubdomains: true
585+ stsPreload: true
586+ frameDeny: true
587+ oauth-auth-redirect:
588+ forwardAuth:
589+ address: https://oauth.example.com/
590+ trustForwardHeader: true
591+ authResponseHeaders:
592+ - X-Auth-Request-Access-Token
593+ - Authorization
594+ oauth-auth-wo-redirect:
595+ forwardAuth:
596+ address: https://oauth.example.com/oauth2/auth
597+ trustForwardHeader: true
598+ authResponseHeaders:
599+ - X-Auth-Request-Access-Token
600+ - Authorization
601+```
602+
603+:::note
604+If you set up your OAuth2 provider to rotate your client secret, you can use the `client-secret-file` option to reload the secret when it is updated.
605+:::
docs/versioned_docs/version-7.5.x/configuration/sessions.mdnew file+71
@@ -0,0 +1,71 @@
1+---
2+id: session_storage
3+title: Session Storage
4+---
5+
6+Sessions allow a user's authentication to be tracked between multiple HTTP
7+requests to a service.
8+
9+The OAuth2 Proxy uses a Cookie to track user sessions and will store the session
10+data in one of the available session storage backends.
11+
12+At present the available backends are (as passed to `--session-store-type`):
13+- [cookie](#cookie-storage) (default)
14+- [redis](#redis-storage)
15+
16+### Cookie Storage
17+
18+The Cookie storage backend is the default backend implementation and has
19+been used in the OAuth2 Proxy historically.
20+
21+With the Cookie storage backend, all session information is stored in client
22+side cookies and transferred with each and every request.
23+
24+The following should be known when using this implementation:
25+- Since all state is stored client side, this storage backend means that the OAuth2 Proxy is completely stateless
26+- Cookies are signed server side to prevent modification client-side
27+- It is mandatory to set a `cookie-secret` which will ensure data is encrypted within the cookie data.
28+- Since multiple requests can be made concurrently to the OAuth2 Proxy, this session implementation
29+cannot lock sessions and while updating and refreshing sessions, there can be conflicts which force
30+users to re-authenticate
31+
32+
33+### Redis Storage
34+
35+The Redis Storage backend stores sessions, encrypted, in redis. Instead sending all the information
36+back the client for storage, as in the [Cookie storage](#cookie-storage), a ticket is sent back
37+to the user as the cookie value instead.
38+
39+A ticket is composed as the following:
40+
41+`{CookieName}-{ticketID}.{secret}`
42+
43+Where:
44+
45+- The `CookieName` is the OAuth2 cookie name (_oauth2_proxy by default)
46+- The `ticketID` is a 128 bit random number, hex-encoded
47+- The `secret` is a 128 bit random number, base64url encoded (no padding). The secret is unique for every session.
48+- The pair of `{CookieName}-{ticketID}` comprises a ticket handle, and thus, the redis key
49+to which the session is stored. The encoded session is encrypted with the secret and stored
50+in redis via the `SETEX` command.
51+
52+Encrypting every session uniquely protects the refresh/access/id tokens stored in the session from
53+disclosure.
54+
55+#### Usage
56+
57+When using the redis store, specify `--session-store-type=redis` as well as the Redis connection URL, via
58+`--redis-connection-url=redis://host[:port][/db-number]`.
59+
60+You may also configure the store for Redis Sentinel. In this case, you will want to use the
61+`--redis-use-sentinel=true` flag, as well as configure the flags `--redis-sentinel-master-name`
62+and `--redis-sentinel-connection-urls` appropriately.
63+
64+Redis Cluster is available to be the backend store as well. To leverage it, you will need to set the
65+`--redis-use-cluster=true` flag, and configure the flags `--redis-cluster-connection-urls` appropriately.
66+
67+Note that flags `--redis-use-sentinel=true` and `--redis-use-cluster=true` are mutually exclusive.
68+
69+Note, if Redis timeout option is set to non-zero, the `--redis-connection-idle-timeout`
70+must be less than [Redis timeout option](https://redis.io/docs/reference/clients/#client-timeouts). For example: if either redis.conf includes
71+`timeout 15` or using `CONFIG SET timeout 15` the `--redis-connection-idle-timeout` must be at least `--redis-connection-idle-timeout=14`
docs/versioned_docs/version-7.5.x/configuration/tls.mdnew file+86
@@ -0,0 +1,86 @@
1+---
2+id: tls
3+title: TLS Configuration
4+---
5+
6+There are two recommended configurations:
7+- [At OAuth2 Proxy](#terminate-tls-at-oauth2-proxy)
8+- [At Reverse Proxy](#terminate-tls-at-reverse-proxy-eg-nginx)
9+
10+### Terminate TLS at OAuth2 Proxy
11+
12+1. Configure SSL Termination with OAuth2 Proxy by providing a `--tls-cert-file=/path/to/cert.pem` and `--tls-key-file=/path/to/cert.key`.
13+
14+ The command line to run `oauth2-proxy` in this configuration would look like this:
15+
16+ ```bash
17+ ./oauth2-proxy \
18+ --email-domain="yourcompany.com" \
19+ --upstream=http://127.0.0.1:8080/ \
20+ --tls-cert-file=/path/to/cert.pem \
21+ --tls-key-file=/path/to/cert.key \
22+ --cookie-secret=... \
23+ --cookie-secure=true \
24+ --provider=... \
25+ --client-id=... \
26+ --client-secret=...
27+ ```
28+
29+2. With this configuration approach the customization of the TLS settings is limited.
30+
31+ The minimal acceptable TLS version can be set with `--tls-min-version=TLS1.3`.
32+ The defaults set `TLS1.2` as the minimal version.
33+ Regardless of the minimum version configured, `TLS1.3` is currently always used as the maximal version.
34+
35+ TLS server side cipher suites can be specified with `--tls-cipher-suite=TLS_RSA_WITH_RC4_128_SHA`.
36+ If not specified, the defaults from [`crypto/tls`](https://pkg.go.dev/crypto/tls#CipherSuites) of the currently used `go` version for building `oauth2-proxy` will be used.
37+ A complete list of valid TLS cipher suite names can be found in [`crypto/tls`](https://pkg.go.dev/crypto/tls#pkg-constants).
38+
39+### Terminate TLS at Reverse Proxy, e.g. Nginx
40+
41+1. Configure SSL Termination with [Nginx](http://nginx.org/) (example config below), Amazon ELB, Google Cloud Platform Load Balancing, or ...
42+
43+ Because `oauth2-proxy` listens on `127.0.0.1:4180` by default, to listen on all interfaces (needed when using an
44+ external load balancer like Amazon ELB or Google Platform Load Balancing) use `--http-address="0.0.0.0:4180"` or
45+ `--http-address="http://:4180"`.
46+
47+ Nginx will listen on port `443` and handle SSL connections while proxying to `oauth2-proxy` on port `4180`.
48+ `oauth2-proxy` will then authenticate requests for an upstream application. The external endpoint for this example
49+ would be `https://internal.yourcompany.com/`.
50+
51+ An example Nginx config follows. Note the use of `Strict-Transport-Security` header to pin requests to SSL
52+ via [HSTS](http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security):
53+
54+ ```
55+ server {
56+ listen 443 default ssl;
57+ server_name internal.yourcompany.com;
58+ ssl_certificate /path/to/cert.pem;
59+ ssl_certificate_key /path/to/cert.key;
60+ add_header Strict-Transport-Security max-age=2592000;
61+
62+ location / {
63+ proxy_pass http://127.0.0.1:4180;
64+ proxy_set_header Host $host;
65+ proxy_set_header X-Real-IP $remote_addr;
66+ proxy_set_header X-Scheme $scheme;
67+ proxy_connect_timeout 1;
68+ proxy_send_timeout 30;
69+ proxy_read_timeout 30;
70+ }
71+ }
72+ ```
73+
74+2. The command line to run `oauth2-proxy` in this configuration would look like this:
75+
76+ ```bash
77+ ./oauth2-proxy \
78+ --email-domain="yourcompany.com" \
79+ --upstream=http://127.0.0.1:8080/ \
80+ --cookie-secret=... \
81+ --cookie-secure=true \
82+ --provider=... \
83+ --reverse-proxy=true \
84+ --client-id=... \
85+ --client-secret=...
86+ ```
docs/versioned_docs/version-7.5.x/features/endpoints.mdnew file+47
@@ -0,0 +1,47 @@
1+---
2+id: endpoints
3+title: Endpoints
4+---
5+
6+OAuth2 Proxy responds directly to the following endpoints. All other endpoints will be proxied upstream when authenticated. The `/oauth2` prefix can be changed with the `--proxy-prefix` config variable.
7+
8+- /robots.txt - returns a 200 OK response that disallows all User-agents from all paths; see [robotstxt.org](http://www.robotstxt.org/) for more info
9+- /ping - returns a 200 OK response, which is intended for use with health checks
10+- /ready - returns a 200 OK response if all the underlying connections (e.g., Redis store) are connected
11+- /metrics - Metrics endpoint for Prometheus to scrape, serve on the address specified by `--metrics-address`, disabled by default
12+- /oauth2/sign_in - the login page, which also doubles as a sign out page (it clears cookies)
13+- /oauth2/sign_out - this URL is used to clear the session cookie
14+- /oauth2/start - a URL that will redirect to start the OAuth cycle
15+- /oauth2/callback - the URL used at the end of the OAuth cycle. The oauth app will be configured with this as the callback url.
16+- /oauth2/userinfo - the URL is used to return user's email from the session in JSON format.
17+- /oauth2/auth - only returns a 202 Accepted response or a 401 Unauthorized response; for use with the [Nginx `auth_request` directive](../configuration/overview.md#configuring-for-use-with-the-nginx-auth_request-directive)
18+- /oauth2/static/\* - stylesheets and other dependencies used in the sign_in and error pages
19+
20+### Sign out
21+
22+To sign the user out, redirect them to `/oauth2/sign_out`. This endpoint only removes oauth2-proxy's own cookies, i.e. the user is still logged in with the authentication provider and may automatically re-login when accessing the application again. You will also need to redirect the user to the authentication provider's sign out page afterwards using the `rd` query parameter, i.e. redirect the user to something like (notice the url-encoding!):
23+
24+```
25+/oauth2/sign_out?rd=https%3A%2F%2Fmy-oidc-provider.example.com%2Fsign_out_page
26+```
27+
28+Alternatively, include the redirect URL in the `X-Auth-Request-Redirect` header:
29+
30+```
31+GET /oauth2/sign_out HTTP/1.1
32+X-Auth-Request-Redirect: https://my-oidc-provider/sign_out_page
33+...
34+```
35+
36+(The "sign_out_page" should be the [`end_session_endpoint`](https://openid.net/specs/openid-connect-session-1_0.html#rfc.section.2.1) from [the metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig) if your OIDC provider supports Session Management and Discovery.)
37+
38+BEWARE that the domain you want to redirect to (`my-oidc-provider.example.com` in the example) must be added to the [`--whitelist-domain`](../configuration/overview) configuration option otherwise the redirect will be ignored. Make sure to include the actual domain and port (if needed) and not the URL (e.g "localhost:8081" instead of "http://localhost:8081").
39+
40+### Auth
41+
42+This endpoint returns 202 Accepted response or a 401 Unauthorized response.
43+
44+It can be configured using the following query parameters query parameters:
45+- `allowed_groups`: comma separated list of allowed groups
46+- `allowed_email_domains`: comma separated list of allowed email domains
47+- `allowed_emails`: comma separated list of allowed emails
docs/versioned_docs/version-7.5.x/installation.mdnew file+26
@@ -0,0 +1,26 @@
1+---
2+id: installation
3+title: Installation
4+slug: /
5+---
6+
7+1. Choose how to deploy:
8+
9+ a. Download [Prebuilt Binary](https://github.com/oauth2-proxy/oauth2-proxy/releases) (current release is `v7.5.0`)
10+
11+ b. Build with `$ go install github.com/oauth2-proxy/oauth2-proxy/v7@latest` which will put the binary in `$GOPATH/bin`
12+
13+ c. Using the prebuilt docker image [quay.io/oauth2-proxy/oauth2-proxy](https://quay.io/oauth2-proxy/oauth2-proxy) (AMD64, ARMv6 and ARM64 tags available)
14+
15+ d. Using a [Kubernetes manifest](https://github.com/oauth2-proxy/manifests) (Helm)
16+
17+Prebuilt binaries can be validated by extracting the file and verifying it against the `sha256sum.txt` checksum file provided for each release starting with version `v3.0.0`.
18+
19+```
20+$ sha256sum -c sha256sum.txt
21+oauth2-proxy-x.y.z.linux-amd64: OK
22+```
23+
24+2. [Select a Provider and Register an OAuth Application with a Provider](configuration/auth.md)
25+3. [Configure OAuth2 Proxy using config file, command line options, or environment variables](configuration/overview.md)
26+4. [Configure SSL or Deploy behind a SSL endpoint](configuration/tls.md) (example provided for Nginx)
docs/versioned_sidebars/version-7.5.x-sidebars.jsonnew file+40
@@ -0,0 +1,40 @@
1+{
2+ "docs": [
3+ {
4+ "type": "doc",
5+ "id": "installation"
6+ },
7+ {
8+ "type": "doc",
9+ "id": "behaviour"
10+ },
11+ {
12+ "type": "category",
13+ "label": "Configuration",
14+ "collapsed": false,
15+ "items": [
16+ "configuration/overview",
17+ "configuration/oauth_provider",
18+ "configuration/session_storage",
19+ "configuration/tls",
20+ "configuration/alpha-config"
21+ ]
22+ },
23+ {
24+ "type": "category",
25+ "label": "Features",
26+ "collapsed": false,
27+ "items": [
28+ "features/endpoints"
29+ ]
30+ },
31+ {
32+ "type": "category",
33+ "label": "Community",
34+ "collapsed": false,
35+ "items": [
36+ "community/security"
37+ ]
38+ }
39+ ]
40+}
docs/versions.json+1
@@ -1,4 +1,5 @@
11[
2+ "7.5.x",
23 "7.4.x",
34 "7.3.x",
45 "7.2.x",