ข้ามไปยังเนื้อหาหลัก

ภาพรวม

คุณสมบัติของผู้ใช้

ในฐานะแพลตฟอร์มการตรวจสอบสิทธิ์, 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)

รหัสที่ไม่ซ้ำกันสำหรับการเข้าสู่ระบบผ่านแพลตฟอร์มโซเชียล:

  • 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

Email Normalization

Casdoor normalizes all email addresses to lowercase to ensure uniqueness and prevent duplicate accounts. This means that user@example.com, User@Example.com, and USER@EXAMPLE.COM are treated as the same email address, complying with RFC 5321 standards.

This normalization happens automatically during:

  • User signup and account creation
  • User login and authentication
  • Email duplicate checking

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

คุณสามารถเพิ่มผู้ใช้ใหม่หรืออัปเดตผู้ใช้ Casdoor ที่มีอยู่โดยการอัปโหลดไฟล์ XLSX ที่มีข้อมูลผู้ใช้

ใน Admin Console, ไปที่ Users และคลิกปุ่ม Upload (.xlsx)

การนำเข้าผู้ใช้

เลือกไฟล์ XLSX ของคุณและคลิก Open ผู้ใช้จะถูกนำเข้า

เรามี ไฟล์เทมเพลต XLSX ที่ชื่อว่า user_test.xlsx ในโฟลเดอร์ xlsx เทมเพลตรวมถึงผู้ใช้ทดสอบ 5 คนและส่วนหัวสำหรับคุณสมบัติผู้ใช้ที่จำเป็นบางอย่าง

การนำเข้าสำเร็จ

ข้ามการเข้ารหัสรหัสผ่าน

เมื่อย้ายผู้ใช้จากฐานข้อมูลภายนอกไปยัง Casdoor, อาจมีสถานการณ์ที่คุณต้องการข้ามหรือควบคุมวิธีการเข้ารหัสที่เริ่มต้นที่ให้โดย organization วิธีการรหัสผ่านที่เริ่มต้น

สามารถทำได้โดยใช้ฟิลด์ passwordType ระหว่างการนำเข้าผู้ใช้

หมายเหตุ

ผู้ใช้ที่มีรหัสผ่าน Bycrypt

ด้านล่างเป็นตัวอย่างของร่างคำขอ POST สำหรับเส้นทาง API /api/add-user

{
"owner": "organization",
"signupApplication": "first-app",
"email":"dev@dev.com",
"name": "dev",
"displayName": "developper",
"password": "$2a$10$.o/iVyDE9Xk8ioywHDnQRu72RviOi6FPa1ujhusbSCZeg7VOa6MY6",
"passwordType":"bcrypt",
}

ที่นี่, รหัสผ่านของผู้ใช้ถูกเข้ารหัสแล้วโดยใช้อัลกอริทึม bcrypt, ดังนั้นเราจึงระบุ passwordType เป็น "bcrypt" เพื่อแจ้งให้ Casdoor ทราบว่าไม่ต้องเข้ารหัสอีกครั้ง