Adding user info in plugin context and pass it to hooks#2510
Merged
crivetimihai merged 1 commit intoIBM:mainfrom Jan 27, 2026
Merged
Adding user info in plugin context and pass it to hooks#2510crivetimihai merged 1 commit intoIBM:mainfrom
crivetimihai merged 1 commit intoIBM:mainfrom
Conversation
Add user information (email, full_name, is_admin) to the plugin global context, enabling plugins like Cedar RBAC to make access control decisions based on user attributes beyond just email. Changes: - Add _inject_userinfo_instate() function to auth.py that populates global_context.user as a dictionary when include_user_info is enabled - Update GlobalContext.user type to Union[str, dict] for backward compat - Add include_user_info config option to plugin_settings (default: false) - Prevent tool_service from overwriting user dict with string email The feature is disabled by default to maintain backward compatibility with existing plugins that expect global_context.user to be a string. Co-authored-by: Mihai Criveti <crivetimihai@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
e5f5cea to
0571dd5
Compare
Member
Changes Made During ReviewThe PR has been rebased onto 1. Default Value Changed (Breaking Change Prevention)Changed Files:
2. Type Annotation FixFixed the type annotation in # Before
def _inject_userinfo_instate(request: Optional[object] = None, user: EmailUser = None) -> None:
# After
def _inject_userinfo_instate(request: Optional[object] = None, user: Optional[EmailUser] = None) -> None:3. Commits SquashedSquashed 4 commits into 1 clean commit with proper sign-off and co-authorship. Follow-up Recommendation: Update Cedar PluginFor full functionality with this feature, the Cedar plugin should be updated in a follow-up PR to handle the new dict format when user = context.global_context.user # expects string
user_role = self.jwt_info["users"].get(user) # will fail if user is dictThe Cedar plugin should be updated to extract the email when user = context.global_context.user
if isinstance(user, dict):
user_email = user.get("email", "")
is_admin = user.get("is_admin", False)
full_name = user.get("full_name", "")
else:
user_email = user or ""This would enable Cedar to leverage the additional user attributes (is_admin, full_name) for more granular RBAC decisions. |
crivetimihai
approved these changes
Jan 27, 2026
hughhennelly
pushed a commit
to hughhennelly/mcp-context-forge
that referenced
this pull request
Feb 8, 2026
Add user information (email, full_name, is_admin) to the plugin global context, enabling plugins like Cedar RBAC to make access control decisions based on user attributes beyond just email. Changes: - Add _inject_userinfo_instate() function to auth.py that populates global_context.user as a dictionary when include_user_info is enabled - Update GlobalContext.user type to Union[str, dict] for backward compat - Add include_user_info config option to plugin_settings (default: false) - Prevent tool_service from overwriting user dict with string email The feature is disabled by default to maintain backward compatibility with existing plugins that expect global_context.user to be a string. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com> Signed-off-by: hughhennnelly <hughhennelly06@gmail.com>
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
Add user information (email, full_name, is_admin) to the plugin global context, enabling plugins like Cedar RBAC to make access control decisions based on user attributes beyond just email. Changes: - Add _inject_userinfo_instate() function to auth.py that populates global_context.user as a dictionary when include_user_info is enabled - Update GlobalContext.user type to Union[str, dict] for backward compat - Add include_user_info config option to plugin_settings (default: false) - Prevent tool_service from overwriting user dict with string email The feature is disabled by default to maintain backward compatibility with existing plugins that expect global_context.user to be a string. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.
Description:
This pull request updates how user information is propagated from tool invocations from the UI to the Cedar plugin (and other potential plugins). Previously, only the user’s email address was included in the plugin context.
With this change, user information is now passed as a dictionary in the global plugin context, containing:
full_name: The user’s full nameemail: The user’s email addressis_admin: A boolean flag indicating if the user has administrative privilegesAs part of the authentication flow in auth.py, this dictionary is stored in
request.state.plugin_global_context, making user attributes readily accessible to the Cedar RBAC plugin for policy enforcement.This enhancement enables more granular access control decisions based on user attributes beyond email, aligning with the RBAC model implemented in the Cedar plugin.
For plugins to have this information,
added a key
include_user_infoin plugin_settings inplugins/config.yamlfile for pluginsGlobal plugin settings