Skip to content

Fix: add auth headers and body to multitenancy token request#908

Merged
esune merged 4 commits intoopenwallet-foundation:mainfrom
MonolithicMonk:fix/acapy-multitenancy-auth-headers
Nov 28, 2025
Merged

Fix: add auth headers and body to multitenancy token request#908
esune merged 4 commits intoopenwallet-foundation:mainfrom
MonolithicMonk:fix/acapy-multitenancy-auth-headers

Conversation

@MonolithicMonk
Copy link
Contributor

Description:

  • Reference: Closes ACA-Py Multitenancy Token Request Fails with 401 Unauthorized #895
  • Summary:
    • Modified MultiTenantAcapy.get_wallet_token to include Admin API key headers when configured.
    • Added wallet_key to the request body payload as required by the endpoint.
    • Refactored SingleTenantAcapy.get_headers to return an empty dict instead of None values when keys are missing.
    • Updated MultiTenantAcapy to raise Exception instead of AssertionError for better error handling.
    • Updated tests to reflect new implementation logic and error handling.
  • Impact: Fixes 401 Unauthorized errors when the controller attempts to get a wallet token from a secured ACA-Py agent instance.

@coveralls
Copy link

coveralls commented Nov 21, 2025

Pull Request Test Coverage Report for Build 19772814756

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 87.711%

Totals Coverage Status
Change from base Build 19772812094: 0.08%
Covered Lines: 1927
Relevant Lines: 2197

💛 - Coveralls

@MonolithicMonk MonolithicMonk force-pushed the fix/acapy-multitenancy-auth-headers branch from 5bb27f0 to 0531ff3 Compare November 22, 2025 14:06
@loneil loneil requested a review from Copilot November 26, 2025 06:39
@loneil loneil force-pushed the fix/acapy-multitenancy-auth-headers branch from 0531ff3 to 060295c Compare November 26, 2025 06:40
@loneil
Copy link
Contributor

loneil commented Nov 26, 2025

rebased

Copy link
Contributor

Copilot AI left a comment

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 fixes a bug where the OIDC controller failed to authenticate with secured ACA-Py instances when requesting wallet tokens. The fix adds proper authentication headers and the required wallet_key parameter to the multitenancy token request endpoint.

Key Changes:

  • Modified MultiTenantAcapy.get_wallet_token to include Admin API key headers when configured and add wallet_key to the request body
  • Refactored error handling from assert statements to explicit Exception raising with improved logging
  • Updated SingleTenantAcapy.get_headers to return empty dict instead of dict with None values when API key is not configured

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
oidc-controller/api/core/acapy/config.py Added authentication header logic and request body payload to get_wallet_token, improved error handling with explicit exceptions, and modified SingleTenantAcapy.get_headers to handle missing credentials gracefully
oidc-controller/api/core/acapy/tests/test_config.py Added comprehensive tests for authenticated and unauthenticated scenarios, updated existing error test to expect Exception instead of AssertionError, and added test for SingleTenantAcapy with missing API key

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@loneil
Copy link
Contributor

loneil commented Nov 26, 2025

Tested out locally with our usual single tenant/no-key setup and that's still working for me. Some minor Copilot suggestions that could be looked at. Didn't try out any mult-tenant setup but implementation makes sense to me

Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

Tested locally, everything works as expected on a multi-tenant instance of ACA-Py. I think addressing the couple comments from Copilot is beneficial, then we can merge.

@MonolithicMonk MonolithicMonk force-pushed the fix/acapy-multitenancy-auth-headers branch from 060295c to 68c4e6b Compare November 28, 2025 19:40
@esune esune merged commit 756ad51 into openwallet-foundation:main Nov 28, 2025
6 checks passed
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.

ACA-Py Multitenancy Token Request Fails with 401 Unauthorized

5 participants