Skip to content

fix(discord): propagate role authorization to gateway auth - #34993

Closed
chrometh wants to merge 1 commit into
NousResearch:mainfrom
chrometh:fix/discord-role-authorization-upstream
Closed

fix(discord): propagate role authorization to gateway auth#34993
chrometh wants to merge 1 commit into
NousResearch:mainfrom
chrometh:fix/discord-role-authorization-upstream

Conversation

@chrometh

Copy link
Copy Markdown

Summary

  • Carry adapter-verified Discord role authorization through SessionSource
  • Let GatewayRunner accept messages already verified against DISCORD_ALLOWED_ROLES
  • Preserve existing user allowlist and bot filtering behavior

Test Plan

  • env -u HERMES_CRON_SESSION -u HERMES_CRON_AUTO_DELIVER_CHAT_ID -u HERMES_CRON_AUTO_DELIVER_PLATFORM python -m pytest -q tests/gateway/test_discord_component_auth.py tests/gateway/test_discord_slash_auth.py tests/gateway/test_discord_roles_dm_scope.py tests/gateway/test_discord_bot_auth_bypass.py tests/gateway/test_discord_channel_controls.py → 86 passed
  • gitleaks git --redact=100 --log-opts='origin/main..HEAD' → 0 findings

… works end-to-end

DISCORD_ALLOWED_ROLES was checked by the Discord adapter (_is_allowed_user)
but gateway._is_user_authorized only read DISCORD_ALLOWED_USERS, so
role-authorized users were rejected with "Unauthorized user" at the
gateway layer despite passing the adapter gate.

- Add role_authorized: bool = False to SessionSource
- Add role_authorized param to build_source (base.py)
- Compute _role_authorized in on_message when user passes via role not user ID
- Thread _role_authorized through _handle_message -> build_source
- Check source.role_authorized early in _is_user_authorized (run.py)

Fixes NousResearch#33952
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate/competing: Competing fix for #33952 — same approach as #33958 (role_authorized field on SessionSource). Also related to closed #33993.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter area/auth Authentication, OAuth, credential pools duplicate This issue or pull request already exists labels May 29, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Discord authorization fix. This is already implemented on main; the member's duplicate/competing note correctly points to the landed approach.

  • Automated hermes-sweeper review verified commit e5580f43c258552b5951b2680a1ac044bab3e5df (fix(discord): propagate role_authorized flag so DISCORD_ALLOWED_ROLES works end-to-end) is an ancestor of current main.
  • plugins/platforms/discord/adapter.py:1157-1206 verifies the sender and forwards role_authorized; gateway/platforms/base.py:5470-5493 carries it into SessionSource.
  • gateway/authz_mixin.py:431-437 authorizes only the adapter-verified boolean flag.
  • The fix shipped in v2026.6.19.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/discord Discord bot adapter sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants