|
| 1 | +# go-auth |
| 2 | + |
| 3 | +`go-auth` is a hosted authentication, authorization, TLS certificate, and LDAP management application. |
| 4 | +It combines three subsystems in one server process: |
| 5 | + |
| 6 | +- Auth management for local users, sessions, identity providers, and bearer tokens. |
| 7 | +- Certificate management for storing and working with TLS certificate material. |
| 8 | +- LDAP management for projecting users and groups into an LDAP directory. |
| 9 | + |
| 10 | +It requires a PostgreSQL database for storage and can be configured |
| 11 | +with environment variables and CLI flags. |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +Run the container: |
| 16 | + |
| 17 | +```bash |
| 18 | +export PG_URL='postgres://user@host.docker.internal/database?sslmode=prefer' |
| 19 | +docker run --rm --name go-auth \ |
| 20 | + -e PG_URL -e PG_PASSWORD \ |
| 21 | + -e ADDR=0.0.0.0:8084 \ |
| 22 | + -p 8084:8084 \ |
| 23 | + ghcr.io/mutablelogic/go-auth:latest |
| 24 | +``` |
| 25 | + |
| 26 | +Notes: |
| 27 | + |
| 28 | +- `PG_URL` is required. The service will not start without a PostgreSQL connection. |
| 29 | +- The image entrypoint is `authmanager` and the default command is `run`, so you only need to pass environment variables unless you want to add extra CLI flags. |
| 30 | + |
| 31 | +## Auth Parameters |
| 32 | + |
| 33 | +These parameters configure the authentication manager and identity provider integration. |
| 34 | + |
| 35 | +| Parameter | Type | Description | |
| 36 | +| --- | --- | --- | |
| 37 | +| `AUTH_SCHEMA` | env | Database schema used for auth tables. | |
| 38 | +| `AUTH_SESSION_TTL` | env | Session lifetime. Defaults to 15 minutes when unset. | |
| 39 | +| `AUTH_REFRESH_TTL` | env | Refresh token lifetime. Defaults to 7 days when unset. | |
| 40 | +| `GOOGLE_CLIENT_ID` | env | Enables the Google provider when set. | |
| 41 | +| `GOOGLE_CLIENT_SECRET` | env | Google OAuth client secret. | |
| 42 | +| `--auth.enabled` / `--no-auth` | cli | Enable or disable authentication on management endpoints. Default is enabled. | |
| 43 | +| `--auth.signer=file:///path/to/key.pem?kid=main` | cli | Add a private key PEM file used to sign issued tokens. Repeat to add multiple signers. | |
| 44 | +| `--local.enabled` / `--no-local.enabled` | cli | Enable or disable the built-in local browser-flow identity provider. Default is disabled. | |
| 45 | + |
| 46 | +Examples: |
| 47 | + |
| 48 | +```bash |
| 49 | +docker run --rm \ |
| 50 | + -p 8084:80 \ |
| 51 | + -e AUTHMANAGER_ADDR=:80 \ |
| 52 | + -e PG_URL='postgres://user:password@host.docker.internal/authdb?sslmode=disable' \ |
| 53 | + -e AUTH_SCHEMA='auth' \ |
| 54 | + -e AUTH_SESSION_TTL='30m' \ |
| 55 | + -e AUTH_REFRESH_TTL='168h' \ |
| 56 | + -e GOOGLE_CLIENT_ID='your-google-client-id' \ |
| 57 | + -e GOOGLE_CLIENT_SECRET='your-google-client-secret' \ |
| 58 | + "$IMAGE" |
| 59 | +``` |
| 60 | + |
| 61 | +## Cert Parameters |
| 62 | + |
| 63 | +These parameters configure the certificate manager. |
| 64 | + |
| 65 | +| Parameter | Type | Description | |
| 66 | +| --- | --- | --- | |
| 67 | +| `CERT_ENABLED` | env | Enable or disable the certificate manager. Default is `true`. | |
| 68 | +| `CERT_PASSPHRASE` | env | Passphrase used for encrypting private keys. Can be supplied multiple times in CLI usage; in Docker this is typically provided once per environment variable name supported by your runtime. | |
| 69 | +| `CERT_SCHEMA` | env | Database schema used for certificate tables. | |
| 70 | + |
| 71 | +Example: |
| 72 | + |
| 73 | +```bash |
| 74 | +docker run --rm \ |
| 75 | + -p 8084:80 \ |
| 76 | + -e AUTHMANAGER_ADDR=:80 \ |
| 77 | + -e PG_URL='postgres://user:password@host.docker.internal/authdb?sslmode=disable' \ |
| 78 | + -e CERT_ENABLED='true' \ |
| 79 | + -e CERT_SCHEMA='cert' \ |
| 80 | + -e CERT_PASSPHRASE='change-me' \ |
| 81 | + "$IMAGE" |
| 82 | +``` |
| 83 | + |
| 84 | +## LDAP Parameters |
| 85 | + |
| 86 | +These parameters configure the LDAP manager. The LDAP manager is only started when `LDAP_URL` is set. |
| 87 | + |
| 88 | +| Parameter | Type | Description | |
| 89 | +| --- | --- | --- | |
| 90 | +| `LDAP_URL` | env | LDAP server URL to connect to or manage. When unset, the LDAP manager is disabled. | |
| 91 | +| `LDAP_BASEDN` | env | Base DN for LDAP entries. Default is `dc=example,dc=org`. | |
| 92 | +| `LDAP_USER` | env | Bind user DN used by the LDAP manager. Default is `cn=admin,dc=example,dc=org`. | |
| 93 | +| `LDAP_PASS` | env | Bind password for the LDAP manager. | |
| 94 | +| `LDAP_USER_DN` | env | Relative DN for the user subtree, for example `ou=users`. | |
| 95 | +| `LDAP_GROUP_DN` | env | Relative DN for the group subtree, for example `ou=groups`. | |
| 96 | + |
| 97 | +Example: |
| 98 | + |
| 99 | +```bash |
| 100 | +docker run --rm \ |
| 101 | + -p 8084:80 \ |
| 102 | + -e AUTHMANAGER_ADDR=:80 \ |
| 103 | + -e PG_URL='postgres://user:password@host.docker.internal/authdb?sslmode=disable' \ |
| 104 | + -e LDAP_URL='ldap://ldap.example.org:389' \ |
| 105 | + -e LDAP_BASEDN='dc=example,dc=org' \ |
| 106 | + -e LDAP_USER='cn=admin,dc=example,dc=org' \ |
| 107 | + -e LDAP_PASS='change-me' \ |
| 108 | + -e LDAP_USER_DN='ou=users' \ |
| 109 | + -e LDAP_GROUP_DN='ou=groups' \ |
| 110 | + "$IMAGE" |
| 111 | +``` |
| 112 | + |
| 113 | +## Common Container Parameters |
| 114 | + |
| 115 | +These are not subsystem-specific, but they are usually required in Docker deployments: |
| 116 | + |
| 117 | +| Parameter | Type | Description | |
| 118 | +| --- | --- | --- | |
| 119 | +| `PG_URL` | env | PostgreSQL connection URL. Required for startup. | |
| 120 | +| `PG_PASSWORD` | env | PostgreSQL password override. | |
| 121 | +| `AUTHMANAGER_ADDR` | env | HTTP listen address. Set this to `:80` or `:443` in containers. | |
| 122 | +| `ADDR` | env | Alternate generic listen-address environment variable. | |
| 123 | +| `--http.prefix` | cli | HTTP API path prefix. Default is `/api`. | |
| 124 | +| `--http.timeout` | cli | HTTP server read/write timeout. Default is `15m`. | |
| 125 | +| `--http.origin` | cli | Cross-origin protection origin configuration. | |
| 126 | +| `--tls.name` | cli | TLS server name. | |
| 127 | +| `--tls.cert` | cli | TLS certificate file inside the container. | |
| 128 | +| `--tls.key` | cli | TLS private key file inside the container. | |
| 129 | +| `--ui` / `--no-ui` | cli | Enable or disable the embedded UI. Default is enabled. | |
| 130 | +| `--openapi` / `--no-openapi` | cli | Enable or disable the OpenAPI endpoints. Default is enabled. | |
| 131 | + |
| 132 | +If you mount certificate files into the container, a TLS-enabled run looks like this: |
| 133 | + |
| 134 | +```bash |
| 135 | +docker run --rm \ |
| 136 | + -p 8443:443 \ |
| 137 | + -e AUTHMANAGER_ADDR=:443 \ |
| 138 | + -e PG_URL='postgres://user:password@host.docker.internal/authdb?sslmode=disable' \ |
| 139 | + -v "$PWD/certs:/certs:ro" \ |
| 140 | + "$IMAGE" \ |
| 141 | + run --tls.cert=/certs/tls.crt --tls.key=/certs/tls.key |
| 142 | +``` |
0 commit comments