Skip to content

NGINX auth_request module support, additional service LABELs for automated setup#281

Open
runleveldev wants to merge 10 commits intomainfrom
rgingras/223-integrate-ozwell-api-with-the-manager-webui
Open

NGINX auth_request module support, additional service LABELs for automated setup#281
runleveldev wants to merge 10 commits intomainfrom
rgingras/223-integrate-ozwell-api-with-the-manager-webui

Conversation

@runleveldev
Copy link
Copy Markdown
Collaborator

@runleveldev runleveldev commented Apr 9, 2026

Authentication updates: https://youtube.com/shorts/f5uIQzKqglQ?si=3yYa5_fx7VXXnQtQ

Ozwell Studio related automation: https://youtube.com/shorts/0cGmEpbwLF8?si=vyI6LGKLoK5BwPD3

Related to mieweb/ozwell-studio#2

Copilot Summary

This pull request introduces authentication support for HTTP services using NGINX's auth_request protocol, allowing certain HTTP endpoints to require user authentication via a configurable auth server per external domain. It also updates the data models, API, and session cookie handling to support these features. Additionally, it adds a new /verify endpoint for lightweight authentication checks and refines how HTTP services and external domains are managed and exposed.

Authentication for HTTP Services:

  • Added an authRequired boolean column to the HTTPServices model and database table, enabling per-service authentication requirements. This is reflected in service creation, update, and API schemas. [1] [2] [3] [4] [5] [6] [7]
  • Updated the OpenAPI spec and container router logic to support listing multiple HTTP services per container, each with its own authentication requirement. [1] [2] [3]

External Domain Auth Server Support:

  • Added an authServer string column to the ExternalDomains model and database table, allowing each domain to specify an auth server URL for use with auth_request. [1] [2] [3]
  • Updated external domain creation and update routes to handle the new authServer field. [1] [2]

NGINX Auth Protocol Implementation:

  • Introduced a new /verify endpoint that implements the NGINX auth_request protocol, supporting both session and API key authentication, and returning user identity headers if authenticated.
  • Adjusted session cookie settings to share cookies across sibling subdomains, enabling seamless authentication for services on different subdomains.

Security and Utility Improvements:

  • Enhanced redirect safety logic in the login route to allow redirects to sibling domains, using a new utility function and domain whitelist. [1] [2]
  • Updated the session middleware and logging to skip /verify requests for efficiency. [1] [2]

Dependency Update:

  • Updated the express-session package from 1.18.2 to 1.19.0 to ensure compatibility and security. [1] [2] [3]

Add per-service authRequired flag for HTTP services. When enabled, NGINX
uses auth_request to verify authentication via the manager app before
proxying requests. Unauthenticated users are redirected to the login page
with a cross-domain redirect back to the original URL.

Changes:
- Add authRequired boolean to HTTPService model
- Add managerUrl field to ExternalDomain model
- Add GET /verify endpoint for NGINX auth_request subrequests
- Update NGINX template with auth_request blocks and login redirect
- Add isSafeRedirectUrl() for cross-domain redirect validation
- Update login router to allow safe cross-domain redirects
- Update container and external-domain forms with new fields
- Upgrade express-session to 1.19 for dynamic cookie domain support
- Add auth-unavailable error page for misconfigured services
- Update OpenAPI spec

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@runleveldev runleveldev linked an issue Apr 9, 2026 that may be closed by this pull request
Add support for named OCI labels to define multiple HTTP services
with per-service configuration:
  org.mieweb.opensource-server.services.http.<name>.port
  org.mieweb.opensource-server.services.http.<name>.hostnameSuffix
  org.mieweb.opensource-server.services.http.<name>.requireAuth

The form auto-populates services from image metadata, building
external hostnames as <hostname>-<suffix> and setting the auth flag.

The existing default-port label remains supported for backward
compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
runleveldev and others added 2 commits April 9, 2026 11:01
The HTTP column now displays all HTTP services for each container
instead of only the first one. Each entry is a clickable link when
an external URL is configured.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@runleveldev runleveldev changed the title feat: add nginx auth_request support for HTTP services NGINX auth_request module support, additional service LABELs for automated setup Apr 9, 2026
runleveldev and others added 2 commits April 9, 2026 11:21
The /verify endpoint is called by NGINX auth_request on every proxied
request. Its 401 responses for unauthenticated users were counting
against the rate limit, quickly blocking legitimate traffic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
NGINX auth_request subrequests to /verify fire on every proxied
request, drowning out meaningful log entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@runleveldev runleveldev force-pushed the rgingras/223-integrate-ozwell-api-with-the-manager-webui branch from 7303a30 to 1b076ef Compare April 9, 2026 15:31
@runleveldev runleveldev marked this pull request as ready for review April 9, 2026 15:42
runleveldev and others added 3 commits April 10, 2026 09:51
- external-domains.md: auth server config, requirements, identity headers,
  cookie sharing, and Mermaid auth flow diagram
- docker-images.md: named service labels (port, hostnameSuffix, requireAuth)
  with examples
- database-schema.md: authRequired on HTTPServices, authServer on
  ExternalDomains with updated descriptions and ERD
- system-architecture.md: authenticated HTTP services sequence diagram
- containers.md: auth note under Service Exposure

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

docs: move service labels to user docs

Move the Service Labels section from developers/docker-images.md into
users/creating-containers/using-environment-variables.mdx (Building
Custom Templates). Add a typo warning and update cross-references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove isValidHostname utility function and replace with Sequelize
'is' regex validation on Container.hostname and HTTPService.externalHostname.
Validation now happens at the model layer instead of the router.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove proxy, dev, serve-with-proxy custom scripts and concurrently
devDependency. The proxy-server.js file was already removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@runleveldev runleveldev force-pushed the rgingras/223-integrate-ozwell-api-with-the-manager-webui branch from 6356fbe to 8907d78 Compare April 10, 2026 13:51
Add proxy_cache for auth_request subrequests keyed on Cookie and
Authorization headers. 200s cached 5m, 401s cached 30s. Cache
invalidates automatically when credentials change.

Revert the /verify skip from morgan and express-rate-limit since
NGINX caching eliminates the high request volume to the auth server.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@Bobzemob Bobzemob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate Ozwell-API with the Manager WebUI

3 participants