Open diegoalzate opened 1 month ago
This update introduces a robust access control mechanism through the creation of an access_rules
table, enhancing user authentication processes. New schema definitions and service functions facilitate improved user verification and access checks, fortifying the application's security and functionality. The changes foster a more modular and efficient approach to managing permissions and user interactions within the system.
File(s) | Change Summary |
---|---|
migrations/.../0030_sleepy_moira_mactaggert.sql , migrations/.../0030_snapshot.json , migrations/.../_journal.json |
Introduced new access_rules table for access control, including constraints and indexes. Updated schema snapshot and migration history. |
package.json |
Added "siwe": "^2.3.2" dependency for Sign-In with Ethereum functionality. |
src/db/schema/access-rules.ts |
Defined access_rules table schema using Drizzle ORM, including fields and type definitions for TypeScript. |
src/db/schema/index.ts |
Exported access rules schema to enhance module functionality. |
src/handlers/auth.ts |
Added handlers for SIWE: getSIWENonceHandler , verifySIWEHandler , and getSIWESessionHandler . Updated existing verification logic. |
src/routers/auth.ts |
Expanded authRouter to include new SIWE routes for nonce generation and verification. |
src/services/access-rules.ts |
Implemented checkAccessRules function to evaluate user permissions based on access rules. |
src/services/auth.ts |
Integrated access control checks in createOrSignInPCD and introduced createOrSignInSIWE for Ethereum-based authentication. |
src/types/auth.ts |
Renamed verifyUserSchema to verifyZupassUserSchema and added verifySIWEUserSchema for SIWE authentication. |
sequenceDiagram
participant Client
participant AuthRouter
participant AuthHandlers
participant AccessRulesService
participant Database
Client->>AuthRouter: Request SIWE Nonce
AuthRouter->>AuthHandlers: Call getSIWENonceHandler()
AuthHandlers->>Database: Store nonce and respond
Database-->>AuthHandlers: Nonce stored
AuthHandlers-->>Client: Return nonce
Client->>AuthRouter: Submit SIWE Verification
AuthRouter->>AuthHandlers: Call verifySIWEHandler()
AuthHandlers->>AccessRulesService: Check access permissions
AccessRulesService->>Database: Query access_rules
Database-->>AccessRulesService: Access result
AccessRulesService-->>AuthHandlers: Return access result
AuthHandlers-->>Client: Respond with verification result
π° In a garden where rules now grow,
Access granted, watch the flow.
With Ethereumβs light, we leap and bound,
In a world of trust, our friends are found!
Hopping with joy, we sing and cheer,
For access rules bring everyone near! π₯
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
inspired by https://docs.login.xyz/sign-in-with-ethereum/quickstart-guide/implement-the-backend
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores