コア概念
Casdoor には 4 つのコアオブジェクトがあります: 組織、ユーザー、アプリケーション、およびプロバイダー。組織にはユーザーとアプリケーションが含まれます。ユーザーはアプリケーションを通じてサインインします。アプリケーションはプロバイダーを使用してサインイン方法を提供し、メッセージを送信します。
このページの例では、デモサイト https://door.casdoor.com を使用しています。
組織
組織はユーザーとアプリケーションのためのコンテナです。通常、組織は会社の従業員や製品の顧客を表します。複数の組織が 1 つの Casdoor インスタンスを共有でき、各組織には独自のユーザー、アプリケーション、パスワードルール、ブランド設定があります。
| Property | Description |
|---|---|
owner | Always admin for organizations |
name | Unique name of the organization, for example built-in |
displayName | Name shown in the UI |
websiteUrl | Website of the organization |
passwordType | Algorithm used to store the passwords of the organization's users |
defaultAvatar | Avatar given to new users |
enableSoftDeletion | Marks deleted users as deleted but keeps them in the database |
accountItems | Fields shown on the account page of a user, and who can view and edit them |
組織の設定については、Organizations を参照してください。
ユーザー
ユーザーはサインインできるアカウントです。各ユーザーは正確に 1 つの組織に属し、その組織のすべてのアプリケーションにサインインできます。
Casdoor には 2 種類のユーザーがいます:
built-in組織のユーザー (built-in/adminなど): Casdoor インスタンス全体を完全に制御するグローバル管理者。- 他の組織のユーザー (
my-company/aliceなど): サインアップ、サインイン、サインアウトができ、自分のプロフィールを管理できる一般ユーザー。
ユーザー ID
ユーザーには 2 つの識別子があります:
| Identifier | Example | Use it for |
|---|---|---|
<organization>/<username> | built-in/admin | Calls to the Casdoor API |
id | d835a48f-2e88-4c1f-b907-60ac6b6c1b40 | A stable user ID in your own application. It is a UUID |
アプリケーションで 1 つの組織のみを使用する場合、アプリケーション内のユーザー ID として <username> だけを使用できます。
ユーザーのプロパティ
| Property | Description |
|---|---|
owner | Name of the organization that the user belongs to |
name | Username, unique within the organization |
id | UUID of the user |
displayName | Name shown in the UI |
avatar | URL of the avatar image |
email, phone | Contact details, also used for verification codes |
password | Password, stored in the form that the organization's passwordType defines |
isAdmin | Whether the user is an administrator of the organization |
isForbidden | Whether the user is blocked from signing in |
isDeleted | Whether the user is soft-deleted |
signupApplication | Application through which the user signed up |
github, google, wechat, and so on | ID of the user at each linked identity provider |
ldap | ID of the user in the LDAP directory that the user was synchronized from |
properties | Key-value map for your own attributes |
Casdoor にフィールドが存在しない属性には properties を使用してください。Using the Properties field を参照してください。フィールドの完全なリストについては、Users を参照してください。
アプリケーション
アプリケーションは、Casdoor でユーザーをサインインさせる Web サービスです (例えばフォーラム、社内オフィスシステム、顧客関係管理システムなど)。アプリケーションは 1 つの組織に属し、その組織のユーザーがどのようにサインインするかに関する設定を保持します。
| Property | Description |
|---|---|
owner | Always admin for applications |
name | Unique name of the application, for example app-built-in |
organization | Organization whose users can sign in to the application |
clientId, clientSecret | OAuth 2.0 credentials of the application |
redirectUris | URLs that Casdoor may send users back to after sign-in |
providers | Providers that the application offers on its sign-in and sign-up pages |
signupItems | Fields of the sign-up page |
enablePassword | Whether users can sign in with a password |
enableSignUp | Whether new users can sign up |
tokenFormat | Format of the access tokens that Casdoor issues for the application |
expireInHours, refreshExpireInHours | Lifetime of access tokens and refresh tokens |
cert | Certificate that signs the tokens |
アプリケーションの設定については、Application configuration を参照してください。
サインインページとサインアップページ
ユーザーは常にアプリケーションを通じてサインインします。各アプリケーションには独自のサインインページとサインアップページがあります。ルートパス /login は、Casdoor が自身の管理コンソール用に作成したアプリケーション app-built-in のサインインページです。
| アプリケーション | Sign-up page | Sign-in page |
|---|---|---|
app-built-in | https://door.casdoor.com/signup | https://door.casdoor.com/login |
app-casnode | https://door.casdoor.com/signup/app-casnode | https://door.casdoor.com/login/oauth/authorize?client_id=014ae4bd048734ca2dea&response_type=code&redirect_uri=http://localhost:9000/callback&scope=read&state=casdoor |
app-casbin-oa | https://door.casdoor.com/signup/app-casbin-oa | https://door.casdoor.com/login/oauth/authorize?client_id=0ba528121ea87b3eb54d&response_type=code&redirect_uri=http://localhost:9000/callback&scope=read&state=casdoor |
サインイン URL とサインアップ URL
ユーザーを独自アプリケーションのページへ誘導するには、URL を自分で構築するか、SDK に構築させます。
URL を自分で構築する
| Page | URL |
|---|---|
| Sign-up page of an application | <casdoor-host>/signup/<application-name> |
| OAuth 2.0 で続くサインアップページ | <casdoor-host>/signup/oauth/authorize?client_id=<client-id>&response_type=code&redirect_uri=<redirect-uri>&scope=read&state=<state> |
| Sign-in page of an organization | <casdoor-host>/login/<organization-name> |
| Sign-in page that continues with OAuth 2.0 | <casdoor-host>/login/oauth/authorize?client_id=<client-id>&response_type=code&redirect_uri=<redirect-uri>&scope=read&state=<state> |
フロントエンド SDK を使用する
React、Vue、Angular アプリケーションでは、casdoor-js-sdk の getSignupUrl() および getSigninUrl() を呼び出します。
バックエンド SDK を使用する
Go、Java などのバックエンドでは、SDK の同等の関数を呼び出します。例えば casdoor-go-sdk の GetSignupUrl() および GetSigninUrl() です。
プロバイダー
プロバイダーは Casdoor を外部サービスに接続します。Casdoor は OAuth 2.0、OpenID Connect (OIDC)、SAML を通じて外部アイデンティティプロバイダーへのサインインをフェデレーションします。また、メールや SMS の送信、ファイルの保存、キャプチャの表示、支払いの処理のために外部サービスを使用します。これらの接続のそれぞれがプロバイダーです。
プロバイダーを一度作成し、それを使用するアプリケーションに追加します。
| Property | Description |
|---|---|
owner | admin for a provider that all organizations share, or the name of the organization that owns it |
name | Unique name of the provider |
category | Kind of provider, for example OAuth, SAML, Email, SMS, Storage, Captcha, or Payment |
type | Service behind the provider, for example GitHub, Google, or Twilio SMS |
clientId, clientSecret | Credentials that the external service issues to Casdoor |
host, port | Server address, for example of an SMTP server |
endpoint, bucket, domain | Location settings of storage providers |
metadata, issuerUrl | Settings of SAML identity providers |
すべてのプロバイダーカテゴリとタイプについては、Providers を参照してください。
組み込みオブジェクト
Casdoor は同じ 4 つのオブジェクトを使って自身を管理します。初回起動時に以下を作成します:
| Object | Name | Purpose |
|---|---|---|
| Organization | built-in | Holds the administrators of the Casdoor instance |
| User | built-in/admin | First global administrator |
| Application | app-built-in | The Casdoor admin console itself |
built-in 組織のすべてのユーザーはグローバル管理者です。管理者を追加するには、built-in にさらにユーザーを作成します。見知らぬ人が管理者になるのを防ぐため、app-built-in のサインアップをオフにしてください。
管理コンソールまたは API を通じて、built-in 組織、built-in/admin ユーザー、app-built-in アプリケーションの名前を変更したり削除したりすることはできません。これらの名前はハードコードされています。データベースで変更または削除すると、Casdoor が破損する可能性があります。