Authenticating Proxy

NOTE: This connector is experimental and may change in the future.

Overview

The authproxy connector returns identities based on authentication which your front-end web server performs. Dex consumes the X-Remote-User header set by the proxy, which is then used as the user’s email address.

It also consumes the X-Remote-Group header to use as the user’s group.

Header’s names can be configured via the userHeader and groupHeader config.

Additional static groups can also be defined in the connector’s configuration.

The proxy MUST remove any X-Remote-* headers set by the client, for any URL path, before the request is forwarded to dex.

The connector does not support refresh tokens.

Configuration

The authproxy connector is used by proxies to implement login strategies not supported by dex. For example, a proxy could handle a different OAuth2 strategy such as Slack:

  1. connectors:
  2. # Slack login implemented by an authenticating proxy, not by dex.
  3. - type: authproxy
  4. id: slack
  5. name: Slack

The proxy only needs to authenticate the user when they attempt to visit the callback URL path:

  1. ( dex issuer URL )/callback/( connector id )?( url query )

For example, if dex is running at https://auth.example.com/dex and the connector ID is slack, the callback URL would look like:

  1. https://auth.example.com/dex/callback/slack?state=xdg3z6quhrhwaueo5iysvliqf

The proxy should login the user then return them to the exact URL (including the query), setting X-Remote-User to the user’s email before proxying the request to dex.

Configuration example - Apache 2

The following is an example config file that can be used by the external connector to authenticate a user.

  1. connectors:
  2. - type: authproxy
  3. id: myBasicAuth
  4. name: HTTP Basic Auth
  5. config:
  6. userHeader: X-Forwarded-User # default is X-Remote-User
  7. groupHeader: X-Forwarded-Group # default is X-Remote-Group
  8. staticGroups:
  9. - default

The authproxy connector assumes that you configured your front-end web server such that it performs authentication for the /dex/callback/myBasicAuth location and provides the result in the HTTP headers.

In this example, the configured headers are X-Forwarded-User for the user’s mail and X-Forwarded-Group for the user’s group. Dex authproxy connector will return a list of groups containing both configured staticGroups and return the group header.

The following configuration will work for Apache 2.4.10+:

  1. <Location /dex/>
  2. ProxyPass "http://localhost:5556/dex/"
  3. ProxyPassReverse "http://localhost:5556/dex/"
  4. # Strip the X-Remote-User header from all requests except for the ones
  5. # where we override it.
  6. RequestHeader unset X-Remote-User
  7. </Location>
  8. <Location /dex/callback/myBasicAuth>
  9. AuthType Basic
  10. AuthName "db.debian.org webPassword"
  11. AuthBasicProvider file
  12. AuthUserFile "/etc/apache2/debian-web-pw.htpasswd"
  13. Require valid-user
  14. # Defense in depth: clear the Authorization header so that
  15. # Debian Web Passwords never even reach dex.
  16. RequestHeader unset Authorization
  17. # Requires Apache 2.4.10+
  18. RequestHeader set X-Remote-User expr=%{REMOTE_USER}@debian.org
  19. ProxyPass "http://localhost:5556/dex/callback/myBasicAuth"
  20. ProxyPassReverse "http://localhost:5556/dex/callback/myBasicAuth"
  21. </Location>

Full Apache2 setup

After installing your Linux distribution’s Apache2 package, place the following virtual host configuration in e.g. /etc/apache2/sites-available/sso.conf:

  1. <VirtualHost sso.example.net>
  2. ServerName sso.example.net
  3. ServerAdmin webmaster@localhost
  4. DocumentRoot /var/www/html
  5. ErrorLog ${APACHE_LOG_DIR}/error.log
  6. CustomLog ${APACHE_LOG_DIR}/access.log combined
  7. <Location /dex/>
  8. ProxyPass "http://localhost:5556/dex/"
  9. ProxyPassReverse "http://localhost:5556/dex/"
  10. # Strip the X-Remote-User header from all requests except for the ones
  11. # where we override it.
  12. RequestHeader unset X-Remote-User
  13. </Location>
  14. <Location /dex/callback/myBasicAuth>
  15. AuthType Basic
  16. AuthName "db.debian.org webPassword"
  17. AuthBasicProvider file
  18. AuthUserFile "/etc/apache2/debian-web-pw.htpasswd"
  19. Require valid-user
  20. # Defense in depth: clear the Authorization header so that
  21. # Debian Web Passwords never even reach dex.
  22. RequestHeader unset Authorization
  23. # Requires Apache 2.4.10+
  24. RequestHeader set X-Remote-User expr=%{REMOTE_USER}@debian.org
  25. ProxyPass "http://localhost:5556/dex/callback/myBasicAuth"
  26. ProxyPassReverse "http://localhost:5556/dex/callback/myBasicAuth"
  27. </Location>
  28. </VirtualHost>

Then, enable it using a2ensite sso.conf, followed by a restart of Apache2.