メインコンテンツにスキップ

コア概念

Casdoor には 4 つのコアオブジェクトがあります: 組織、ユーザー、アプリケーション、およびプロバイダー。組織にはユーザーとアプリケーションが含まれます。ユーザーはアプリケーションを通じてサインインします。アプリケーションはプロバイダーを使用してサインイン方法を提供し、メッセージを送信します。

このページの例では、デモサイト https://door.casdoor.com を使用しています。

組織​

組織はユーザーとアプリケーションのためのコンテナです。通常、組織は会社の従業員や製品の顧客を表します。複数の組織が 1 つの Casdoor インスタンスを共有でき、各組織には独自のユーザー、アプリケーション、パスワードルール、ブランド設定があります。

PropertyDescription
ownerAlways admin for organizations
nameUnique name of the organization, for example built-in
displayNameName shown in the UI
websiteUrlWebsite of the organization
passwordTypeAlgorithm used to store the passwords of the organization's users
defaultAvatarAvatar given to new users
enableSoftDeletionMarks deleted users as deleted but keeps them in the database
accountItemsFields 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 つの識別子があります:

IdentifierExampleUse it for
<organization>/<username>built-in/adminCalls to the Casdoor API
idd835a48f-2e88-4c1f-b907-60ac6b6c1b40A stable user ID in your own application. It is a UUID
ヒント

アプリケーションで 1 つの組織のみを使用する場合、アプリケーション内のユーザー ID として <username> だけを使用できます。

ユーザーのプロパティ​

PropertyDescription
ownerName of the organization that the user belongs to
nameUsername, unique within the organization
idUUID of the user
displayNameName shown in the UI
avatarURL of the avatar image
email, phoneContact details, also used for verification codes
passwordPassword, stored in the form that the organization's passwordType defines
isAdminWhether the user is an administrator of the organization
isForbiddenWhether the user is blocked from signing in
isDeletedWhether the user is soft-deleted
signupApplicationApplication through which the user signed up
github, google, wechat, and so onID of the user at each linked identity provider
ldapID of the user in the LDAP directory that the user was synchronized from
propertiesKey-value map for your own attributes

Casdoor にフィールドが存在しない属性には properties を使用してください。Using the Properties field を参照してください。フィールドの完全なリストについては、Users を参照してください。

アプリケーション​

アプリケーションは、Casdoor でユーザーをサインインさせる Web サービスです (例えばフォーラム、社内オフィスシステム、顧客関係管理システムなど)。アプリケーションは 1 つの組織に属し、その組織のユーザーがどのようにサインインするかに関する設定を保持します。

PropertyDescription
ownerAlways admin for applications
nameUnique name of the application, for example app-built-in
organizationOrganization whose users can sign in to the application
clientId, clientSecretOAuth 2.0 credentials of the application
redirectUrisURLs that Casdoor may send users back to after sign-in
providersProviders that the application offers on its sign-in and sign-up pages
signupItemsFields of the sign-up page
enablePasswordWhether users can sign in with a password
enableSignUpWhether new users can sign up
tokenFormatFormat of the access tokens that Casdoor issues for the application
expireInHours, refreshExpireInHoursLifetime of access tokens and refresh tokens
certCertificate that signs the tokens

アプリケーションの設定については、Application configuration を参照してください。

サインインページとサインアップページ​

ユーザーは常にアプリケーションを通じてサインインします。各アプリケーションには独自のサインインページとサインアップページがあります。ルートパス /login は、Casdoor が自身の管理コンソール用に作成したアプリケーション app-built-in のサインインページです。

アプリケーションSign-up pageSign-in page
app-built-inhttps://door.casdoor.com/signuphttps://door.casdoor.com/login
app-casnodehttps://door.casdoor.com/signup/app-casnodehttps://door.casdoor.com/login/oauth/authorize?client_id=014ae4bd048734ca2dea&response_type=code&redirect_uri=http://localhost:9000/callback&scope=read&state=casdoor
app-casbin-oahttps://door.casdoor.com/signup/app-casbin-oahttps://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 を自分で構築する​

PageURL
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 の送信、ファイルの保存、キャプチャの表示、支払いの処理のために外部サービスを使用します。これらの接続のそれぞれがプロバイダーです。

プロバイダーを一度作成し、それを使用するアプリケーションに追加します。

PropertyDescription
owneradmin for a provider that all organizations share, or the name of the organization that owns it
nameUnique name of the provider
categoryKind of provider, for example OAuth, SAML, Email, SMS, Storage, Captcha, or Payment
typeService behind the provider, for example GitHub, Google, or Twilio SMS
clientId, clientSecretCredentials that the external service issues to Casdoor
host, portServer address, for example of an SMTP server
endpoint, bucket, domainLocation settings of storage providers
metadata, issuerUrlSettings of SAML identity providers

すべてのプロバイダーカテゴリとタイプについては、Providers を参照してください。

組み込みオブジェクト​

Casdoor は同じ 4 つのオブジェクトを使って自身を管理します。初回起動時に以下を作成します:

ObjectNamePurpose
Organizationbuilt-inHolds the administrators of the Casdoor instance
Userbuilt-in/adminFirst global administrator
Applicationapp-built-inThe Casdoor admin console itself

built-in 組織のすべてのユーザーはグローバル管理者です。管理者を追加するには、built-in にさらにユーザーを作成します。見知らぬ人が管理者になるのを防ぐため、app-built-in のサインアップをオフにしてください。

注意

管理コンソールまたは API を通じて、built-in 組織、built-in/admin ユーザー、app-built-in アプリケーションの名前を変更したり削除したりすることはできません。これらの名前はハードコードされています。データベースで変更または削除すると、Casdoor が破損する可能性があります。

関連項目​