Concepts clés
Casdoor possède quatre objets principaux : les organisations, les utilisateurs, les applications et les fournisseurs. Une organisation contient des utilisateurs et des applications. Les utilisateurs se connectent via une application. Une application utilise des fournisseurs pour proposer des méthodes de connexion et envoyer des messages.
Les exemples de cette page utilisent le site de démonstration https://door.casdoor.com.
Organisation
Une organisation est un conteneur pour les utilisateurs et les applications. Une organisation représente généralement les employés d'une entreprise ou les clients d'un produit. Plusieurs organisations peuvent partager une seule instance Casdoor, et chaque organisation dispose de ses propres utilisateurs, applications, règles de mot de passe et identité visuelle.
| 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 |
Pour tous les paramètres d'une organisation, consultez Organisations.
Utilisateur
Un utilisateur est un compte pouvant se connecter. Chaque utilisateur appartient exactement à une organisation et peut se connecter à toutes les applications de cette organisation.
Casdoor propose deux types d'utilisateurs :
- Utilisateurs de l'organisation
built-in, tels quebuilt-in/admin: Administrateurs globaux ayant un contrôle total sur l'instance Casdoor. - Utilisateurs des autres organisations, tels que
my-company/alice: Utilisateurs classiques qui peuvent s'inscrire, se connecter, se déconnecter et gérer leur propre profil.
Identifiants d'utilisateur
Un utilisateur possède deux identifiants :
| 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 |
Si votre application n'utilise qu'une seule organisation, vous pouvez utiliser <username> seul comme ID utilisateur dans votre application.
Propriétés de l'utilisateur
| 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 |
Utilisez properties pour les attributs pour lesquels Casdoor ne possède pas de champ dédié. Consultez Utilisation du champ Properties. Pour la liste complète des champs, consultez Utilisateurs.
Application
Une application est un service web qui authentifie les utilisateurs avec Casdoor, par exemple un forum, un système interne de bureau ou un système de gestion de la relation client. Une application appartient à une organisation et contient les paramètres relatifs à la façon dont les utilisateurs de cette organisation s'y connectent.
| 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 |
Pour tous les paramètres d'une application, consultez Configuration de l'application.
Pages de connexion et d'inscription
Les utilisateurs se connectent toujours via une application. Chaque application dispose de ses propres pages de connexion et d'inscription. Le chemin racine /login correspond à la page de connexion de app-built-in, l'application que Casdoor crée pour sa propre console d'administration.
| Application | 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 |
URLs de connexion et d'inscription
Pour rediriger les utilisateurs vers les pages de votre propre application, construisez les URLs vous-même ou laissez un SDK les construire.
Construire les URLs vous-même
| Page | URL |
|---|---|
| Sign-up page of an application | <casdoor-host>/signup/<application-name> |
| Page d'inscription poursuivant avec 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> |
Utiliser un SDK frontend
Dans les applications React, Vue et Angular, appelez getSignupUrl() et getSigninUrl() de casdoor-js-sdk.
Utiliser un SDK backend
Dans les backends Go, Java et autres, appelez les fonctions équivalentes du SDK, par exemple GetSignupUrl() et GetSigninUrl() de casdoor-go-sdk.
Fournisseur
Un fournisseur connecte Casdoor à un service externe. Casdoor fédère la connexion vers des fournisseurs d'identité externes via OAuth 2.0, OpenID Connect (OIDC) et SAML. Il utilise également des services externes pour envoyer des e-mails et des SMS, stocker des fichiers, afficher des captchas et effectuer des paiements. Chacune de ces connexions est un fournisseur.
Vous créez un fournisseur une seule fois, puis vous l'ajoutez aux applications qui l'utilisent.
| 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 |
Pour toutes les catégories et types de fournisseurs, consultez Fournisseurs.
Objets intégrés
Casdoor se gère lui-même avec les mêmes quatre objets. Au premier démarrage, il crée :
| 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 |
Every user of the built-in organization is a global administrator. To add administrators, create more users in built-in. To keep strangers from becoming administrators, turn off sign-up for app-built-in.
Vous ne pouvez pas renommer ni supprimer l'organisation built-in, l'utilisateur built-in/admin ou l'application app-built-in dans la console d'administration ou via l'API. Leurs noms sont codés en dur. Leur modification ou suppression dans la base de données peut casser Casdoor.