feat(auth): unified team lead authorization for roles and individual members - #45
Merged
Merged
Conversation
…members - Add guild_lead_users table and Alembic migration 0003_add_guild_lead_users - Implement IGuildLeadUserRepository port, Postgres repo adapter, and UoW wiring - Expand AuthService.can_manage_projects to authorize individual team lead members - Add /pm admin lead slash command supporting both role and user assignments (with /pm admin lead-role alias) - Update interactive admin UI to TeamLeadsAdminView with RoleSelect and UserSelect pickers - Auto-prune individual lead records on member departure in on_member_remove - Update wiki documentation for teams, authorization matrix, and slash commands - Add unit, repository, cog, and menu tests Closes #44
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.
Summary of Changes
Follows up on PR #43 and closes #44 by expanding the Team Lead authorization model so Server Managers can authorize both Discord roles and individual Discord members to create and manage projects and squads using unified commands and UI.
1. Database Schema & Migrations
GuildLeadUserTable(guild_lead_userswith composite primary key(guild_id, user_discord_id)and indexed foreign-key lookups) insrc/adapters/db/tables.py.0003_add_guild_lead_users.py.IGuildLeadUserRepositoryport andPostgresGuildLeadUserRepositoryadapter insrc/adapters/db/postgres_repo.py.guild_lead_usersintoIUnitOfWorkandSqlAlchemyUnitOfWork.2. Domain & Authorization Services
AuthService.can_manage_projects(user, guild_id, guild)andrequire_project_managementto authorize:manage_guild/administrator).guild_lead_users).guild_lead_roles).add_guild_lead_user,remove_guild_lead_user, andlist_guild_lead_userstoAuthService.guild_lead_user_repoinPmHubView,forum_helpers, andmain.py.3. Slash Commands (
/pm admin lead)/pm admin lead action:<add|remove|list> role:<@Role> user:<@Member>inPmCog./pm admin lead-roleas a backwards-compatible alias.4. Interactive Discord UI (
TeamLeadsAdminView)/pm menubutton label withTeam Leads.TeamLeadsAdminViewwith native DiscordRoleSelectandUserSelectpickers and 1-clickAssign/Removeactions for both roles and members.LeadRolesAdminView = TeamLeadsAdminViewalias for backwards compatibility.5. Self-Healing on Server Departure
DggPmBot.on_member_removeto automatically prune individual lead user entries fromguild_lead_userswhen a member leaves the server.6. Documentation
docs/wiki/Teams-and-Authorization.mdwith updated hierarchy diagrams, mutation authorization matrix, and departure lifecycle details.docs/wiki/Slash-Commands-Reference.mddetailing/pm admin leadand updated permission scopes.Testing & Verification
direnv exec . uv run pytest).ruff check .(0 errors) andruff format --check .(clean).tests/test_migrations.pyall passing.docker compose up -d --build app.Closes #44