Skip to content

triauth for OAuth2 ProxyOIDC

Let your team reach the tools behind OAuth2 Proxy with one approval on their own device, and no passwords anywhere.

  • Access and networking
  • Open source
Sign-in through
OpenID Connect bridge
Available in
Every OAuth2 Proxy installation
Set up in
Flags or environment variables

About OAuth2 Proxy

OAuth2 Proxy is a small server you put in front of a web application, or behind Nginx or Traefik, so that nobody reaches the application without signing in first. It handles the sign-in, keeps a session cookie, and passes the person's email address and groups to the application in headers. Operations teams use it to protect dashboards and internal tools that have no login of their own.

Connect OAuth2 Proxy to triauth

OAuth2 Proxy signs people in through the triauth OpenID Connect bridge. Once connected, anyone opening a protected tool sees a Sign in with button with your domain's name. People on your team click it, type their username, and approve on their own device. The tool behind the proxy never sees a password, and when someone leaves, removing their identity records at your domain ends their access to all of it.

How it works

  1. Open oidc.triauth.org and enter your domain. Paste the proxy's redirect address, https://app.example.com/oauth2/callback with the address people use for the protected app in place of app.example.com, and click Connect app. The bridge gives you a client ID and a client secret.

  2. Start OAuth2 Proxy with the settings below. Replace example.com with your domain, app.example.com with the app's address, the two placeholders with the client ID and the client secret from the bridge, and the cookie secret with a random value of your own.

    ini
    OAUTH2_PROXY_PROVIDER=oidc
    OAUTH2_PROXY_OIDC_ISSUER_URL=https://oidc.triauth.org/example.com
    OAUTH2_PROXY_CLIENT_ID=<client ID from the bridge>
    OAUTH2_PROXY_CLIENT_SECRET=<client secret from the bridge>
    OAUTH2_PROXY_REDIRECT_URL=https://app.example.com/oauth2/callback
    OAUTH2_PROXY_SCOPE=openid email profile groups offline_access
    OAUTH2_PROXY_COOKIE_REFRESH=30m
    OAUTH2_PROXY_EMAIL_DOMAINS=example.com
    OAUTH2_PROXY_CODE_CHALLENGE_METHOD=S256
    OAUTH2_PROXY_PROVIDER_DISPLAY_NAME=example.com
    OAUTH2_PROXY_COOKIE_SECRET=<a random secret of 32 bytes>
    OAUTH2_PROXY_UPSTREAMS=http://127.0.0.1:8080/
  3. Open the protected app and click Sign in with example.com.

Checkpoint

The proxy's sign-in page shows Sign in with example.com. Choosing it opens a page from the bridge that asks for the username, and the person's authenticator asks them to approve. The app opens afterwards.

Good to know

  • OAuth2 Proxy keeps no accounts. Everyone with an identity at your domain gets in, and OAUTH2_PROXY_ALLOWED_GROUPS narrows that to the members of one of the groups published at your domain. You can also limit the app to a group when you connect it.
  • The app behind the proxy learns who signed in from headers such as X-Auth-Request-Email and X-Auth-Request-Groups, when OAUTH2_PROXY_SET_XAUTHREQUEST=true.
  • With the settings above, the proxy renews the sign-in through the bridge every half hour while a person works, and re-reads their groups each time. So a session follows the identity. When someone's records at your domain go away, the next renewal sends them to the sign-in page.

For the person who connects the app

SettingValue
Redirect addresshttps://<the protected host>/oauth2/callback, also set as OAUTH2_PROXY_REDIRECT_URL
Whereflags, OAUTH2_PROXY_* environment variables, or a TOML configuration file
IssuerOAUTH2_PROXY_OIDC_ISSUER_URL takes https://oidc.triauth.org/<your domain>, and the rest comes from the discovery document
SessionsOAUTH2_PROXY_COOKIE_REFRESH=30m renews the sign-in through the bridge every half hour. OAUTH2_PROXY_COOKIE_EXPIRE, usually a week, is how long an unused session is kept, and the refresh period must stay below it. The proxy's docs ask for that expiry to match how long the bridge keeps an unused session. A bridge error at a renewal sends the person to sign in again
NonceOAUTH2_PROXY_INSECURE_OIDC_SKIP_NONCE=false turns the nonce check on, which the bridge supports
Behind Nginx or Traefikthe auth_request and ForwardAuth setups use the proxy's /oauth2/auth endpoint and need OAUTH2_PROXY_REVERSE_PROXY=true

OAuth2 Proxy keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge. OAuth2 Proxy's OpenID Connect page and the configuration overview list every flag.

Next steps

All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.