Skip to content

Add permission-gated SPAPI credential lookup for mail services#502

Merged
jdelic merged 1 commit into
developfrom
copilot/add-permission-check-to-authserver-get-credentials
Apr 28, 2026
Merged

Add permission-gated SPAPI credential lookup for mail services#502
jdelic merged 1 commit into
developfrom
copilot/add-permission-check-to-authserver-get-credentials

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

SPAPI credential lookups currently return active users without considering application-level authorization, which leaves IMAP/SMTP consumers unable to gate access on MNUser permissions. This change adds a permission-aware credential lookup variant for Dovecot/OpenSMTPD-style integrations while preserving the existing unscoped function.

  • What changes

    • Added authserver_get_credentials(varchar, varchar) as a permission-gated overload of the existing SPAPI credential lookup.
    • The new variant only returns credentials when the owning MNUser has the requested permission, either directly or through an assigned group.
    • The existing single-argument authserver_get_credentials(varchar) behavior remains unchanged.
  • Permission evaluation

    • Added a DB-side helper to resolve application permissions by permission_name.
    • Checks both:
      • direct user permissions (app_permissions)
      • inherited group permissions (app_groups -> group_permissions)
    • Applies the same authorization gate to both mailbox logins and service-user logins.
  • SPAPI integration

    • Registered the new overloaded function in SPAPI install/check/grant/revoke handling so database users can execute it like the rest of the stored procedure API.
    • Corrected signature aggregation in SPAPI install/access checks so all registered functions are evaluated.
  • Coverage and docs

    • Added tests for:
      • direct permission access
      • group-inherited permission access
      • denied access when the permission is missing
    • Updated the SPAPI function reference in README.rst.
  • Usage

    SELECT username, password, primary_alias
    FROM authserver_get_credentials('svc-alice', 'mail.smtp');

@jdelic jdelic marked this pull request as ready for review April 28, 2026 06:30
@jdelic jdelic merged commit 38ed370 into develop Apr 28, 2026
5 checks passed
@jdelic jdelic deleted the copilot/add-permission-check-to-authserver-get-credentials branch April 28, 2026 20:43
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.

2 participants