Commit graph

70 commits

Author SHA1 Message Date
Max
b1db5505ea Update team model and creation logic to support role management
- Added role_id field to the team model for specifying team owner roles.
- Enhanced team creation logic to set default role_id based on team configuration if not provided.
- Updated tests to reflect changes in team type and role handling, ensuring accurate assertions.
- Improved documentation for team configuration to clarify default role settings for team creators.
2025-10-20 17:00:33 +08:00
Max
0bd6bdcda3 Refactor OAuth guard and ACL error handling for improved response structure
- Updated the OAuth guard to utilize a standardized response format for error handling, enhancing consistency across error responses.
- Integrated detailed error information for insufficient scope and permission denied scenarios, providing clearer insights into access issues.
- Modified the ACL enforcement logic to return structured error details, allowing for better handling of permission-related errors.
- Enhanced the ErrorResponse struct to include optional fields for reason, required scopes, and missing scopes, following OAuth 2.0 extensibility guidelines.
2025-10-20 16:23:12 +08:00
Max
0e260ffb6a Enhance OAuth guard with authorized info handling and ACL integration
- Updated the OAuth guard to set authorized information in the context using the new authorized package.
- Refactored the GetAuthorizedInfo function to utilize the authorized.GetInfo method, improving clarity and maintainability.
- Enhanced the ACL implementation by adding scope resolution logic in the Enforce method, ensuring proper access control based on user roles and scopes.
- Improved error handling and logging during ACL operations, providing better insights into access decisions.
2025-10-20 08:50:20 +08:00
Max
667d40b5a1 Add ACL support to OAuth guard and error handling
- Integrated ACL (Access Control List) functionality into the OAuth guard, enabling permission checks and rate limiting based on ACL configurations.
- Updated error responses for token validation and refresh token handling to use standardized error types.
- Enhanced error handling for ACL-related issues, providing detailed HTTP responses based on specific ACL error types.
- Improved overall security and user experience by ensuring proper authorization checks are enforced during API requests.
2025-10-18 09:22:35 +08:00
Max
5d1b665457 Enhance user authentication with Remember Me functionality
- Added Remember Me flag to LoginContext and AuthorizedInfo structures to support extended session management.
- Updated GetAuthorizedInfo function to retrieve Remember Me state from the context.
- Modified token issuance logic to accommodate Remember Me settings, adjusting token expiration durations accordingly.
- Preserved Remember Me state during login and team selection processes, improving user experience and session persistence.
2025-10-17 09:31:30 +08:00
Max
9a2a636314 Add invitation model and related functionality
- Introduced the invitation model in bindata.go, including the new invitation.mod.yao file.
- Updated system models to include the invitation model for better integration.
- Added invitation code related error handling in default.go, enhancing user experience during invitation processes.
- Implemented invitation code management methods in the user provider interface, allowing for creation, usage, and deletion of invitation codes.
- Enhanced entry configuration to support invitation code verification, improving the user registration flow.
- Added a new endpoint for verifying invitation codes in user routing, streamlining the invitation redemption process.
2025-10-16 19:08:54 +08:00
Max
c58bc8c4fe Add logout functionality and expose refresh token retrieval
- Implemented GinLogout function to handle user logout, including revoking access and refresh tokens, clearing authentication cookies, and returning a success response.
- Added public method GetRefreshToken to retrieve the refresh token from the request, enhancing token management.
- Updated user routing to link the logout endpoint to the new GinLogout function, improving the user authentication flow.
2025-10-16 14:53:49 +08:00
Max
48f531cf82 Update asset modification times and enhance user authentication flow
- Updated modification times for various asset files in bindata.go to reflect recent changes.
- Enhanced user authentication by adding support for custom claims in the context during authorization, improving flexibility in handling user data.
- Refactored entry verification logic to generate and send OTPs for user registration, streamlining the registration process and improving user experience.
- Introduced new status handling for user accounts, ensuring proper feedback for pending, unverified, and disabled accounts during login attempts.
2025-10-16 10:28:00 +08:00
Max
168313c757 Update AcceptInvitation method to support optional user ID parameter
- Modified the AcceptInvitation method to accept an optional user ID parameter, allowing for updates to the user ID when accepting invitations without an existing user ID.
- Adjusted related tests to include the new user ID parameter, ensuring comprehensive coverage of invitation acceptance scenarios.
- Updated the team invitation acceptance logic to utilize the new parameter, enhancing the invitation flow and user management capabilities.
2025-10-14 14:15:41 +08:00
Max
721f47c345 Enhance invitation acceptance flow with invitation ID support
- Updated the AcceptInvitation method to require both invitation ID and token, improving the invitation acceptance process.
- Modified related tests to accommodate the new invitation ID parameter, ensuring comprehensive coverage of acceptance scenarios.
- Enhanced the invitation acceptance endpoint to validate invitation ID, providing clearer error handling for invalid or expired invitations.
- Refactored tests to include detailed scenarios for accepting invitations, including success and failure cases, ensuring robust testing of the invitation flow.
2025-10-14 11:58:20 +08:00
Max
0d83faeeca Add Yao user ID support in OIDC and token generation
- Enhanced the SignIDToken method to include the original Yao user ID in the token claims, improving user identification.
- Updated the MakeOIDCUserInfo function to extract and set the Yao user ID from the user map, ensuring consistency in user information.
- Modified the OIDCUserInfo structure to include a field for Yao user ID, facilitating better integration with Yao-specific features.
- Adjusted the team invitation response to include the inviter's user ID, enhancing the invitation context.
2025-10-14 09:56:29 +08:00
Max
5e67a9e5c0 Add Yao type information to user and token claims
- Enhanced the OIDCUserInfo structure to include YaoTypeID and YaoType fields for better user type management.
- Updated SignIDToken method to incorporate YaoTypeID and YaoType claims, ensuring comprehensive user type information in ID tokens.
- Modified team creation logic to set default type_id based on team configuration, improving team management capabilities.
- Refactored token generation methods to support additional type information in access and refresh tokens, enhancing overall token customization.
2025-10-13 18:26:52 +08:00
Max
87465379be Enhance user type management with locale support
- Added 'locale' field to user type structure for language localization.
- Updated API methods to include locale in pricing and published types retrieval.
- Enhanced tests to validate locale handling in user type operations, ensuring robust support for multiple languages.
2025-10-13 16:16:40 +08:00
Max
15f0750253 Enhance user type management with pricing and status fields
- Updated user type structure to include new fields for pricing: price_daily, price_monthly, price_yearly, and credits_monthly.
- Added status field to manage publishing states (draft, published, archived) for user types.
- Enhanced the user type API to support pricing operations, including retrieval and updates for pricing information.
- Refactored tests to cover new pricing functionalities and ensure robust handling of user type statuses.
2025-10-13 15:55:41 +08:00
Max
ba296c3b48 Update UpdateUserLastLogin method to require loginCtx
- Modified the UpdateUserLastLogin method to validate that loginCtx is not nil, returning an error if it is.
- Updated the corresponding test to reflect this change, ensuring that an error is asserted when loginCtx is nil, improving error handling and robustness of user login tracking.
2025-10-13 14:11:28 +08:00
Max
0a353e6e41 Add Yao custom fields to ID token claims
- Enhanced the SignIDToken method to include additional Yao-specific fields such as tenant_id, team_id, is_owner, and team details in the token claims.
- Improved the structure of claims to support team information, ensuring comprehensive metadata is included in the generated tokens.
2025-10-13 11:29:45 +08:00
Max
1af0a20015 Enhance user login functionality with detailed context tracking
- Updated the UpdateUserLastLogin method to accept a LoginContext, allowing for tracking of last login IP, user agent, device, and platform.
- Modified the LoginThirdParty and LoginByUserID functions to utilize the new LoginContext, improving the accuracy of login tracking.
- Enhanced the user model to include fields for last login details, ensuring comprehensive user activity logging.
- Refactored tests to validate the new login context handling, ensuring robust coverage of the updated functionality.
2025-10-13 09:58:16 +08:00
Max
d78ed77b9e Enhance token generation and storage to support optional extra claims
- Updated methods related to refresh token generation and storage to accept optional extra claims, allowing for additional metadata such as team_id and tenant_id.
- Refactored tests to utilize the new method signatures, ensuring comprehensive coverage of the updated functionality.
- Introduced a new endpoint for team selection that issues tokens with team-specific claims, improving user experience in multi-team scenarios.
2025-10-11 19:56:29 +08:00
Max
aae3447575 Refactor token claims structure for improved readability
- Removed unnecessary blank lines in the TokenClaims, AuthorizedInfo, and JWTClaims structs to enhance code clarity and maintainability.
- Ensured consistent formatting across the claims structures for better organization.
2025-10-11 19:04:39 +08:00
Max
07cc11b363 Refactor token handling to support optional extra claims in access token generation
- Updated storeAccessToken and related methods to accept an optional extraClaims parameter for additional flexibility.
- Modified MakeAccessToken and generateAccessTokenWithScope functions to incorporate extra claims, enhancing token customization.
- Adjusted tests to utilize the new extraClaims parameter, ensuring comprehensive coverage of the updated functionality.
2025-10-11 18:59:45 +08:00
Max
afa5b2d3f2 Enhance team retrieval functionality and improve user team handling
- Updated GetTeamsByMember method to include role information and owner status for each team member.
- Refactored GinTeamList to utilize the new getUserTeams function, simplifying team retrieval logic and removing pagination.
- Introduced getUserTeams and getUserTeamsCount functions to encapsulate team membership logic, improving code organization and clarity.
- Removed deprecated team retrieval logic from user/team.go, streamlining the codebase.
2025-10-11 10:54:51 +08:00
Max
5e5b633fba Add team retrieval and counting methods for user membership
- Introduced GetTeamsByMember and CountTeamsByMember methods in the DefaultUser struct to retrieve teams associated with a specific member and count the total number of teams, respectively.
- Updated the UserProvider interface to include these new methods.
- Enhanced the login response structure to include a status indicating whether team selection is required based on the user's team membership.
- Added error handling for team retrieval in the authentication process.
2025-10-10 11:57:47 +08:00
Max
b9a912b7d9 Enhance member invitation management and related functionality
- Introduced invitation_id handling for member management, allowing for unique identification of pending invitations.
- Added methods to create, update, and remove members by invitation_id, improving the invitation workflow.
- Updated member data structures and API responses to include invitation-related fields, enhancing clarity and usability.
- Implemented tests for invitation ID operations, ensuring robust validation and error handling.
- Refactored team access checks to streamline member management processes.
2025-09-23 17:47:43 +08:00
Max
35afc1d58c Add team ownership and membership checks in user management
- Introduced IsTeamOwner and IsTeamMember methods to verify user ownership and membership status within a team.
- Added CheckTeamAccess method to assess a user's access level, returning ownership and membership status.
- Enhanced user types with new MemberResponse and MemberDetailResponse structures for improved member management.
- Updated routing for team member management to utilize new handler functions for clarity and consistency.
2025-09-23 16:14:42 +08:00
Max
9aff88d2fc Add team member removal functionality and related tests
- Implemented RemoveAllTeamMembers method in DefaultUser to delete all members from a team during team deletion.
- Added TestTeamDeleteMemberCleanup to verify that all members are removed when a team is deleted.
- Refactored team creation and deletion logic to ensure proper member management and error handling during these operations.
2025-09-23 11:24:57 +08:00
Max
5a894c11ab Add authorized info handling and session ID retrieval in OAuth guard
- Introduced methods to set and retrieve authorized information from the context, enhancing the OAuth guard functionality.
- Added a new `AuthorizedInfo` type to encapsulate user-related data such as subject, client ID, user ID, and scope.
- Implemented session ID retrieval from various sources (cookies, headers, query strings) to improve session management.
- Updated test utilities to support the creation of test users and access tokens, ensuring comprehensive testing of OAuth functionalities.
2025-09-23 10:22:52 +08:00
Max
6c73395158 Refactor invitation handling and data parsing in user provider
- Updated TestMemberInvitationExpiry to use a consistent expired time for invitations.
- Simplified invitation expiration check in AcceptInvitation by utilizing a new checkTimeExpired function.
- Enhanced member ID parsing in AcceptInvitation to handle potential errors more gracefully.
- Refactored total extraction logic in CountOAuthAccounts, CountRoles, CountTeams, CountTypes, and CountUsers to use a new utility function for improved clarity and consistency.
- Introduced parseTimeFromDB and parseIntFromDB functions to streamline data parsing from database fields.
2025-09-16 17:54:56 +08:00
Max
b20ddee701 Add team and member management capabilities to user provider
- Introduced new constants for team and member error handling, enhancing error reporting.
- Added default field lists for teams and members, improving data structure organization.
- Expanded the UserProvider interface with methods for team and member management, including creation, updates, and retrieval.
- Enhanced the NewDefaultUser function to support team and member configurations, ensuring flexibility in user management.
2025-09-16 17:33:25 +08:00
Max
580f3683e2 Refactor user and model structures to enhance organization and role management
- Reorganized models by replacing the assistant and chat models with a new agent structure, including assistant, chat, and history models.
- Updated user model relationships to reflect changes in role and type references, ensuring consistency with the new model structure.
- Removed obsolete organization and user role models, streamlining the overall architecture.
- Adjusted system model mappings to incorporate new member and role models, enhancing clarity in user management.
2025-09-16 09:35:18 +08:00
Max
4a2106371e Enhance hello world endpoints with query string and post payload logging
- Added functionality to capture and return the raw query string and post payload in the JSON response for both public and protected hello world endpoints.
- Improved response structure to include additional context for debugging and client-side processing.
2025-08-05 09:28:25 +08:00
Max
5657c75201 Enhance refresh token functionality and response handling
- Updated MakeRefreshToken and generateRefreshToken methods to accept an optional expiresIn parameter for customizable token expiration.
- Modified storeRefreshTokenWithScope to handle dynamic expiration times based on the provided parameter.
- Enhanced the authback function to send cookies with access and refresh tokens, including their respective expiration times.
- Updated LoginResponse structure to include RefreshTokenExpiresIn for better client-side management of token lifetimes.
- Adjusted client configuration to set default refresh token expiration duration.
2025-08-04 16:52:57 +08:00
Max
c1b28f3b69 Add scope field to dynamic client registration tests
- Updated test cases for dynamic client registration to include a scope field with values "openid profile email".
- Ensured that tests reflect the expected behavior when scope is provided, enhancing validation coverage for client registration requests.
2025-08-04 11:19:45 +08:00
Max
4682c20903 Update OAuth client configuration and ID generation methods
- Added support for numeric ID generation in the OAuth service, replacing the previous NanoID approach for better compatibility.
- Refactored client ID and secret generation methods to be public and renamed them for consistency.
- Enhanced dynamic client registration to allow optional client ID usage.
- Updated client configuration loading to include validation and registration of clients if not found.
- Improved error handling and logging for client configuration processes.
- Adjusted tests to reflect changes in ID generation and client configuration handling.
2025-08-04 11:04:56 +08:00
Max
2b7040c834 Implement ID token signing and user fingerprint management in OAuth
- Added `SignIDToken` method to the OAuth service for signing ID tokens with user data and claims.
- Introduced `MakeAccessToken` and `MakeRefreshToken` methods for generating access and refresh tokens.
- Implemented user fingerprint management with `Subject` and `UserID` methods for mapping user IDs to unique NanoIDs.
- Enhanced `LoginByUserID` to generate and return OIDC tokens and access tokens during user login.
- Updated `OIDCUserInfo` mapping to include additional user attributes and improved handling of optional fields.
2025-08-03 19:51:35 +08:00
Max
392b6bee1b Enhance user management functionality with IP tracking and scope retrieval
- Added `last_login_ip` field to the user model to track the IP address of the last login.
- Updated `UpdateUserLastLogin` method to accept an IP address parameter for logging.
- Introduced `GetUserWithScopes` method to retrieve user information along with associated scopes and permissions.
- Modified `LoginThirdParty` and `LoginByUserID` functions to include IP address handling during login processes.
- Improved user provider interface to reflect the new methods and parameters, enhancing overall user management capabilities.
2025-08-03 18:30:34 +08:00
Max
757f040fd0 Refactor test data handling for improved isolation and cleanup
- Updated test cases to utilize unique client IDs and user emails with suffixes for better isolation during parallel test execution.
- Enhanced the setupTestData function to generate unique identifiers for test clients and users, preventing conflicts in concurrent test runs.
- Implemented comprehensive cleanup patterns to ensure all test data is removed after execution, improving test reliability and maintainability.
2025-08-03 11:16:46 +08:00
Max
1dbcdd47d4 Update test data cleanup to use user_id instead of subject in oauth_test.go
- Modified the cleanupTestData function to query by user_id, ensuring consistency with the updated user provider interface.
- This change enhances the accuracy of test data cleanup and aligns with recent refactoring efforts in user management.
2025-08-03 10:35:28 +08:00
Max
5301023cf2 Refactor user provider methods to return string IDs and update test data handling
- Updated GetUserProvider to return an error alongside the user provider for better error handling.
- Modified CreateUser, CreateRole, and CreateType methods to return user and role IDs as strings instead of interfaces, enhancing type safety.
- Adjusted test data setup in oauth_test.go to reflect changes in user ID handling and ensure compatibility with the updated user provider interface.
- Removed unnecessary nil checks and improved assertions in tests for clarity and reliability.
2025-08-03 10:25:09 +08:00
Max
21c7caed5d Add lightweight existence check methods for OAuth accounts, roles, types, and users
- Implemented methods to check the existence of OAuth accounts, roles, types, and users by their respective identifiers, enhancing the user provider's functionality.
- Added error handling for these methods to ensure robust feedback in case of failures.
- Updated the user provider interface to include the new existence check methods, improving overall usability and maintainability.
2025-08-03 07:14:09 +08:00
Max
e3e4b1bb77 Implement MFA functionality in user management
- Added Multi-Factor Authentication (MFA) capabilities to the user provider, including methods for generating MFA secrets, enabling/disabling MFA, and verifying MFA codes.
- Introduced MFA configuration options, allowing customization of issuer, algorithm, digits, and recovery codes.
- Enhanced error handling for MFA operations, providing clear feedback for failures.
- Updated user model to include MFA-related fields and improved database interactions for MFA management.
- Refactored existing user provider methods to integrate MFA functionality seamlessly.
2025-08-02 21:08:37 +08:00
Max
5c96312eef Implement user type management methods and enhance user provider functionality
- Added methods for creating, retrieving, updating, and deleting user types, improving user type management capabilities.
- Introduced type field lists in DefaultUser and DefaultUserOptions for better type configuration.
- Implemented error handling for user type operations, ensuring robust feedback for failures.
- Enhanced user deletion process to clean up associated data before removing user accounts.
- Updated tests to cover new user type functionalities and ensure proper cleanup of test data.
2025-08-02 19:56:48 +08:00
Max
73846c9b9d Remove obsolete user provider implementation and associated test files
- Deleted the DefaultUser implementation and its related test file, streamlining the codebase by removing unused functionality.
- This cleanup enhances maintainability and focuses on the current user management architecture.
2025-08-02 19:28:43 +08:00
Max
d32b5e4eb6 Enhance user role management functionality and implement role-related methods
- Added role field lists to DefaultUser and DefaultUserOptions for better role configuration.
- Implemented methods for creating, retrieving, updating, and deleting user roles, improving role management capabilities.
- Enhanced error handling for role operations, ensuring robust feedback for failures.
- Introduced ClearUserRole method to remove role assignments from users, streamlining user-role management.
- Updated tests to ensure proper cleanup of role data and maintain a clean testing environment.
2025-08-02 19:27:09 +08:00
Max
80f10cd7e5 Refactor test user model and update subject references in tests
- Updated the TestUser model to align with the latest user structure, replacing the 'Subject' field with 'UserID' for consistency with the new user provider interface.
- Modified all relevant test cases to use 'UserID' instead of 'Subject' when storing tokens and refresh tokens, ensuring compatibility with the updated user model.
- Enhanced test data setup to reflect changes in user creation and management, improving overall test reliability and clarity.
2025-08-02 18:58:23 +08:00
Max
7442c942db Implement OAuth account management methods and enhance user provider functionality
- Added methods for creating, retrieving, updating, and deleting OAuth accounts, improving user authentication capabilities.
- Introduced default OAuth account fields and options for better configuration management.
- Enhanced error handling for OAuth account operations, ensuring robust feedback for failures.
- Updated tests to ensure unique identifiers and improved cleanup processes for test data, maintaining a clean testing environment.
2025-08-02 18:49:27 +08:00
Max
11f69b8c38 Update go-nanoid dependency and implement user retrieval methods
- Replaced the jaevor/go-nanoid library with the updated matoous/go-nanoid/v2 for generating unique IDs.
- Implemented user retrieval methods in the user provider, including GetUsers, PaginateUsers, and CountUsers, enhancing user management capabilities.
- Improved error handling and ensured default select fields are set for user queries, streamlining the user data access process.
2025-08-02 18:10:04 +08:00
Max
7c332c6811 Add go-nanoid dependency and refactor user provider methods
- Added the go-nanoid library for generating unique IDs, enhancing user ID management.
- Refactored user provider methods to improve clarity and consistency, including updates to user retrieval and authentication processes.
- Adjusted user model fields to align with new ID generation strategy, ensuring compliance with best practices.
- Cleaned up code by removing obsolete test files and improving overall structure for better maintainability.
2025-08-02 17:49:03 +08:00
Max
ae2b267aa1 Update user model and remove obsolete test file
- Refactored the user model to align with OIDC standards, including renaming fields for clarity and compliance.
- Updated field descriptions and added new fields for enhanced user profile management.
- Removed the obsolete test file for user-related functionality to streamline the codebase and eliminate redundancy.
2025-08-02 10:13:34 +08:00
Max
7111d9fab2 Implement global OAuth service and enhance cache management in Signin API
- Introduced a global OAuth service variable to streamline access across the application.
- Added new methods in the OAuth Service for retrieving cache and store, improving data management.
- Refactored session state handling in the Signin API to utilize the global OAuth service for better cache interactions.
- Updated key management functions for user info and redirect URIs to enhance clarity and maintainability.
2025-08-02 08:34:18 +08:00
Max
be1acd324e Enhance OAuth user information handling and introduce OIDC support in Signin API
- Added OIDC standard types for ID Token and User Info, improving compliance with OpenID Connect specifications.
- Updated the Provider struct to support user info source types, allowing retrieval from endpoints, ID tokens, or access tokens.
- Enhanced the authback and user info retrieval functions to handle cached user data and improve error management.
- Introduced new utility functions for managing user info mapping and merging cached data, streamlining the user information processing flow.
2025-08-01 17:28:49 +08:00