Skip to content

[BUG] Duplicate Domain Prevents Path‑Scoped Role Protection #2229

@soakes

Description

@soakes

Describe the Bug

Cannot create second resource on same domain with different path prefix and role (duplicate‑domain error)

Environment

To Reproduce

  1. In Pangolin, ensure you have:

    • A single domain configured, for example example.com.
    • At least two roles / groups, for example:
      • admins
      • users (non‑admin)
  2. In Pangolin, create a public resource (or application) using this domain:

    • Domain: example.com
    • Path prefix: / (or leave as root)
    • Access / authorization: assign role/group users
    • Save the resource – it is created successfully.
  3. Attempt to create a second resource for the same domain, but scoped to an admin‑only path:

    • Domain: example.com
    • Path prefix: /admin
    • Access / authorization: assign role/group admins only
    • Try to save the new resource.
  4. Observe that Pangolin refuses to create the second resource and displays an error similar to:

    Error creating resource
    Resource with that domain already

Expected Behavior

It should be possible to:

  • Define multiple resources on the same domain as long as they have different path prefixes (for example / and /admin).
  • Attach different roles / policies to different prefixes so that:
    • / (or other non‑privileged paths) can be accessible to general users.
    • /admin (or other admin paths) can be restricted to admins only, even though both are under example.com.

In other words, the uniqueness constraint should apply to the (domain, path prefix) pair, not just the bare domain, so that separate resources can protect different path segments under the same host.


Actual Behavior

  • When creating the second resource for example.com with a different path prefix (e.g. /admin) and a different role:

    • Pangolin rejects the configuration and shows:

      Error creating resource
      Resource with that domain already

  • This effectively forces all traffic for that domain to be governed by a single resource and a single set of roles, which means:

    • Either /admin must be left accessible to all roles assigned to the root resource, or
    • The entire domain has to be locked down to admins, which is not practical when admins and non‑admins share the same host.

Additional Context

Impact / Why This Is a Bug

Many real‑world applications host multiple areas under the same domain with different access requirements, such as:

  • / – public or general‑user area
  • /admin – sensitive administrative UI

With the current behavior:

  • It is not possible to express "allow only admins to /admin, but allow all users to /" using separate resources, because the second resource is blocked by the duplicate‑domain check.
  • Administrators are forced to:
    • Either expose /admin to all users that can reach example.com, or
    • Split the application across multiple domains/subdomains purely to work around the limitation.

Functionally, this feels like a bug / design oversight in the resource uniqueness logic rather than an intentional restriction, because:

  • The UI and configuration model both support a path prefix field.
  • Path prefixes are a natural place to apply separate authorization policies.

This limitation weakens security for shared domains and makes it harder to model common app layouts without restructuring DNS or the application itself.

Suggestions

  • The error message is technically correct (a resource already exists for that domain), but in practice too strict, because:
    • The second resource uses a different path prefix and different roles.
  • A more flexible and intuitive model would:
    • Allow multiple resources per domain as long as their path prefixes are not overlapping/conflicting, or
    • At minimum allow two resources when one uses / and the other uses a more specific prefix such as /admin.
  • This would let administrators:
    • Lock down /admin (or any other sensitive path) to admins,
    • While keeping the rest of the site accessible to other roles/groups,
    • Without introducing extra domains or subdomains solely for access control.

If any logs or config snippets would help troubleshoot, they can be provided as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions