Repository navigation
Closed
Description
Summary
Restore user mode support that allows the gateway to distinguish between bot operations and human-attributed operations. This is important for scenarios where commits should be attributed to a personal GitHub account rather than the bot.
Background
jib supports two authentication modes:
- Bot mode: Operations attributed to the GitHub App bot identity
- User mode: Operations attributed to a personal GitHub account (via PAT)
The egg extraction simplified this to bot-only mode, losing user mode capabilities.
Components to Update
1. gateway/policy.py
Add auth_mode parameter to these methods:
check_branch_ownership(repo, branch, auth_mode="bot")check_pr_ownership(repo, pr_number, auth_mode="bot")
Add missing method:
check_pr_create_allowed(repo, auth_mode="bot")- blocks PR creation in user mode
Add configured user support:
_get_configured_user()- get GitHub username from config_is_configured_user_author()- check if PR/branch author matches configured user
Add branch existence check for user mode:
branch_exists()check to allow pushing to NEW branches in user mode- Fail-closed logic when API check fails
2. gateway/github_client.py
Add user mode validation:
is_user_token_valid()- check if user token is configuredget_authenticated_user()- get GitHub username for authenticated tokenvalidate_user_mode_config()- validate user token matches configured github_userget_user_mode_client()- convenience function for user mode client
Add private mode enforcement:
GH_COMMANDS_BLOCKED_IN_PRIVATE_MODEconstant (blocksgh search)
3. gateway/repo_config.py
Extend to full functionality (currently only 3 functions):
get_github_username()get_writable_repos()/get_readable_repos()is_writable_repo()/is_readable_repo()get_default_reviewer()get_auth_mode(repo)- returns "bot" or "user"is_user_mode_repo(repo)get_user_mode_config()- git_name, git_email, github_userget_bot_username()
4. gateway/gateway.py
Pass auth_mode to policy checks:
policy_result = policy.check_branch_ownership(repo, branch, auth_mode=auth_mode)Acceptance Criteria
-
auth_modeparameter added to policy methods -
check_pr_create_allowed()method implemented - Configured user support in policy checks
- Branch existence check with fail-closed logic
- User mode validation in github_client
- Full repo_config.py functionality
- Gateway passes auth_mode to policy checks
- Documentation updated for user mode configuration
Reference
- jib policy.py:
james-in-a-box/gateway-sidecar/policy.py - jib github_client.py:
james-in-a-box/gateway-sidecar/github_client.py - jib repo_config.py:
james-in-a-box/config/repo_config.py
Authored-by: jib
Metadata
Metadata
Assignees
Labels
No labels
Activity
Phase 2c: User mode support (auth_mode awareness)
jwbron commentedon Feb 3, 2026
#21
Phase 2c: User mode support (auth_mode awareness) (#21)
plan(1557): address reviewer_plan NACK — fix two-query JQL + 10 non-b…