feat(auth): authentik OIDC + admin SSO グループ同期#11
Open
Mikuto0831 wants to merge 3 commits into
Open
Conversation
- authentik を OIDC プロバイダーとして追加 (AUTHENTIK_CLIENT_ID 等の env var で有効化)
- OIDCClaims に Groups フィールドを追加 (ID Token の groups クレームを抽出)
- ADMIN_GROUPS 環境変数でグループ名を指定すると、ログイン時に自動でロールを同期:
グループ一致 → role = admin / 不一致 → role = student
未設定のときは従来通りロールを変更しない (手動 DB UPDATE で昇格)
- UserRepository.UpsertWithIdentity に roleHint を追加
既存ユーザーと新規ユーザーの両方でロールを上書き可能に
authentik の設定手順:
1. Provider に OAuth2/OIDC を作成し Client ID/Secret を控える
2. Scopes に groups マッピングを追加 (Property Mapping で groups クレームを発行)
3. ADMIN_GROUPS に authentik 上の admin グループ名を設定
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- AUTH_BYPASS=true のセクションを削除し、デフォルト false であることを明記
- 管理者登録方法を 2 つに整理:
A. DB 直接 UPDATE(初回・手動セットアップ向け)
B. authentik グループによる自動同期(本番環境向け)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
AUTHENTIK_CLIENT_ID等の env var で有効化)OIDCClaims.Groupsフィールドを追加し、ID Token のgroupsクレームを抽出ADMIN_GROUPS環境変数で admin グループ名を指定するとログイン時にロールを自動同期UserRepository.UpsertWithIdentityにroleHint引数を追加admin SSO の動作フロー
ADMIN_GROUPS未設定のときはロールを変更しない(従来通り手動 DB UPDATE で昇格可能)。authentik 側の設定手順
https://dailycoding.lcn.ad.jp/api/auth/authentik/callbackを登録groupsProperty Mapping を追加(これにより ID Token に
groupsクレームが含まれるようになる).env.prodに追記:Test plan
/api/auth/meに role が返ることADMIN_GROUPS未設定時に既存ユーザーのロールが変化しないこと🤖 Generated with Claude Code