Skip to content

tenants: fix base URL validation rejecting internal hostnames - #25560

Open
emilburzo wants to merge 6 commits into
mainfrom
fix-baseurl-strictness
Open

tenants: fix base URL validation rejecting internal hostnames#25560
emilburzo wants to merge 6 commits into
mainfrom
fix-baseurl-strictness

Conversation

@emilburzo

Copy link
Copy Markdown
Member

Fixes #25546

@emilburzo emilburzo self-assigned this Aug 28, 2026
@emilburzo emilburzo added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Aug 28, 2026
@emilburzo emilburzo moved this from Todo to In Progress in authentik Core Aug 28, 2026
@emilburzo emilburzo added this to the Release 2026.8.1 milestone Aug 28, 2026
@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 405ae38
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a9153ebffa49d00080f06d3
😎 Deploy Preview https://deploy-preview-25560--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@emilburzo
emilburzo marked this pull request as ready for review August 28, 2026 09:29
@emilburzo
emilburzo requested review from a team as code owners August 28, 2026 09:29
Copilot AI lite review requested due to automatic review settings August 28, 2026 09:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses overly strict base URL validation in authentik tenants, which was rejecting valid internal hostnames (e.g. https://auth.svr001) during initial setup and when saving system settings (Issue #25546).

Changes:

  • Relax base URL validation by replacing strict URLField/URLValidator behavior with a custom validate_base_url helper and a DRF BaseURLField.
  • Update the OOBE (initial setup) flow validation to use the shared tenant base URL validation helper.
  • Regenerate the OpenAPI schema so base_url is no longer emitted as format: uri, and add/extend tests covering internal hostnames and backfill behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
schema.yml Removes format: uri for base_url so clients/UIs don’t apply overly strict “URI format” validation.
blueprints/default/flow-oobe.yaml Switches OOBE base URL validation to normalize_base_url + validate_base_url.
authentik/tenants/utils.py Adds validate_base_url helper (and related imports) to centralize base URL validation.
authentik/tenants/api/settings.py Adds BaseURLField and uses it in the settings serializer to relax DRF validation and normalize input.
authentik/tenants/apps.py Ensures reconciliation/backfill validates a candidate base URL and discards invalid values safely.
authentik/tenants/tests/test_validate_base_url.py Adds unit tests for the new helper and expected accepted/rejected patterns.
authentik/tenants/tests/test_base_url_settings.py Adds API tests confirming internal hostnames are accepted and settings remain saveable.
authentik/tenants/tests/test_base_url_backfill.py Adds backfill test ensuring invalid outpost host values are discarded and warnings are logged.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread authentik/tenants/utils.py Outdated
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.69%. Comparing base (8890ee2) to head (e3a5185).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25560      +/-   ##
==========================================
+ Coverage   91.67%   91.69%   +0.02%     
==========================================
  Files        1151     1152       +1     
  Lines       73416    73503      +87     
  Branches     4054     4054              
==========================================
+ Hits        67301    67396      +95     
+ Misses       6073     6065       -8     
  Partials       42       42              
Flag Coverage Δ
conformance 34.37% <4.08%> (-0.04%) ⬇️
e2e 39.02% <4.08%> (-0.05%) ⬇️
integration 30.97% <4.08%> (-0.04%) ⬇️
rust 42.92% <ø> (ø)
unit 93.24% <100.00%> (+0.02%) ⬆️
unit-migrate 93.26% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-e3a5185cf13171c2e2f7cdabe3a3e100ac105760
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-e3a5185cf13171c2e2f7cdabe3a3e100ac105760

Afterwards, run the upgrade commands from the latest release notes.

Comment thread authentik/tenants/api/settings.py Outdated
Comment on lines +80 to +86
base_url = CharField(
required=False,
allow_blank=True,
max_length=200,
help_text=Tenant._meta.get_field("base_url").help_text,
validators=[BASE_URL_VALIDATOR],
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The validator should be set on the model field instead, which allows you to remove this, and a bunch more of the validation code that you added on this PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did try that, but because the model field is models.URLField, I could not get rid of the URLValidator. it seems validators = [...] only appends to the list of validators, it doesn't replace it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah yeah, I forgot about that. In that case, change the model field to become:

base_url = models.TextField(validators=[DomainlessURLValidator(...)])

@emilburzo emilburzo Aug 28, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

that introduces a migration though, right? do we want that? since this needs to be backported to .8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's fine for this. It will change the column type from varchar(200) to text which is painless in postgres. Especially for a table with 1 row

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went with models.CharField and max length 200 instead, so that there's no DDL change at all.

Why: concerned about upgrades/downgrades and any surprises with the data during conversions.

@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit fb1ed40
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a91a3e312674a00083812cf
😎 Deploy Preview https://deploy-preview-25560--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

base url invalid

3 participants