-
Notifications
You must be signed in to change notification settings - Fork 56
Add get_token_scope method to ClaimsIdentity and update token handling in ChannelServiceAdapter and RestChannelServiceClientFactory #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add get_token_scope method to ClaimsIdentity and update token handling in ChannelServiceAdapter and RestChannelServiceClientFactory #290
Conversation
…g in ChannelServiceAdapter and RestChannelServiceClientFactory
There was a problem hiding this 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 pull request centralizes token scope determination logic by introducing a new get_token_scope method to the ClaimsIdentity class. The changes eliminate duplicate scope construction logic across multiple files and add JWT authorization middleware to the echo proactive agent sample.
Changes:
- Added
get_token_scope()method toClaimsIdentityfor centralized token scope retrieval - Refactored
ChannelServiceAdapterandRestChannelServiceClientFactoryto use the new centralized method - Added JWT authorization middleware to the echo proactive agent sample for improved request authorization
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/claims_identity.py |
Added new get_token_scope() method to centralize token scope logic |
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py |
Removed duplicate scope logic and now uses claims_identity.get_token_scope() |
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py |
Updated to use claims_identity.get_token_scope() instead of inline scope construction |
test_samples/app_style/echo_proactive_agent.py |
Added JWT authorization middleware to the sample application |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/claims_identity.py
Outdated
Show resolved
Hide resolved
...oft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py
Show resolved
Hide resolved
...oft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py
Show resolved
Hide resolved
...microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/claims_identity.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/claims_identity.py
Show resolved
Hide resolved
...microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/claims_identity.py
Show resolved
Hide resolved
|
@MattB-msft I've opened a new pull request, #291, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@MattB-msft I've opened a new pull request, #292, to work on those changes. Once the pull request is ready, I'll request review from you. |
…//github.com/microsoft/Agents-for-python into users/mbarbour/updateProactiveScopeAuthFlows
|
@MattB-msft I've opened a new pull request, #293, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces improvements to how token scopes are determined and utilized throughout the agent hosting core, aiming for more consistent and centralized handling. The main changes include the addition of a new method for retrieving token scopes from claims, refactoring of scope assignment in several places to use this method, and an update to the echo proactive agent sample to include JWT authorization middleware.
Token scope handling improvements:
get_token_scopetoClaimsIdentityfor retrieving the appropriate token scope based on the claim type, centralizing scope logic.process_activity(inchannel_service_adapter.py) to useclaims_identity.get_token_scope()instead of duplicating scope logic.create_connector_clientandcreate_user_token_clientto use the new centralizedget_token_scopemethod for consistency. [1] [2]Sample and middleware updates:
jwt_authorization_middlewareimport and applied it as a middleware in theecho_proactive_agent.pysample app to improve request authorization handling. [1] [2]