Add authentication protocol specification#46
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
这个不是内核,我只是希望作为一个插件接入 @copilot |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
已重构为独立插件包 (Restructured as a standalone plugin package Commit: e8f0d88 |
… not BetterAuth) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
已重构为核心规范,使用通用名称 "Authentication" 而不是 "BetterAuth"。现在这是 ObjectStack 的标准认证协议规范,与具体实现无关(可以用 better-auth、Auth.js、Passport 等任何认证库实现)。 (Restructured as core specification with generic name "Authentication" instead of "BetterAuth". Now it's the standard authentication protocol specification for ObjectStack, framework-agnostic and can be implemented with any auth library like better-auth, Auth.js, Passport, etc.) Schema: |
|
Please refactor the changes in this PR to promote the "Better-Auth Plugin" specification into a generic "Standard Authentication Protocol". The goal is to decouple the specification from the specific implementation (better-auth), making the spec the "Interface" and better-auth just one possible "Driver". Please perform the following tasks:
Please ensure all tests pass after the refactoring. |
… driver field Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Refactoring completed: ✅ File Renaming:
✅ Symbol Renaming:
✅ Schema Updates:
✅ Documentation:
✅ All Tests Passing: 46/46 tests pass Commit: ad7a87b |
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
|
@copilot 继续 |
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive authentication protocol specification to the ObjectStack ecosystem. It introduces a framework-agnostic authentication standard that can be implemented by various authentication libraries, with better-auth as the reference implementation.
Changes:
- Added authentication protocol specification with Zod schemas and TypeScript types
- Implemented support for multiple authentication strategies (email/password, OAuth, magic link, passkey, OTP, anonymous)
- Included comprehensive test coverage (46 passing tests) and auto-generated JSON schemas and documentation
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/system/auth.zod.ts | Core authentication protocol specification with Zod schemas |
| packages/spec/src/system/auth.test.ts | Comprehensive test suite for authentication schemas |
| packages/spec/src/index.ts | Export path for authentication specifications |
| packages/spec/json-schema/*.json | Auto-generated JSON schemas for all authentication types |
| content/docs/references/system/*.mdx | Auto-generated documentation for authentication schemas |
| docs/AUTHENTICATION_STANDARD.md | Detailed documentation of the authentication standard |
| type AuthenticationConfig, | ||
| type AuthenticationProvider, |
There was a problem hiding this comment.
The imported types AuthenticationConfig and AuthenticationProvider are inconsistent with the exported types AuthConfig and StandardAuthProvider from auth.zod.ts. Update these imports to use AuthConfig and StandardAuthProvider respectively to match the actual exported type names.
| type AuthenticationConfig, | |
| type AuthenticationProvider, | |
| type AuthConfig, | |
| type StandardAuthProvider, |
|
|
||
| describe('AuthConfigSchema', () => { | ||
| it('should accept minimal valid configuration', () => { | ||
| const config: AuthConfig = { |
There was a problem hiding this comment.
The type annotation uses AuthConfig but should use AuthenticationConfig based on the imports. However, the correct fix is to update the imports as noted in Comment 1, since AuthConfig is the actual exported type name.
|
|
||
| describe('StandardAuthProviderSchema', () => { | ||
| it('should accept valid authentication provider', () => { | ||
| const provider: AuthenticationProvider = { |
There was a problem hiding this comment.
The type annotation uses AuthenticationProvider but should use StandardAuthProvider to match the exported type from auth.zod.ts.
|
|
||
| describe('Type inference', () => { | ||
| it('should correctly infer AuthenticationConfig type', () => { | ||
| const config: AuthConfig = { |
There was a problem hiding this comment.
Same issue as Comment 2 - type annotation inconsistency with imports.
| const config: AuthConfig = { | |
| const config: AuthenticationConfig = { |
| }); | ||
|
|
||
| it('should correctly infer StandardAuthProvider type', () => { | ||
| const provider: AuthenticationProvider = { |
There was a problem hiding this comment.
Same issue as Comment 3 - type annotation uses AuthenticationProvider instead of StandardAuthProvider.
docs/AUTHENTICATION_STANDARD.md
Outdated
| |----------|------|----------|-------------| | ||
| | `name` | `string` | ✅ | Configuration identifier (snake_case) | | ||
| | `label` | `string` | ✅ | Human-readable label | | ||
| | `strategies` | `BetterAuthStrategy[]` | ✅ | Enabled authentication strategies | |
There was a problem hiding this comment.
The type BetterAuthStrategy[] should be AuthStrategy[] to match the exported type from auth.zod.ts.
| | `strategies` | `BetterAuthStrategy[]` | ✅ | Enabled authentication strategies | | |
| | `strategies` | `AuthStrategy[]` | ✅ | Enabled authentication strategies | |
docs/AUTHENTICATION_STANDARD.md
Outdated
| - **Zod Schema**: `packages/spec/src/system/auth-better.zod.ts` | ||
| - **Tests**: `packages/spec/src/system/auth-better.test.ts` | ||
| - **JSON Schema**: `packages/spec/json-schema/BetterAuthConfig.json` | ||
| - **Documentation**: `content/docs/references/system/BetterAuthConfig.mdx` |
There was a problem hiding this comment.
The file paths reference non-existent files with 'better' or 'BetterAuth' naming. These should be updated to use the actual file names: auth.zod.ts, auth.test.ts, AuthConfig.json, and AuthConfig.mdx respectively.
docs/AUTHENTICATION_STANDARD.md
Outdated
| BetterAuthConfig, | ||
| BetterAuthProvider, | ||
| BetterAuthStrategy, |
There was a problem hiding this comment.
These import examples reference non-existent types. Should be AuthConfig, StandardAuthProvider, and AuthStrategy respectively to match the actual exports from auth.zod.ts.
| BetterAuthConfig, | |
| BetterAuthProvider, | |
| BetterAuthStrategy, | |
| AuthConfig, | |
| StandardAuthProvider, | |
| AuthStrategy, |
docs/AUTHENTICATION_STANDARD.md
Outdated
| Following ObjectStack conventions: | ||
|
|
||
| - **Configuration Keys** (TypeScript properties): `camelCase` (e.g., `maxAttempts`, `emailPassword`) | ||
| - **Machine Names** (Data values): `snake_case` (e.g., `name: 'better_auth'`, `strategy: 'email_password'`) |
There was a problem hiding this comment.
The example name: 'better_auth' is misleading since 'better_auth' refers to the driver implementation, not the name field which should be something like 'main_auth'. Consider using a more appropriate example that doesn't reference the implementation.
| - **Machine Names** (Data values): `snake_case` (e.g., `name: 'better_auth'`, `strategy: 'email_password'`) | |
| - **Machine Names** (Data values): `snake_case` (e.g., `name: 'main_auth'`, `strategy: 'email_password'`) |
docs/AUTHENTICATION_STANDARD.md
Outdated
|
|
||
| - [Better-Auth Documentation](https://better-auth.com) | ||
| - [ObjectStack Documentation](https://objectstack.ai) | ||
| - [JSON Schema Reference](../packages/spec/json-schema/BetterAuthConfig.json) |
There was a problem hiding this comment.
The file path references a non-existent file. Should be AuthConfig.json instead of BetterAuthConfig.json.
|
@copilot fix all |
|
@copilot 继续 |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
All review issues fixed: ✅ Test imports updated: All 46 tests passing. Commit: 6254324 |
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
Authentication Standard Specification
Status: All Review Issues Fixed
Summary
Fixed all inconsistencies identified by code review - updated type names, file paths, and examples throughout tests and documentation.
Changes Made
1. File Renaming:
authentication.zod.ts→auth.zod.tsauthentication.test.ts→auth.test.tsAUTHENTICATION.md→AUTHENTICATION_STANDARD.md2. Symbol Renaming (Shorter Names):
AuthenticationConfigSchema→AuthConfigSchemaAuthenticationConfig→AuthConfigAuthenticationProviderSchema→StandardAuthProviderSchema(to avoid conflict with identity.zod.ts)AuthenticationProvider→StandardAuthProviderAuthStrategy(already short, kept as-is)3. Schema Updates:
driverfield toAuthConfig(string, default: 'better-auth')'authentication'to'standard_auth'to avoid conflicts4. Documentation Updates:
better-authis the "Reference Implementation" (Default Driver)5. Bug Fixes (Latest Commit):
AuthenticationConfig→AuthConfig,AuthenticationProvider→StandardAuthProviderBetterAuthConfig→AuthConfig,BetterAuthStrategy→AuthStrategyauth-better.zod.ts→auth.zod.ts,auth-better.test.ts→auth.test.tsname: 'better_auth'→name: 'main_auth'BetterAuthConfig.json→AuthConfig.jsonArchitecture
Clear Interface/Driver Separation:
AuthConfigis the interface (standard specification)driverfield specifies the implementation ('better-auth', 'auth-js', 'passport', 'custom')No Naming Conflicts:
StandardAuthProviderSchemadoesn't conflict withAuthProviderSchemain identity.zod.tsQuality Assurance
✅ Tests: All 46 tests passing
✅ Build: TypeScript compilation successful
✅ Exports: Updated in packages/spec/src/index.ts
✅ JSON Schemas: Auto-generated successfully
✅ Documentation: Auto-generated and manually updated
✅ Code Review: All 12 review issues fixed
Files Changed
packages/spec/src/system/auth.zod.ts- Renamed from authentication.zod.ts, added driver fieldpackages/spec/src/system/auth.test.ts- Renamed, updated imports and type referencespackages/spec/src/index.ts- Updated export pathdocs/AUTHENTICATION_STANDARD.md- Renamed and fixed all type/path referencesAll review feedback addressed: type name consistency, correct file paths, and clear examples.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.