Implement auto signin handler#882
Open
sw-joelmut wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic sign-in functionality for the UserAuthorization flow, allowing users to be automatically authenticated on first interaction with the application. The implementation introduces a new structured configuration format (userAuthorization) while maintaining backward compatibility with the legacy authorization format.
Changes:
- Added new
UserAuthorizationOptionsinterface withautoSignIn,defaultHandlerName, andhandlersproperties - Implemented auto sign-in logic in
AuthorizationManager.process()that uses the default or first available handler when enabled - Deprecated the flat
authorizationconfiguration in favor of nesteduserAuthorization.handlersstructure - Added environment variable support for
AGENTAPPLICATION__USERAUTHORIZATION__DEFAULTHANDLERNAMEandAGENTAPPLICATION__USERAUTHORIZATION__AUTOSIGNIN
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/agents-hosting/src/app/auth/types.ts | Defines new types and interfaces for UserAuthorizationOptions, AuthorizationHandlers, and AutoSignInSelector; deprecates old AuthorizationOptions type |
| packages/agents-hosting/src/app/auth/authorizationManager.ts | Implements normalizeOptions() for backward compatibility, adds auto sign-in logic in process() method, improves type validation |
| packages/agents-hosting/src/app/agentApplicationOptions.ts | Adds userAuthorization property and deprecates authorization property |
| packages/agents-hosting/src/app/agentApplicationBuilder.ts | Adds overloaded withAuthorization() method with type guard to support both old and new formats |
| packages/agents-hosting/src/app/agentApplication.ts | Updates authorization checks to support both userAuthorization and authorization properties |
| packages/agents-hosting/test/hosting/app/authorization.test.ts | Updates error message assertion to match new implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #857
Important
This PR will most likely conflict with PR #872
Description
This PR adds automatic sign-in capability to the
UserAuthorizationflow, allowing users to be automatically authenticated when first interacting with the application.Additionally, the authorization configuration changed to include this feature and stays close to .NET settings.
New
userAuthorizationconfiguration options:autoSignIn- A selector function to enable/disable automatic sign-in per contextdefaultHandlerName- Specifies which handler to use for auto sign-inhandlers- New structured format for configuring authorization handlersEnvironment variables support:
AGENTAPPLICATION__USERAUTHORIZATION__DEFAULTHANDLERNAMEAGENTAPPLICATION__USERAUTHORIZATION__AUTOSIGNINExample usage:
AgentApplicationOptions.authorizationAgentApplicationOptions.userAuthorizationAgentApplicationBuilder.withAuthorization(AuthorizationOptions)AgentApplicationBuilder.withAuthorization(UserAuthorizationOptions)AuthorizationOptionstype (flat structure)UserAuthorizationOptionswith nestedhandlersconfigMigration example:
Testing
The following image shows the feature working.
