概述
Casdoor允许使用其他OAuth应用程序作为登录方法。
目前,Casdoor支持多个OAuth应用程序提供商。 一旦这些提供商被添加到Casdoor中,它们的图标将会在登录和注册页面上显示。 以下是Casdoor支持的提供商:
| 提供者 | Logo | 提供者 | Logo | 提供者 | Logo | 提供者 | Logo |
|---|---|---|---|---|---|---|---|
| ADFS | 支付宝 | 亚马逊 | 苹果 | ||||
| Auth0 | Azure AD | Azure AD B2C | 百度 | ||||
| Bilibili | Bitbucket | 盒子 | Casdoor | ||||
| Cloud Foundry | Dailymotion | Deezer | DigitalOcean | ||||
| 钉钉 | Discord | Tiktok | Dropbox | ||||
| Eve Online | Fitbit | Gitea | |||||
| Gitee | GitHub | GitLab | |||||
| Heroku | InfluxCloud | 信息流 | |||||
| Intercom | Kakao | Lark | Lastfm | ||||
| 线 | Mailru | Meetup | |||||
| 微软 | Naver | Nextcloud | Okta | ||||
| OneDrive | Oura | Patreon | PayPal | ||||
| Salesforce | Shopify | Slack | |||||
| SoundCloud | Spotify | Steam | Strava | ||||
| Stripe | Telegram | TikTok | Tumblr | ||||
| Twitch | Typetalk | Uber | |||||
| VK | 微信 | WeCom | 微博 | ||||
| WePay | Xero | Yahoo | Yammer | ||||
| Yandex | Zoom | 电子邮件 | 短信 | ||||
| Battle.net |
我们将向您展示如何申请第三方服务并将其添加到Casdoor。
申请成为开发者
在此之前,你需要理解一些概念。
- RedirectUrl, 认证后重定向地址, 填写您的应用程序地址, 例如
https://forum.casbin.com/ - Scope,用户授予您的权限,如基本个人资料,电子邮件地址和帖子及其他。
- ClientId/AppId, ClientKey/AppSecret, 这是最重要的信息 而且这是您在申请开发者帐户后需要得到的信息。 您 无法与任何人共享 的密钥。
添加 OAuth 提供商
- 前往您的Casdoor首页。
- 点击顶部栏中的
Providers。 - 点击
Add,您将会看到新的提供商被添加到顶部的列表中。 - 点击新的提供商以对其进行更改。
- 在
Category部分中,选择OAuth。 - 从
Type下拉菜单中选择您需要的特定OAuth提供商。 - 填写必要的信息,例如
Client ID和Client Secret。
User Field Mapping
OAuth providers often return additional user information beyond the standard profile fields. Casdoor's User Mapping feature allows you to automatically populate user profile fields from OAuth claims returned by your identity provider. This is particularly useful when integrating with enterprise identity providers like Okta, Azure AD, or other custom OAuth services that provide rich user metadata.
Automatic Account Linking
When users authenticate via OAuth, Casdoor automatically attempts to link accounts using multiple strategies: existing OAuth links, email/phone matching (if enabled), and case-insensitive username matching. This is particularly useful for enterprises with existing users who want to enable OAuth authentication without requiring manual account linking.
OAuth Provider Token Access
After users authenticate through OAuth providers, Casdoor stores the provider's access token in the user object. Your application can retrieve this token via the /api/get-account API to make authenticated calls to the third-party provider's APIs (e.g., GitHub API, Google Drive API) on behalf of the user. The token is only visible to the user themselves or organization admins. See the OAuth documentation for details.
应用程序设置
- 点击顶部栏中的
Application,然后选择要编辑的应用程序。 - 点击提供商添加按钮,并选择新添加的提供商。
- 修改提供商的权限,例如启用注册、登录和解绑。
- 你已经准备好了!