1.7 KiB
1.7 KiB
Auth Proxy
Simple Express proxy that requires a login screen before forwarding requests to an upstream site.
Usage
- Create a
config.json(or copyconfig.example.json) in the project root and configure one or more hosts. Each host can have anoidcsection to point to a Keycloak/OpenID Provider.
Example config.json (copy from config.example.json and edit):
[ ... ]
- Set environment variables in a
.envfile (optional):
PORT=3000
SESSION_SECRET=change-me
- Install and run:
npm install
npm start
- Open
http://localhost:3000— if a host requires OIDC you'll be redirected to Keycloak for login. After a successful OIDC flow the proxy stores tokens in the session and forwards requests to the configured upstream.
Notes
- For OIDC hosts you must create a Keycloak client (confidential) with an appropriate redirect URI matching the host
redirect_uri(e.g.http://localhost:3000/callback/app1). - This is a demo scaffold: replace the simple in-memory
USERSstore, hard-coded session handling, and consider using a persistent session store and HTTPS in production. - The proxy injects
Authorization: Bearer <access_token>when available andX-Forwarded-Userwith the authenticated username.
Admin web UI
- There is a minimal admin interface at
http://localhost:3000/adminto manage hosts (create/edit/delete) and reload OIDC clients. - Default admin credentials are read from environment variables
ADMIN_USER/ADMIN_PASS(defaults toadmin/admin). - When you save hosts in the admin UI they are persisted to
config.jsonin the project root.
Security notes
- Protect the admin UI behind strong credentials and run the proxy with HTTPS in production.