phish108 / authomator

MIT License
0 stars 0 forks source link

authomator

Little authentication helper for the caddy server

Authomator consists of two core components:

  1. The authentication service.
  2. The authorization checker.

The entire system is designed to be located behind a caddy proxy server. The authentication service needs to be setup to listen to a location.

someserver.foo.bar:443 {
    # ...

    reverse_proxy /auth/* authserver:80

    forward_auth /protected/* {
        uri authserver:8081
        copy_headers Remote-User Remote-Name Remote-Authorizations
    }

    forward_auth /api/* {
        uri authserver:8081
        copy_headers Remote-User Remote-Name Remote-Authorizations
    }

    handle_path /api/* {
        # ...
    }

    handle_path /protected/* {
        # ...
    }

Endpoints

auth_server

The auth server has currently 4 endpoints:

check_server

The check server consists of a single endpoint that is used

Authomator Configuration

Authomator has three main sections:

Frontend options

Deprecation note:

Checker options

Deprecation note:

The entire section will be integrated with the frontend. port will be fixed to 8081.

Targets Configuration

The targets configuration defines the issuer endpoints and their specialities.

Each issuer is uniquely identified by its internal name.

The following options are available per issuer.

 user Configuration

The user configuration consists of a list of users and their access scope.

The reverse proxy sets the scope header. The scope is a simple string. The checker component uses the scope, to decide on allowing access to the path.

Each user is defined by

Configuration of a reverse proxy

An example configuration is provided in [demo/config.yaml].

The service can get customised via a special configuration that is located at /etc/authomator/config.yaml

[https://caddyserver.com/docs/caddyfile/directives/forward_auth]

Development

For external services I use ngrok to expose the development tool chain to real domains.

The development toolchain consists of the reverse proxy and a protected ressource container as well as the autho service. In order to keep everybody happy, the reverse proxy is running all the time during development.

> docker compose -f demo/proxy.yaml up -d --remove-orphans # send to background
> docker compose -f demo/compose.yaml up --build           # adding --remove orphans here kills the reverse proxy

In a second Terminal start ngrok

> ngrok http 8080

The first stack runs in the background as we are hardly concerned with its logs.

The second component is interactively running, so we can see the logs from authomator.

When the development session is complete, run the following steps:

  1. Terminate ngrok with ^C.
  2. Terminate authomator with ^C
  3. Terminate the reverse proxy with docker compose -f demo/proxy.yaml down