概要
ユーザー属性
認証プラットフォームとして、Casdoorはユーザーを管理することができます。 すべてのユーザーには以下の属性があります:
- Owner:ユーザーを所有する組織
- Name:一意のユーザー名
- CreatedTime
- UpdatedTime
- Id:各ユーザーの一意の識別子
- Type
- Password
- PasswordSalt
- PasswordOptions:パスワードの複雑さのオプション
- DisplayName:ユーザーインターフェースに表示される
- FirstName
- LastName
- Avatar:ユーザーのアバターへのリンク
- PermanentAvatar
- Email
- Phone
- Location
- Address
- Affiliation
- Title
- IdCardType
- IdCard
- Homepage
- Bio
- Tag
- Region
- Language
- Gender
- Birthday
- Education
- Score
- Karma
- Ranking
- IsDefaultAvatar
- IsOnline
- IsAdmin:ユーザーが自分の組織の管理者であるかどうかを示す
- IsGlobalAdmin:ユーザーがCasdoorを管理する権限を持っているかどうかを示す
- IsForbidden
- IsDeleted: When a user is soft-deleted (- IsDeleted = true), they cannot sign in through any authentication method, including OAuth providers. This prevents deleted users from re-registering via third-party login.
- SignupApplication
- Hash
- PreHash
- CreatedIp
- LastSigninTime
- LastSigninIp
- Roles: An array of the user's roles (extended field, read-only via User API)
- Permissions: An array of the user's permissions (extended field, read-only via User API)
ソーシャルプラットフォームログインのための一意のID:
- Github
- Google
- QQ
- WeChat
- Facebook
- DingTalk
- Weibo
- Gitee
- LinkedIn
- Wecom
- Lark
- Gitlab
- Adfs
- Baidu
- Casdoor
- Infoflow
- Apple
- Azure AD
- Azure AD B2C
- Slack
- Steam
- Ldap
Understanding Roles and Permissions Fields
The Roles and Permissions fields in the User object are extended fields that are dynamically populated when retrieving user data. These fields are not stored directly in the User table but are collected from the Roles and Permissions resources through the ExtendUserWithRolesAndPermissions() function.
Important: You cannot update roles and permissions through the /api/update-user endpoint, even when using the columns parameter. To manage user roles and permissions, you must use the dedicated APIs for Roles and Permissions resources.
To assign roles or permissions to users:
- Roles: Use the Roles API endpoints to create and assign roles. Visit the Roles management page (e.g., https://door.casdoor.com/roles) or use the roles API.
- Permissions: Use the Permissions API endpoints to create and assign permissions. Visit the Permissions management page (e.g., https://door.casdoor.com/permissions) or use the permissions API.
Using the Properties Field
The Properties field is a flexible key-value map (map[string]string) that allows you to store custom attributes for users beyond the predefined fields in the User schema. This is particularly useful when you need to:
- Store organization-specific user attributes
- Add custom metadata that doesn't fit into standard fields
- Extend user profiles without modifying the core schema
XLSXファイルからユーザーをインポートする
XLSXファイルに含まれるユーザー情報をアップロードすることで、新しいユーザーを追加したり、既存のCasdoorユーザーを更新したりすることができます。
管理コンソールで、ユーザーに移動し、アップロード(.xlsx)ボタンをクリックします。

XLSXファイルを選択し、開くをクリックします。 ユーザーがインポートされます。
次のテンプレートXLSXファイルはuser_test.xlsxという名前でxlsxフォルダにあります。 テンプレートには5人のテストユーザーと、いくつかの必要なユーザー属性のヘッダーが含まれています。

パスワード暗号化をバイパスする
外部データベースからCasdoorにユーザーを移行する際に、organizationのデフォルトのパスワードタイプメソッドによって提供されるデフォルトの暗号化方法をバイパスしたり、制御したりしたい場合があります。
これは、ユーザーインポート中にpasswordTypeフィールドを使用することで実現できます。
Bycryptパスワードを持つユーザー
以下は、APIルート/api/add-userのPOSTボディリクエストの例です。
{
  "owner": "organization",
    "signupApplication": "first-app",
    "email":"dev@dev.com",
    "name": "dev",
    "displayName": "developper",
    "password": "$2a$10$.o/iVyDE9Xk8ioywHDnQRu72RviOi6FPa1ujhusbSCZeg7VOa6MY6",
    "passwordType":"bcrypt",
}
ここでは、ユーザーのパスワードはすでにbcryptアルゴリズムを使用して暗号化されているため、Casdoorに再度暗号化しないようにpasswordTypeを"bcrypt"として指定します。