Add user_oauth_account model and update asset metadata

- Introduced the user_oauth_account model to enhance user authentication capabilities.
- Updated asset metadata timestamps for various files to reflect recent changes.
- Ensured consistency in the system and test models by including the new user_oauth_account model in both configurations.
This commit is contained in:
Max 2025-08-02 10:39:25 +08:00
parent ae2b267aa1
commit ea4a492974
4 changed files with 409 additions and 129 deletions

File diff suppressed because one or more lines are too long

View file

@ -20,15 +20,16 @@ import (
// SystemModels system models
var systemModels = map[string]string{
"__yao.assistant": "yao/models/assistant.mod.yao",
"__yao.attachment": "yao/models/attachment.mod.yao",
"__yao.audit": "yao/models/audit.mod.yao",
"__yao.chat": "yao/models/chat.mod.yao",
"__yao.config": "yao/models/config.mod.yao",
"__yao.dsl": "yao/models/dsl.mod.yao",
"__yao.history": "yao/models/history.mod.yao",
"__yao.kb": "yao/models/kb.mod.yao",
"__yao.user": "yao/models/user.mod.yao",
"__yao.assistant": "yao/models/assistant.mod.yao",
"__yao.attachment": "yao/models/attachment.mod.yao",
"__yao.audit": "yao/models/audit.mod.yao",
"__yao.chat": "yao/models/chat.mod.yao",
"__yao.config": "yao/models/config.mod.yao",
"__yao.dsl": "yao/models/dsl.mod.yao",
"__yao.history": "yao/models/history.mod.yao",
"__yao.kb": "yao/models/kb.mod.yao",
"__yao.user": "yao/models/user.mod.yao",
"__yao.user_oauth_account": "yao/models/user_oauth_account.mod.yao",
}
// Load load models

View file

@ -36,15 +36,16 @@ var testServer *http.Server = nil
// SystemModels system models for testing
var testSystemModels = map[string]string{
"__yao.assistant": "yao/models/assistant.mod.yao",
"__yao.attachment": "yao/models/attachment.mod.yao",
"__yao.audit": "yao/models/audit.mod.yao",
"__yao.chat": "yao/models/chat.mod.yao",
"__yao.config": "yao/models/config.mod.yao",
"__yao.dsl": "yao/models/dsl.mod.yao",
"__yao.history": "yao/models/history.mod.yao",
"__yao.kb": "yao/models/kb.mod.yao",
"__yao.user": "yao/models/user.mod.yao",
"__yao.assistant": "yao/models/assistant.mod.yao",
"__yao.attachment": "yao/models/attachment.mod.yao",
"__yao.audit": "yao/models/audit.mod.yao",
"__yao.chat": "yao/models/chat.mod.yao",
"__yao.config": "yao/models/config.mod.yao",
"__yao.dsl": "yao/models/dsl.mod.yao",
"__yao.history": "yao/models/history.mod.yao",
"__yao.kb": "yao/models/kb.mod.yao",
"__yao.user": "yao/models/user.mod.yao",
"__yao.user_oauth_account": "yao/models/user_oauth_account.mod.yao",
}
var testSystemStores = map[string]string{

View file

@ -0,0 +1,255 @@
{
"name": "User OAuth Account",
"label": "User OAuth Account",
"description": "User's third-party OAuth account information storage",
"tags": ["user", "oauth", "social", "external", "provider"],
"table": {
"name": "user_oauth_account",
"comment": "User's third-party OAuth account information storage"
},
"columns": [
// ============================================================================
// Basic Fields
// ============================================================================
{
"name": "id",
"type": "ID",
"label": "ID",
"comment": "Primary key identifier",
"primary": true
},
{
"name": "user_id",
"type": "string",
"label": "User ID",
"comment": "Reference to main user account",
"length": 255,
"nullable": false,
"index": true
},
{
"name": "provider",
"type": "string",
"label": "Provider",
"comment": "OAuth provider name (google, apple, github, etc.)",
"length": 50,
"nullable": false,
"index": true
},
// ============================================================================
// OIDC Standard Claims from Provider
// Reference: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
// ============================================================================
{
"name": "sub",
"type": "string",
"label": "Subject",
"comment": "OIDC subject identifier (sub claim) from provider",
"length": 255,
"nullable": false,
"index": true
},
{
"name": "preferred_username",
"type": "string",
"label": "Preferred Username",
"comment": "OIDC preferred username from provider",
"length": 100,
"nullable": true
},
{
"name": "email",
"type": "string",
"label": "Email",
"comment": "OIDC email address from provider",
"length": 255,
"nullable": true,
"index": true
},
{
"name": "email_verified",
"type": "boolean",
"label": "Email Verified",
"comment": "OIDC email verification status from provider",
"default": false,
"nullable": true
},
{
"name": "name",
"type": "string",
"label": "Full Name",
"comment": "OIDC full name from provider",
"length": 200,
"nullable": true
},
{
"name": "given_name",
"type": "string",
"label": "Given Name",
"comment": "OIDC given name(s) or first name(s) from provider",
"length": 100,
"nullable": true
},
{
"name": "family_name",
"type": "string",
"label": "Family Name",
"comment": "OIDC surname(s) or last name(s) from provider",
"length": 100,
"nullable": true
},
{
"name": "middle_name",
"type": "string",
"label": "Middle Name",
"comment": "OIDC middle name(s) from provider",
"length": 100,
"nullable": true
},
{
"name": "nickname",
"type": "string",
"label": "Nickname",
"comment": "OIDC casual name from provider",
"length": 100,
"nullable": true
},
{
"name": "profile",
"type": "string",
"label": "Profile",
"comment": "OIDC profile page URL from provider",
"length": 500,
"nullable": true
},
{
"name": "picture",
"type": "string",
"label": "Picture",
"comment": "OIDC profile picture URL from provider",
"length": 500,
"nullable": true
},
{
"name": "website",
"type": "string",
"label": "Website",
"comment": "OIDC web page or blog URL from provider",
"length": 500,
"nullable": true
},
{
"name": "gender",
"type": "string",
"label": "Gender",
"comment": "OIDC gender from provider",
"length": 20,
"nullable": true
},
{
"name": "birthdate",
"type": "string",
"label": "Birthdate",
"comment": "OIDC birthday from provider (YYYY-MM-DD format)",
"length": 10,
"nullable": true
},
{
"name": "zoneinfo",
"type": "string",
"label": "Zone Info",
"comment": "OIDC time zone info from provider",
"length": 50,
"nullable": true
},
{
"name": "locale",
"type": "string",
"label": "Locale",
"comment": "OIDC locale from provider (language-country)",
"length": 20,
"nullable": true
},
{
"name": "phone_number",
"type": "string",
"label": "Phone Number",
"comment": "OIDC phone number from provider",
"length": 50,
"nullable": true
},
{
"name": "phone_number_verified",
"type": "boolean",
"label": "Phone Number Verified",
"comment": "OIDC phone verification status from provider",
"default": false,
"nullable": true
},
{
"name": "address",
"type": "json",
"label": "Address",
"comment": "OIDC physical mailing address from provider (structured)",
"nullable": true
},
{
"name": "raw",
"type": "json",
"label": "Raw",
"comment": "OIDC original user info response from provider",
"nullable": true
},
// ============================================================================
// Account Management Fields
// ============================================================================
{
"name": "last_login_at",
"type": "timestamp",
"label": "Last Login At",
"comment": "Last login via this OAuth provider",
"nullable": true,
"index": true
},
{
"name": "is_active",
"type": "boolean",
"label": "Is Active",
"comment": "Whether this OAuth account is still active",
"default": true,
"index": true
}
],
"indexes": [
{
"name": "idx_user_oauth_user_provider",
"columns": ["user_id", "provider"],
"type": "unique",
"comment": "Unique constraint: one account per provider per user"
},
{
"name": "idx_user_oauth_provider_sub",
"columns": ["provider", "sub"],
"type": "unique",
"comment": "Unique constraint: one record per provider sub claim"
},
{
"name": "idx_user_oauth_email",
"columns": ["provider", "email"],
"type": "index",
"comment": "Index for email lookups by provider"
},
{
"name": "idx_user_oauth_active",
"columns": ["is_active", "last_login_at"],
"type": "index",
"comment": "Index for active account queries"
}
],
"relations": {},
"values": [],
"option": { "timestamps": true, "soft_deletes": true }
}