Skip to content

feat(BA-4838): add NoAuth strategy and BackendAIClientRegistry to webserver#9595

Merged
fregataa merged 8 commits intomainfrom
feature/BA-4838
Mar 6, 2026
Merged

feat(BA-4838): add NoAuth strategy and BackendAIClientRegistry to webserver#9595
fregataa merged 8 commits intomainfrom
feature/BA-4838

Conversation

@fregataa
Copy link
Member

@fregataa fregataa commented Mar 3, 2026

Summary

  • Add NoAuth(AuthStrategy) to client/v2/auth.py that returns empty headers from sign(), for use by the webserver which has no real keypair
  • Replace anon_client_ctx / app["anon_client"] with client_registry_ctx / app["client_registry"] using BackendAIClientRegistry.create(config, NoAuth())
  • Extract build_forwarding_headers() as a reusable pure function and refactor fill_forwarding_hdrs_to_api_session() to use it internally

Test plan

  • Verify webserver starts without errors
  • Verify app["client_registry"] is accessible and properly initialized
  • Verify login/logout/update-password flows still work

Resolves BA-4838

🤖 Generated with Claude Code

@github-actions github-actions bot added the size:M 30~100 LoC label Mar 3, 2026
@github-actions github-actions bot added the comp:webserver Related to Web Server component label Mar 3, 2026
fregataa added a commit that referenced this pull request Mar 3, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa fregataa added this to the 26.3 milestone Mar 3, 2026
@fregataa fregataa marked this pull request as ready for review March 3, 2026 07:26
@fregataa fregataa requested review from a team and Copilot March 3, 2026 07:26
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 introduces a persistent v2 anonymous Backend.AI client on the webserver app and refactors forwarding-header construction into a reusable helper, aligning request proxying behavior across different HTTP callers.

Changes:

  • Extract build_forwarding_headers(request) in web/auth.py and refactor fill_forwarding_hdrs_to_api_session() to use it.
  • Add anon_client_ctx() in web/server.py to create/close a persistent BackendAIAnonymousClient (v2) and register it on app["anon_client"] via AsyncExitStack.
  • Add a changelog entry documenting the new persistent anon client and header builder extraction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/ai/backend/web/server.py Adds an async context manager to create/close a v2 anonymous client and registers it on the app lifecycle.
src/ai/backend/web/auth.py Introduces build_forwarding_headers() and refactors existing session header population to use it.
changes/9595.feature.md Documents the new persistent v2 anonymous client and forwarding header helper extraction.

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

@fregataa fregataa requested review from a team and jopemachine March 3, 2026 08:05
fregataa added a commit that referenced this pull request Mar 3, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa fregataa force-pushed the feature/BA-4838 branch 2 times, most recently from 15d42ea to db1555c Compare March 5, 2026 02:23
@github-actions github-actions bot added the comp:client Related to Client component label Mar 5, 2026
@fregataa fregataa changed the title feat(BA-4838): Register persistent v2 anonymous client on webserver app feat(BA-4838): add NoAuth strategy and BackendAIClientRegistry to webserver Mar 5, 2026
@fregataa fregataa requested a review from ironAiken2 March 5, 2026 02:42
fregataa added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added size:L 100~500 LoC and removed size:M 30~100 LoC labels Mar 5, 2026
@fregataa fregataa requested a review from jopemachine March 5, 2026 08:11
fregataa added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa fregataa requested a review from a team March 5, 2026 12:31
ironAiken2
ironAiken2 previously approved these changes Mar 6, 2026
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

LGTM

fregataa and others added 8 commits March 6, 2026 14:01
Extract build_forwarding_headers() as a pure function in web/auth.py,
refactor fill_forwarding_hdrs_to_api_session() to use it, and add
anon_client_ctx() context manager registered as app["anon_client"].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aders

- Create aiohttp.ClientSession with TCPConnector(limit=connection_limit)
  for the anonymous client to match webserver concurrency settings
- Fix docstring in build_forwarding_headers() to accurately describe usage
- Remove redundant `if _headers:` guard since the dict is always non-empty

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oAuth strategy

- Add NoAuth(AuthStrategy) that returns empty headers from sign()
- Replace anon_client_ctx/app["anon_client"] with client_registry_ctx/app["client_registry"]
- Use BackendAIClientRegistry.create() as a single facade for auth and anon clients

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ndler

- Add extra_headers support to BackendAIAuthClient._request() and typed_request()
- Add extra_headers passthrough to AuthClient.update_password_no_auth()
- Replace v1 APISession-based anonymous call with registry.auth.update_password_no_auth()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clarify that the registry uses NoAuth strategy by reflecting it in the name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

LGTM

@fregataa fregataa merged commit c77e24f into main Mar 6, 2026
23 checks passed
@fregataa fregataa deleted the feature/BA-4838 branch March 6, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:client Related to Client component comp:webserver Related to Web Server component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants