Skip to content

m3gat0nn4ge/auth-proxy

 
 

Repository files navigation

Auth Proxy

Overview

This repo and Docker image provides a test proxy server, configured with Kerberos, Basic, Form and SAML authentication.

To start, run like this:

docker run -p 80:80 -p 443:443 -p 88:88 -h mydomain.com -e BACKEND=https://192.168.1.100:443 -ti liggitt/auth-proxy

Invocation details:

  • 80 is the http proxy port
  • 443 is the https proxy port
  • 88 is the Kerberos ticket server port
  • mydomain.com can be replaced with any hostname you like, just adjust the setup instructions appropriately
  • $BACKEND should be set to the base URL you want proxied (with no trailing slash). The host or IP must be accessible from within the container (so localhost probably won't work)

On startup, it sets up the following:

  • Kerberos ticket server for $PROXY_HOST (defaulting to the host mydomain.com and the realm MYDOMAIN.COM)
  • Apache proxy from https://$PROXY_HOST/mod_auth_gssapi/* to $BACKEND, secured by negotiate auth backed by Kerberos (mod_auth_gssapi)
  • Apache proxy from https://$PROXY_HOST/mod_auth_gssapi_basic/* to $BACKEND, secured by negotiate auth backed by Kerberos (mod_auth_gssapi) with basic auth fallback
  • Apache proxy from https://$PROXY_HOST/mod_auth_kerb/* to $BACKEND, secured by negotiate auth backed by Kerberos (mod_auth_kerb)
  • Apache proxy from https://$PROXY_HOST/mod_auth_kerb_basic/* to $BACKEND, secured by negotiate auth backed by Kerberos (mod_auth_kerb) with basic auth fallback
  • Apache proxy from https://$PROXY_HOST/mod_auth_basic/* to $BACKEND, secured by basic auth backed by Kerberos
  • Apache proxy from https://$PROXY_HOST/mod_auth_form/* to $BACKEND, secured by form auth backed by a htpasswd file
  • Apache proxy from https://$PROXY_HOST/mod_auth_mellon/* to $BACKEND, secured by SAML auth with the IDP metadata in /etc/httpd/conf.d/saml_idp.xml
  • Apache proxy from https://$PROXY_HOST/mod_intercept_form_submit/* to $BACKEND, secured by form interception auth backed by Kerberos
  • 5 test users, user1-user5@REALM, with password password (e.g. [email protected]/password)

Docker image setup

Build the Docker image from source

make build

Run the Docker image from source

Specify the backend to proxy to with the $BACKEND envvar.

BACKEND=https://my-backend.com PROXY_HOST=mydomain.com make run

Desktop setup

Use the container as a Kerberos ticket server

The following examples assume $PROXY_HOST was set to mydomain.com, and the krb5-workstation package is installed.

  1. Alias mydomain.com to the Docker IP in `/etc/hosts/:
172.17.42.1 mydomain.com
  1. Configure Kerberos to use the container as the ticket server in /etc/krb5.conf:
[realms]
MYDOMAIN.COM = {
  kdc = mydomain.com
  admin_server = mydomain.com
  default_domain = mydomain.com
}

[domain_realm]
.mydomain.com = MYDOMAIN.COM
mydomain.com = MYDOMAIN.COM
  1. Configure Firefox to use negotiate auth with the domain:

  2. Type about:config

  3. Set network.negotiate-auth.trusted-uris to include mydomain.com

Example Use

Kerberos

The following examples assume $PROXY_HOST was set to mydomain.com, and the krb5-workstation package is installed.

  1. Log in:
$ kinit [email protected]
Password for [email protected]: password

$ klist
Ticket cache: KEYRING:persistent:1000:1000
Default principal: [email protected]

Valid starting       Expires              Service principal
09/07/2015 20:43:32  09/08/2015 20:43:32  krbtgt/[email protected]
  1. Check negotiate auth:
$ curl -v http://mydomain.com/mod_auth_gssapi/ --negotiate -u :

* Connected to mydomain.com (172.17.42.1) port 80 (#0)
> GET /mod_auth_gssapi/ HTTP/1.1
> Host: mydomain.com
> Accept: */*

< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Negotiate

* Issue another request to this URL: 'http://mydomain.com/mod_auth_gssapi/'
* Server auth using GSS-Negotiate with user ''

> GET /mod_auth_gssapi/ HTTP/1.1
> Authorization: Negotiate YIICmQYGKwYBBQUCoIICj...
> Host: mydomain.com
> Accept: */*

< HTTP/1.1 200 OK
< WWW-Authenticate: Negotiate oYG3MIG0oAMKAQChCwYJK...
< Content-Type: text/html
< Content-Length: 252
...
  1. Log out, verify no tickets are active
$ kdestroy
$ klist
klist: Credentials cache keyring 'persistent:1000:1000' not found

  1. Verify negotiate auth fails:
$ curl -v http://mydomain.com/mod_auth_gssapi/ --negotiate -u :

> GET /mod_auth_gssapi/ HTTP/1.1
> Host: mydomain.com
> Accept: */*

< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Negotiate
* gss_init_sec_context() failed: : SPNEGO cannot find mechanisms to negotiate
...

Basic auth

  1. Check basic auth fails:
$ curl -v http://mydomain.com/mod_auth_basic/ -u test:user

* Server auth using Basic with user 'test'
> GET /mod_auth_basic/ HTTP/1.1
> Authorization: Basic dGVzdDp1c2Vy
> Host: mydomain.com
> Accept: */*

< HTTP/1.1 401 Unauthorized
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Basic Login"
...

  1. Check basic auth succeeds:
$ curl -v http://mydomain.com/mod_auth_basic/ -u [email protected]:password

* Server auth using Basic with user '[email protected]'
> GET /mod_auth_basic/ HTTP/1.1
> Authorization: Basic dXNlcjFATVlET01BSU4uQ09NOnBhc3N3b3Jk
> Host: mydomain.com
> Accept: */*

< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Length: 252
...

SAML auth

  1. Copy your IDP's metadata XML to /etc/httpd/conf.d/saml_idp.xml and restart httpd (httpd -k restart)

  2. An example IDP can be created at https://auth0.com/. After creating an account, edit the default app's Addons > SAML2 Web App settings as follows:

    Settings > Application Callback URL: https://mydomain.com/mellon/postResponse

    Settings > Settings:

    {
        "audience":  "https://mydomain.com",
        ...
    }
    

    Usage > Identity Provider Metadata: Copy to /etc/httpd/conf.d/saml_idp.xml in your proxy image and restart httpd (httpd -k restart)

About

Test proxy for negotiate, basic, and form authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 54.7%
  • Makefile 25.3%
  • HTML 20.0%