OpenID Connect対応。個人/Workspaceアカウントをサポート。
ソーシャルログイン
ソーシャルログイン(外部IDプロバイダー連携)を使用することで、ユーザーは既存のGoogle、Microsoft、GitHubアカウントを使ってAuthrimにログインできます。
対応プロバイダー
Microsoft
Entra ID(旧Azure AD)対応。マルチテナント、組織、個人アカウントをサポート。
GitHub
OAuth 2.0対応。GitHub Enterprise Serverもサポート。
カスタム
任意のOIDC/OAuth 2.0準拠プロバイダーを設定可能。
なぜソーシャルログインを使うのか?
ユーザー体験の向上
- 既存アカウントでのワンクリックログイン
- パスワード不要
- 登録障壁の低減
セキュリティの強化
- 大手プロバイダーの認証基盤を活用
- MFA/2FAを外部IdPに委任可能
- パスワード管理の負担軽減
JITプロビジョニング
- 初回ログイン時に自動ユーザー作成
- メールによる自動アカウントリンク
- 属性マッピングによるプロファイル同期
認証フロー
sequenceDiagram
participant User
participant App as アプリケーション
participant Authrim
participant ExtIdP as 外部IdP
User->>App: 1. "Login with GitHub" クリック
App->>Authrim: 2. GET /auth/external/github/start
Authrim->>Authrim: 3. state, nonce, PKCE生成
Authrim-->>User: 4. 外部IdPへリダイレクト
User->>ExtIdP: 5. 認証画面
ExtIdP->>ExtIdP: 6. ユーザー認証
ExtIdP-->>Authrim: 7. コールバック (認可コード)
Authrim->>ExtIdP: 8. トークン交換
ExtIdP-->>Authrim: 9. アクセストークン
Authrim->>ExtIdP: 10. ユーザー情報取得
ExtIdP-->>Authrim: 11. ユーザー情報
Authrim->>Authrim: 12. アカウントリンク処理
Authrim-->>User: 13. セッション作成 + リダイレクト
User->>App: 14. 認証完了
プロバイダー設定
-
Google Cloud Console にアクセス
-
APIs & Services → Credentials → Create Credentials → OAuth client ID
-
Application type: Web application を選択
-
Authorized redirect URIs に追加:
https://your-domain.com/auth/external/google/callback -
Client ID と Client Secret を取得
-
Admin API でプロバイダー登録:
Terminal window curl -X POST "https://your-domain.com/external-idp/admin/providers" \-H "Authorization: Bearer ${ADMIN_API_SECRET}" \-H "Content-Type: application/json" \-d '{"template": "google","name": "Google","slug": "google","client_id": "YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com","client_secret": "YOUR_GOOGLE_CLIENT_SECRET"}'
-
Azure Portal → Microsoft Entra ID → App registrations
-
New registration をクリック
-
Redirect URI に追加:
https://your-domain.com/auth/external/microsoft/callback -
Certificates & secrets → New client secret で秘密鍵を作成
-
Application (client) ID と Client Secret を取得
-
Admin API でプロバイダー登録:
Terminal window curl -X POST "https://your-domain.com/external-idp/admin/providers" \-H "Authorization: Bearer ${ADMIN_API_SECRET}" \-H "Content-Type: application/json" \-d '{"template": "microsoft","name": "Microsoft","slug": "microsoft","client_id": "YOUR_MICROSOFT_CLIENT_ID","client_secret": "YOUR_MICROSOFT_CLIENT_SECRET","provider_quirks": {"tenantType": "common"}}'
tenantType オプション:
| 値 | 説明 |
|---|---|
common | 全Microsoftアカウント(個人 + 組織) |
organizations | 組織アカウントのみ(Azure AD) |
consumers | 個人アカウントのみ(Outlook.com等) |
{tenant-id} | 特定テナントのみ |
-
OAuth Apps → New OAuth App
-
以下の情報を入力:
- Application name: アプリ名
- Homepage URL:
https://your-domain.com - Authorization callback URL:
https://your-domain.com/auth/external/github/callback
-
Register application をクリック
-
Client ID と Client Secret を取得
-
Admin API でプロバイダー登録:
Terminal window curl -X POST "https://your-domain.com/external-idp/admin/providers" \-H "Authorization: Bearer ${ADMIN_API_SECRET}" \-H "Content-Type: application/json" \-d '{"template": "github","name": "GitHub","slug": "github","client_id": "YOUR_GITHUB_CLIENT_ID","client_secret": "YOUR_GITHUB_CLIENT_SECRET"}'
OpenID Connect準拠のカスタムプロバイダーを設定できます:
curl -X POST "https://your-domain.com/external-idp/admin/providers" \ -H "Authorization: Bearer ${ADMIN_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "name": "Custom IdP", "slug": "custom-idp", "provider_type": "oidc", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET", "issuer": "https://idp.example.com", "scopes": "openid email profile" }'OIDC Discovery(/.well-known/openid-configuration)からエンドポイントが自動取得されます。
設定リファレンス
共通フィールド
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
name | string | ✅ | 表示名 |
slug | string | - | URLフレンドリーな識別子 |
client_id | string | ✅ | OAuth Client ID |
client_secret | string | ✅ | OAuth Client Secret |
enabled | boolean | - | 有効/無効(デフォルト: true) |
アイデンティティリンク
| フィールド | デフォルト | 説明 |
|---|---|---|
auto_link_email | true | メールでの自動アカウントリンク |
jit_provisioning | true | JITプロビジョニング(自動ユーザー作成) |
require_email_verified | true | 検証済みメール必須 |
ユーザーフローエンドポイント
認証開始
GET /auth/external/:provider/start?redirect_uri=https://app.example.com/callback| パラメータ | 必須 | 説明 |
|---|---|---|
redirect_uri | ✅ | 認証後のリダイレクト先 |
tenant_id | - | テナントID(マルチテナント時) |
user_id | - | リンク先ユーザーID(アカウントリンク時) |
セキュリティ
Authrimは以下のセキュリティ機能を自動的に適用します:
- PKCE: すべての外部IdP認証でS256方式のPKCEを使用
- State: CSRF攻撃防止のためのcryptographically secureなstateパラメータ
- Nonce: OIDCプロバイダーでのID Tokenリプレイ攻撃防止
- Client Secret暗号化: AES-256-GCMで暗号化して保存
- メール検証: デフォルトで検証済みメールのみ許可
トラブルシューティング
”Provider not found”
- プロバイダーが作成されているか確認
slugまたはidが正しいか確認enabled: trueか確認
”State validation failed”
- ユーザーが60秒以上かかっていないか確認
- 同じブラウザ/セッションでフローを完了しているか確認
- Cookieがブロックされていないか確認
”Provider did not return email”
- OAuth Appに適切なスコープ(
email)があるか確認 - GitHubの場合、
user:emailスコープが必要 - ユーザーがメールを設定しているか確認