Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

traefik-forward-auth

> DevOps
Open source

Minimal forward authentication service that provides Google/OpenID oauth based login and authentication for the traefik reverse proxy

2.4K stars0 likes2 views
WebsiteGitHub

About

Minimal forward authentication service that provides Google/OpenID oauth based login and authentication for the traefik reverse proxy

Traefik Forward Auth

A minimal forward authentication service that provides OAuth/SSO login and authentication for the traefik reverse proxy/load balancer.

Why?

  • Seamlessly overlays any http service with a single endpoint (see: url-path in Configuration)
  • Supports multiple providers including Google and OpenID Connect (supported by Azure, Github, Salesforce etc.)
  • Supports multiple domains/subdomains by dynamically generating redirect_uri's
  • Allows authentication to be selectively applied/bypassed based on request parameters (see rules in Configuration)
  • Supports use of centralised authentication host/redirect_uri (see auth-host in Configuration)
  • Allows authentication to persist across multiple domains (see Cookie Domains)
  • Supports extended authentication beyond Google token lifetime (see: lifetime in Configuration)

Contents

  • Releases
  • Usage
    • Simple
    • Advanced
    • Provider Setup
  • Configuration
    • Overview
    • Option Details
  • Concepts
    • Forwarded Headers
    • User Restriction
    • Applying Authentication
      • Global Authentication
      • Selective Ingress Authentication in Kubernetes
      • Selective Container Authentication in Swarm
      • Rules Based Authentication
    • Operation Modes
      • Overlay Mode
      • Auth Host Mode
    • Logging Out
  • Copyright
  • License

Releases

We recommend using the 2 tag on docker hub (thomseddon/traefik-forward-auth:2).

You can also use the latest incremental releases found on docker hub and github.

ARM releases are also available on docker hub, just append -arm or -arm64 to your desired released (e.g. 2-arm or 2.1-arm64).

We also build binary files for usage without docker starting with releases after 2.2.0 You can find these as assets of the specific GitHub release.

Upgrade Guide

v2 was released in June 2019, whilst this is fully backwards compatible, a number of configuration options were modified, please see the upgrade guide to prevent warnings on startup and ensure you are using the current configuration.

Usage

Simple:

See below for instructions on how to setup your Provider Setup.

docker-compose.yml:

…

Advanced:

Please see the examples directory for a more complete docker-compose.yml or kubernetes/simple-separate-pod.

Also in the examples directory is docker-compose-auth-host.yml and kubernetes/advanced-separate-pod which shows how to configure a central auth host, along with some other options.

Provider Setup

Below are some general notes on provider setup, specific instructions and examples for a number of providers can be found on the Provider Setup wiki page.

Google

Head to https://console.developers.google.com and make sure you've switched to the correct email account.

Create a new project then search for and select "Credentials" in the search bar. Fill out the "OAuth Consent Screen" tab.

Click "Create Credentials" > "OAuth client ID". Select "Web Application", fill in the name of your app, skip "Authorized JavaScript origins" and fill "Authorized redirect URIs" with all the domains you will allow authentication from, appended with the url-path (e.g. https://app.test.com/_oauth)

You must set the providers.google.client-id and providers.google.client-secret config options.

OpenID Connect

Any provider that supports OpenID Connect 1.0 can be configured via the OIDC config options below.

You must set the providers.oidc.issuer-url, providers.oidc.client-id and providers.oidc.client-secret config options.

Please see the Provider Setup wiki page for examples.

Generic OAuth2

For providers that don't support OpenID Connect, we also have the Generic OAuth2 provider where you can statically configure the OAuth2 and "user" endpoints.

You must set:

  • providers.generic-oauth.auth-url - URL the client should be sent to authenticate the authenticate
  • providers.generic-oauth.token-url - URL the service should call to exchange an auth code for an access token
  • providers.generic-oauth.user-url - URL used to retrieve user info (service makes a GET request)
  • providers.generic-oauth.client-id - Client ID
  • providers.generic-oauth.client-secret - Client Secret

You can also set:

  • providers.generic-oauth.scope- Any scopes that should be included in the request (default: profile, email)
  • providers.generic-oauth.token-style - How token is presented when querying the User URL. Can be header or query, defaults to header. With header the token is provided in an Authorization header, with query the token is provided in the access_token query string value.

Please see the Provider Setup wiki page for examples.

Configuration

Overview

The following configuration options are supported:

…

All options can be supplied in any of the following ways, in the following precedence (first is highest precedence):

  1. Command Arguments/Flags - As shown above
  2. Environment Variables - As shown in square brackets above
  3. File
    1. Use INI format (e.g. url-path = _oauthpath)
    2. Specify the file location via the --config flag or $CONFIG environment variable
    3. Can be specified multiple times, each file will be read in the order they are passed

Option Details

  • auth-host

    When set, when a user returns from authentication with a 3rd party provider they will always be forwarded to this host. By using one central host, this means you only need to add this auth-host as a valid redirect uri to your 3rd party provider.

    The host should be specified without protocol or path, for example:

    --auth-host="auth.example.com"

    For more details, please also read the Auth Host Mode, operation mode in the concepts section.

    Please Note - this should be considered advanced usage, if you are having problems please try disabling this option and then re-read the Auth Host Mode section.

  • config

    Used to specify the path to a configuration file, can be set multiple times, each file will be read in the order they are passed. Options should be set in an INI format, for example:

    url-path = _oauthpath
  • cookie-domain

    When set, if a user successfully completes authentication, then if the host of the original request requiring authentication is a subdomain of a given cookie domain, then the authentication cookie will be set for the higher level cookie domain. This means that a cookie can allow access to multiple subdomains without re-authentication. Can be specificed multiple times.

    For example:

    --cookie-domain="example.com"  --cookie-domain="test.org"

    For example, if the cookie domain test.com has been set, and a request comes in on app1.test.com, following authentication the auth cookie will be set for the whole test.com domain. As such, if another request is forwarded for authentication from app2.test.com, the original cookie will be sent and so the request will be allowed without further authentication.

    Beware however, if using cookie domains whilst running multiple instances of traefik/traefik-forward-auth for the same domain, the cookies will clash. You can fix this by using a different cookie-name in each host/cluster or by using the same cookie-secret in both instances.

  • insecure-cookie

    If you are not using HTTPS between the client and traefik, you will need to pass the insecure-cookie option which will mean the Secure attribute on the cookie will not be set.

  • cookie-name

    Set the name of the cookie set following successful authentication.

    Default: _forward_auth

  • csrf-cookie-name

    Set the name of the temporary CSRF cookie set during authentication.

    Default: _forward_auth_csrf

  • default-action

    Specifies the behavior when a request does not match any rules. Valid options are auth or allow.

    Default: auth (i.e. all requests require authentication)

  • default-provider

    Set the default provider to use for authentication, this can be overridden within rules. Valid options are currently google or oidc.

    Default: google

  • domain

    When set, only users matching a given domain will be permitted to access.

    For example, setting --domain=example.com --domain=test.org would mean that only users from example.com or test.org will be permitted. So [email protected] would be allowed but [email protected] would not.

    For more details, please also read User Restriction in the concepts section.

  • lifetime

    How long a successful authentication session should last, in seconds.

    Default: 43200 (12 hours)

  • logout-redirect

    When set, users will be redirected to this URL following logout.

  • match-whitelist-or-domain

    When enabled, users will be permitted if they match either the whitelist or domain parameters.

    This will be enabled by default in v3, but is disabled by default in v2 to maintain backwards compatibility.

    Default: false

    For more details, please also read User Restriction in the concepts section.

  • url-path

    Customise the path that this service uses to handle the callback following authentication.

    Default: /_oauth

    Please note that when using the default Overlay Mode requests to this exact path will be intercepted by this service and not forwarded to your application. Use this option (or Auth Host Mode) if the default /_oauth path will collide with an existing route in your application.

  • secret

    Used to sign cookies authentication, should be a random (e.g. openssl rand -hex 16)

  • whitelist

    When set, only specified users will be permitted.

    For example, setting [email protected] [email protected] would mean that only those two exact users will be permitted. So [email protected] would be allowed but [email protected] would not.

    For more details, please also read User Restriction in the concepts section.

  • rule

    Specify selective authentication rules. Rules are specified in the following format: rule.<name>.<param>=<value>

    • <name> can be any string and is only used to group rules together
    • <param> can be:
      • action

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gobeyondcorpdocker-swarmgoogle-oauthkubernetes

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理