OAuth2 Proxy
Protect a private website with wallet authentication through Ver.iD, an exact email allowlist and a private verified-email gate.
Put OAuth2 Proxy in front of a private website to add wallet login without changing its login page. The proxy validates the signed ID token and applies an exact email allowlist. A private gateway additionally requires the email verification claim before forwarding a request to your application.
This guide targets the unmodified OAuth2 Proxy 7.15.6 binary. Its structured provider and header options are marked alpha upstream, so keep this version pinned while following the guide.
How it works
- A signed-out visitor opens a protected website path.
- OAuth2 Proxy redirects the browser to Ver.iD with nonce and S256 PKCE.
- The visitor approves email and phone in their wallet.
- The proxy exchanges the authorization code, validates the ID token and checks the permitted-email file.
- The proxy replaces identity headers with claims from the validated token and session. The private gateway requires a nonempty email and a positive verification header.
- Only then does the private application receive the original request.
The gateway and application must be reachable only through that boundary. The proxy has no account database, so account creation and linking are not applicable. An application's independent accounts require their own account policy.
What you need
| Requirement | Where to get it |
|---|---|
| OAuth2 Proxy 7.15.6 and an HTTPS entry point | Your normal software deployment process |
| A private gateway and application with no alternate public route | Your network and application administrator |
| An organization prepared for verification, with wallets and trust frameworks enabled | Prepare your organization |
A dedicated authentication with email, an active brand and an attached OAUTH secret | Create an authentication and OAuth client secrets |
| A wallet with a verified email credential | This example uses Yivi; see wallet availability and status |
| An explicit list of permitted email addresses | Your application's access policy |
Use <application-origin> for the external HTTPS origin without a trailing slash, for example https://portal.example.com. Configure <application-origin>/oauth2/callback in Ver.iD Studio → Verify → Authentications → your flow → Redirect URIs (Add redirect URIs).
Configuration
This worked example requests openid email. Access requires an allowlisted email and a positive verification flag. Phone is additional contact data for the application; it is not an authorization factor here.
Configure Ver.iD
- Create an authentication for this website and environment. Enable Yivi with
email, add an active brand and attach an OAUTH secret. - Deactivate it before editing Redirect URIs. Add
<application-origin>/oauth2/callbackexactly, then activate the authentication. - Copy its client identifier from Configuration and the secret's Key (as base64url) value. Do not use the secret's key identifier.
- Test the authentication with
openid email. Confirm the signed token containsemailandemail_verified, with a boolean verification flag.
Prepare private credentials and the allowlist
Create a private directory and these files using your deployment's secret manager. Keep the directory mode 0700 and each file mode 0600, owned by the service account that reads it.
| File mounted in the proxy | Content |
|---|---|
/run/secrets/client-secret | The OAUTH secret's value, without a trailing newline |
/run/secrets/cookie-secret | An independent raw 32-byte random cookie key |
/run/secrets/allowed-emails | Exact permitted email addresses, one per line |
Choose a test mailbox you control for the first login. Do not replace this exact-address policy with a wildcard email domain. Mount each file read-only into the proxy and do not expose them to the gateway or application. If using a container, run it as a non-root UID that can read the owned 0600 files; do not make the files world-readable to fix access.
Configure the proxy session and access policy
Create proxy.cfg and replace the application origin:
redirect_url = "https://portal.example.com/oauth2/callback"
authenticated_emails_file = "/run/secrets/allowed-emails"
cookie_secret_file = "/run/secrets/cookie-secret"
cookie_name = "__Host-verid_proxy"
cookie_secure = true
cookie_httponly = true
cookie_samesite = "lax"
cookie_path = "/"
cookie_expire = "5m"
cookie_refresh = "1s"
cookie_csrf_expire = "5m"
cookie_csrf_per_request = true
cookie_csrf_per_request_limit = 5
reverse_proxy = true
skip_provider_button = true
request_logging = false
auth_logging = false
standard_logging = false
show_debug_on_error = falseConfigure the provider and claim headers
Create proxy.yaml, replacing the client identifier and private gateway address for your deployment:
server:
bindAddress: '0.0.0.0:4180'
upstreamConfig:
upstreams:
- id: private-application-gateway
path: /
uri: http://private-application-gateway:8080/
injectRequestHeaders:
- name: X-Verid-Email
preserveRequestValue: false
values:
- claimSource:
claim: email
- name: X-Verid-Email-Verified
preserveRequestValue: false
values:
- claimSource:
claim: email_verified
injectResponseHeaders: []
providers:
- id: verid
provider: oidc
name: Digital Identity Wallet
clientID: 'REPLACE_WITH_AUTHENTICATION_CLIENT_ID'
clientSecretFile: /run/secrets/client-secret
scope: openid email
code_challenge_method: S256
skipClaimsFromProfileURL: true
additionalClaims:
- email_verified
useSystemTrustStore: true
oidcConfig:
issuerURL: https://ssi.oauth.ver.id/
enabledSigningAlgs: [ES384]
insecureSkipNonce: false
insecureSkipIssuerVerification: false
insecureAllowUnverifiedEmail: falseClaims come from the signed ID token; skipClaimsFromProfileURL disables UserInfo enrichment. The proxy replaces incoming copies of these two headers, including when a claim is absent. Neither ID tokens nor access tokens are injected into application headers. Do not enable token forwarding or request offline_access or groups for this example.
The upstream generic OIDC provider uses confidential authentication auto-detection at the token endpoint. Retain its native behavior and the configured secret.
Require verified email at the private gateway
OAuth2 Proxy permits an absent email_verified flag. Therefore an email allowlist alone does not implement this policy. Require the proxy's verification header and a nonempty email on every application route.
For nginx, put the maps in its HTTP context and keep this server reachable only by the authenticated proxy:
map $http_x_verid_email_verified $verified_contact { default 0; "true" 1; }
map $http_x_verid_email $email_present { default 1; "" 0; }
server {
listen 8080;
access_log off;
location / {
if ($verified_contact = 0) { return 403; }
if ($email_present = 0) { return 403; }
proxy_pass http://private-application:8080;
}
}Provide no alternate ingress or published port for the gateway or application. The HTTPS entry point must replace client-supplied forwarding headers. Disable trusted-IP authentication bypasses, skip-auth routes and bearer-token login shortcuts.
The native proxy normalizes both signed boolean true and signed string "true" to the accepted value. This boundary does not enforce strict JSON boolean typing. Configure the Studio flow to return standard boolean verification flags. Missing and false values are denied by the combined proxy-and-gateway policy.
Start the proxy and test the protected path
Start the pinned binary with your configuration paths:
oauth2-proxy \
--config=/etc/oauth2-proxy/proxy.cfg \
--alpha-config=/etc/oauth2-proxy/proxy.yamlFor an nginx HTTPS entry point, set proxy_buffer_size 16k;, proxy_buffers 4 16k; and proxy_busy_buffers_size 32k; in the location forwarding to OAuth2 Proxy. Its callback sets session cookies that can exceed nginx’s default response-header buffer.
Keep the HTTP listener private behind your HTTPS entry point. Review every logging layer so callback query strings, cookies, tokens and contact headers are excluded.
- In a new private browser window, open
<application-origin>/protected. Complete the Yivi email-and-phone request using the allowlisted mailbox. The original protected path must load. - In your protected application, confirm it received
X-Verid-EmailandX-Verid-Email-Verified: true. Inspect values privately and keep them out of reports. - Open
/oauth2/sign_out, then revisit the protected path. Confirm a new authorization request and repeat login. - Try a wallet email outside the exact allowlist and cancel another fresh wallet request. Neither attempt may open the application.
- Test a missing or false email verification flag in your test environment. A missing flag may create a native proxy session, but the private gateway must return HTTP 403.
- Wait beyond the cookie lifetime and revisit the protected path. A new login must be required. Check token expiry independently, using its actual expiry.
- Try forged identity headers through the public entry point without a valid proxy session. Confirm no application access and no direct route to the private upstream.
Proxy sign-out clears this proxy session. It does not delete an application's accounts or end an independent application session.