feat: Discord OAuth и платформонезависимый Web Dashboard (issue #34) #91

Closed
Toutsu wants to merge 0 commits from feature/issue-34-discord-oauth-dashboard into main
Owner

Summary

Реализует Discord OAuth 2.0 login flow для Web Dashboard (issue #34) и рефакторит слой авторизации на платформонезависимую модель. Discord- и Telegram-аккаунты полностью разделены — никакой связи между ними.

Changes

  • Добавлен Discord OAuth Authorization Code Flow (identify + guilds scopes)
  • Платформонезависимая идентификация через (platform, external_user_id) вместо long telegram_id
  • Cookie Authentication с ClaimsPrincipal: Platform, DiscordId/TelegramId, AvatarUrl
  • Все Razor Pages переведены на *ForCurrentUserAsync API
  • Backward-compatible constructors для WebGameGroup и WebGroupManager
  • Тесты: DiscordAuthServiceTests, PlatformIdentityTests, обновлённые AuthorizedSessionServiceTests

Test plan

  • dotnet build проходит
  • Все 265 тестов проходят (dotnet test)
  • Версия синхронизирована → 2.8.0

Workflow

  • CI passes
  • Code review approved
  • Deployed
  • Release published
## Summary Реализует Discord OAuth 2.0 login flow для Web Dashboard (issue #34) и рефакторит слой авторизации на платформонезависимую модель. Discord- и Telegram-аккаунты полностью разделены — никакой связи между ними. ## Changes - Добавлен Discord OAuth Authorization Code Flow (`identify` + `guilds` scopes) - Платформонезависимая идентификация через `(platform, external_user_id)` вместо `long telegram_id` - Cookie Authentication с ClaimsPrincipal: `Platform`, `DiscordId`/`TelegramId`, `AvatarUrl` - Все Razor Pages переведены на `*ForCurrentUserAsync` API - Backward-compatible constructors для `WebGameGroup` и `WebGroupManager` - Тесты: `DiscordAuthServiceTests`, `PlatformIdentityTests`, обновлённые `AuthorizedSessionServiceTests` ## Test plan - [x] `dotnet build` проходит - [x] Все 265 тестов проходят (`dotnet test`) - [x] Версия синхронизирована → 2.8.0 ## Workflow - [ ] CI passes - [ ] Code review approved - [ ] Deployed - [ ] Release published
Toutsu added 6 commits 2026-05-25 11:49:10 +03:00
- DiscordOAuthOptions for client_id, secret, redirect_uri
- DiscordAuthService exchanges code for token and fetches user profile
- /auth/discord and /auth/discord/callback endpoints
- CreateDiscordPrincipal for cookie auth claims
- Telegram principal now includes Platform claim for forward compatibility

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- TryGetPlatformIdentity returns (platform, external_user_id)
- TryGetDiscordId for Discord-specific flows
- Backward-compatible fallback for legacy Telegram auth without Platform claim
- GetAvatarUrl helper for Discord avatars

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- ISessionStore: all methods use (platform, external_user_id)
- SessionService: updated SQL queries and added UpsertDiscordUserAsync
- AuthorizedSessionService: resolves identity from HttpContext, no longer accepts telegram_id params
- SessionAccessDeniedException now accepts string externalUserId
- Added ExternalUserId/ExternalUsername to WebGroupManager and WebParticipant

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Discord login button on /login with brand colors
- NavMenu shows user avatar (Discord) and platform label
- CSS: login-divider, login-btn-discord, nav-user-info, nav-user-platform
- NavMenu version bumped to v2.8.0

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- DiscordAuthServiceTests: authorize URL, token exchange, profile fetch
- PlatformIdentityTests: Telegram fallback, Discord identity, avatar URL

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feat(web): finalize Discord OAuth and platform-agnostic auth
PR Checks / test-and-build (pull_request) Successful in 5m47s
50f5307aac
- Bump version to 2.8.0 across all versioned files
- Fix AuthorizedSessionServiceTests for platform-agnostic identity
- Update Razor Pages to use *ForCurrentUserAsync APIs
- Add backward-compatible constructors to WebGameGroup/WebGroupManager
- Make DiscordOAuthOptions properties non-required for config binding

Bump version → 2.8.0

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Toutsu added 1 commit 2026-05-25 12:08:36 +03:00
fix(web): address PR review critical issues for Discord OAuth
PR Checks / test-and-build (pull_request) Successful in 6m6s
66dc53f12f
- Add V019 migration: rename session_audit_log.actor_telegram_id → actor_external_user_id
- Add CSRF protection to Discord OAuth flow (state cookie with HttpOnly/Secure/Strict)
- Add Discord OAuth env vars to compose.yaml, deploy.yml, and .env.example
- Fix SQL COALESCE for nullable telegram_id in GetGroupManagersAsync and GetSessionParticipantsAsync

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Toutsu closed this pull request 2026-05-25 13:31:38 +03:00
Some checks are pending
PR Checks / test-and-build (pull_request) Successful in 6m6s

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Toutsu/GmRelayBot#91