- Introduce `LoginWithOptions` method to allow for customizable login flows, enabling overrides for scopes, token expiration, and refresh token issuance.
- Add `LoginOptions` struct to encapsulate optional parameters for login, improving flexibility in user authentication.
- Update token handling in `issueTokens` to accommodate new options, ensuring proper management of access and refresh tokens based on user preferences.
- Integrate OTP service initialization into the OpenAPI server setup for enhanced authentication capabilities.
- Update the `Authenticate` method in the OAuth guard to allow for token refresh when an access token is expired but still valid.
- Introduce `TryRefreshToken` method to handle the refresh token logic, including token rotation and cookie management.
- Implement `VerifyTokenAllowExpired` and `VerifyRefreshToken` methods to improve token verification processes.
- Adjust error handling to provide clearer responses for token refresh failures.
- Refactor token expiration strategies in the login process to ensure consistent handling of access and refresh tokens.
- Add `resolveTeamConfigENV` function to process and replace environment variables in team configuration settings, including robot email domains, whitelist entries, and invite configuration.
- Enhance `loadTeamConfigs` to call the new function, ensuring that team configurations are properly resolved before storage.
This change improves the flexibility of team configurations by allowing dynamic environment variable substitution.
- Introduce `YaoAuthSource` and `OAuthEmail` fields in various structures to capture authentication source and OAuth email during user login and registration processes.
- Update `SignIDToken`, `GetInfo`, and `Map` functions to include new claims for Yao authentication source.
- Modify login context to preserve authentication source and OAuth email across different user flows.
- Enhance token issuance to include authentication source and OAuth email in claims for better tracking and user context.
- Ensure proper handling of OAuth email for third-party logins without affecting user profile email.
This change improves the user experience by providing clearer context on authentication methods used during login and registration processes.
- Introduce a new function `registerUserWithTeam` that handles user registration and default team creation with rollback on failure.
- Update `GinEntryRegister` and `LoginThirdParty` functions to utilize the new registration method, ensuring consistency in user and team creation.
- Remove redundant error handling for user provider retrieval in `GinEntryRegister`.
- Enhance logging for user registration and team creation failures.
- Add SecureCookie field to EntryConfig struct for frontend access
- Add GetCookieName helper to response package for dynamic cookie names
- Update guard.go to use GetCookieName instead of hardcoded __Host- prefix
- Pass secure_cookie setting to /user/entry API response
Co-authored-by: Cursor <cursoragent@cursor.com>
- Added a comment to clarify that the __yao_created_by field is only set for create operations, ensuring consistency with the WithCreateScope function.
- Removed the __yao_updated_by field from the auth scope, streamlining the user knowledge base collection preparation process.
- Removed the synchronous preparation of the knowledge base (KB) collection from the InitializeConversation method, now initializing it asynchronously after user login.
- Introduced a new method, GetDocumentsContent, to retrieve content for multiple documents by their IDs, supporting text-based files and improving document handling.
- Updated the API interface to include the new GetDocumentsContent method, enhancing the document management capabilities.
- Enhanced locale handling in the login context to support user preferences during KB collection creation.
- Added new root-level endpoints for team management, including listing and creating teams, while maintaining OAuth protection.
- Streamlined user-related endpoints by removing unnecessary groupings, enhancing clarity and accessibility.
- Updated the Content-Type header in the API response to application/json for better consistency with API standards.
- Introduced a new function to get first-level subdirectories in the scopes directory, enhancing the flexibility of scope definition loading.
- Updated the loadScopeDefinitions method to utilize this new function, replacing hardcoded subdirectory names with a dynamic approach.
- Improved the description of the invite verification scope in the user scope initialization for clarity.
- Added new endpoints for retrieving user profile and teams in the user scope initialization.
- Ensured the existing endpoint for team selection remains included for continued functionality.
- Changed token scope from `ScopeInviteVerification` to `ScopeEntryVerification` in both `GinVerifyInvite` and `LoginByUserID` functions to align with updated authorization requirements.
- Updated error messages to reflect the new expected scope for improved clarity in responses.
- Added functionality to process SuccessURL, FailureURL, and LogoutRedirect fields in EntryConfig for environment variable substitution.
- Implemented checks to ensure that referenced environment variables exist, collecting any missing variables for further handling.
- Improved overall configuration handling by ensuring URLs are properly replaced with their corresponding environment variable values.
- Updated the modification times for various assets in `bindata.go` to reflect recent changes.
- Refactored import statements in `team_invitation.go` to maintain consistency and improve code organization by moving the `utils` import to the correct position.
- Updated the modification times for various assets in `bindata.go` to reflect recent changes.
- Enhanced the collection management in the API by adding new fields for `preset`, `public`, and `share` in the collection and document models, allowing for better control over collection visibility and sharing options.
- Updated the `CreateCollection` function to incorporate the new `share` field, improving the handling of collection data based on user permissions.
- Refactored utility functions to streamline type conversions, ensuring consistent data handling across the user and team management functionalities.
- Added `Parse` function to handle attachment wrapper strings, extracting uploader name and file ID.
- Introduced `Base64` function to convert attachment wrappers to Base64 format, with optional data URI support.
- Enhanced `readFilePathAsBase64` to read files from the filesystem and return Base64 encoded content.
- Updated `teamInvitationGetPublic` to process team logos and inviter pictures as Base64 for direct display in the response.
- Introduced a new endpoint `GET /features` to allow authenticated users to query available features.
- This addition enhances the user experience by providing access to feature-related information directly through the API.
- Updated the invitation resend process to accept a locale parameter, allowing for locale-specific email formatting and invitation link generation.
- Modified the `teamInvitationResend` function to include locale handling, ensuring proper configuration based on the user's locale.
- Enhanced the `toString` utility function to support time formatting based on locale, improving date presentation in emails.
- Added new utility functions for locale-specific time formatting, ensuring consistent user experience across different regions.
- Expanded tests to validate the new locale handling in invitation processes, ensuring comprehensive coverage for various scenarios.
- Removed assertions for the uploader and avatar agent fields in the team configuration tests, as these fields are no longer preserved in the public configuration.
- Updated the GetTeamConfigPublic function to reflect the changes in the TeamConfig structure, ensuring only relevant fields are included in the public configuration.
- Adjusted test cases to maintain coverage while aligning with the updated configuration structure.
- Enhanced the OIDC user info structure to include Yao member profile information, such as member ID, display name, bio, avatar, and email.
- Updated the SignIDToken and MakeOIDCUserInfo functions to incorporate member details if available, improving team context handling.
- Refactored the issueTokens function to accept a new IssueTokensParams structure, streamlining token issuance with team and member context.
- Adjusted login functions to retrieve and pass member profile data during token issuance, ensuring comprehensive user context in authentication flows.
- Introduced a new endpoint `GET /teams/:team_id/members/:member_id/profile` to allow users to retrieve member profile information, including display name, bio, avatar, and email.
- Implemented the `GinMemberGetProfile` handler to process profile retrieval requests with appropriate authentication and error handling.
- Added business logic in `memberGetProfile` to ensure only authenticated users can access their own profile data.
- Expanded test cases in `TestMemberProfileGet` to validate various scenarios for profile retrieval, ensuring comprehensive coverage for authentication and data validation.
- Added a new endpoint `PUT /teams/:team_id/members/:member_id/profile` to allow members to update their profile information, including display name, bio, avatar, and email.
- Introduced `UpdateMemberProfileRequest` structure to handle profile update requests.
- Enhanced the `GinMemberUpdateProfile` handler to process profile updates with appropriate validation and error handling.
- Implemented business logic in `memberUpdateProfile` to ensure only the member can update their own profile.
- Expanded test cases to validate the new profile update functionality, ensuring comprehensive coverage for various update scenarios.
- Introduced a new API endpoint `GET /file/:uploaderID/:fileID/content` to facilitate the retrieval of file content based on uploader ID and file ID.
- This addition enhances the user capabilities for accessing file data within the application.
- Enhanced the team creation and update processes to include an optional logo field, allowing teams to have custom logos.
- Updated the CreateTeamRequest and UpdateTeamRequest structures to accommodate the new logo field.
- Modified the GinTeamCreate and GinTeamUpdate handlers to handle logo data appropriately.
- Expanded test cases for team creation and updates to validate logo handling, ensuring comprehensive coverage for scenarios involving logos.
- Added avatar field to CreateRobotMemberRequest and UpdateRobotMemberRequest structures, allowing for avatar URL or file ID during member creation and updates.
- Updated GinMemberCreateRobot and GinMemberUpdateRobot handlers to process avatar information, ensuring it is included in the member data.
- Expanded test cases for member creation and updates to validate avatar handling, including scenarios for updating only the avatar without affecting other fields.
- Enhanced team configuration tests to verify preservation of uploader and avatar agent fields, improving overall test coverage and reliability.
- Added the `UpdateRobotMember` method to handle updates for robot members, including validation for member existence, type checks, and email uniqueness.
- Introduced a new `UpdateRobotMemberRequest` structure to facilitate updates via the API, allowing for modifications to various fields such as `robot_email`, `status`, and `autonomous_mode`.
- Enhanced the `GinMemberUpdateRobot` handler to process update requests, ensuring proper authentication and error handling for various scenarios.
- Expanded test coverage with new test cases for the robot member update functionality, validating successful updates, error conditions, and edge cases.
- Refactored existing member management logic to integrate the new update capabilities, improving overall system robustness and user experience.
- Introduced the `robot_email`, `authorized_senders`, and `email_filter_rules` fields to the robot member model, enhancing the configuration options for robot members.
- Updated the member creation and existence check logic to ensure the uniqueness of `robot_email` globally, improving data integrity.
- Refactored API endpoints and request/response structures to accommodate the new fields, ensuring consistency across the member management system.
- Enhanced test cases to validate the new robot member features, including scenarios for email uniqueness and configuration updates, improving overall test coverage and reliability.
- Introduced a new MemberListRequest structure to support advanced filtering options such as status, member_type, role_id, email, and display_name.
- Updated the GinMemberList handler to parse and validate query parameters, improving user experience with clearer error messages for invalid inputs.
- Enhanced the memberList function to handle advanced filtering and sorting, allowing for more flexible and efficient member retrieval.
- Added comprehensive test cases to validate new filtering and sorting functionalities, ensuring robust coverage and reliability in member listing scenarios.
- Refactored existing member response structures to include new fields and improve data representation.
- Added the is_owner field to the member model to indicate if a member is the team owner, improving clarity and performance for queries related to team ownership.
- Updated the team creation process to automatically set the is_owner field for the creator of the team, ensuring accurate member status upon creation.
- Refactored related tests to verify the correct assignment of the is_owner field, enhancing test coverage and reliability in team membership scenarios.
- Removed redundant permission and restriction fields from the member model to streamline the data structure and improve maintainability.
- Introduced member_id as a unique identifier for members, improving data integrity and consistency across member operations.
- Updated member-related functions to utilize member_id instead of internal IDs, enhancing API usability and clarity.
- Implemented email existence checks for team members, allowing for better validation during member creation and updates.
- Refactored existing tests to accommodate changes in member identification and email validation, ensuring comprehensive coverage and reliability.
- Added new API endpoint for checking if an email exists within a team, improving user experience during member management.
- Introduced a new endpoint for creating robot members, enhancing the member model to include fields specific to robots such as email, system prompt, and autonomous mode.
- Refactored existing member creation logic to accommodate robot-specific requirements and ensure email uniqueness within teams.
- Updated request and response structures to support the new robot member functionality, improving API consistency.
- Added comprehensive test cases to validate the new robot member creation process, including scenarios for required fields, duplicate emails, and invalid inputs.
- Introduced ObtainAccessTokenWithRootPermission function to streamline the creation of test users with root permissions, ensuring consistent access token generation for tests.
- Updated various test cases to utilize the new function, improving clarity and reducing redundancy in access token acquisition.
- Enhanced team configuration retrieval to expose public settings while hiding sensitive information, improving security in API responses.
- Added display_name, bio, and email fields to the member model for improved team-specific identity.
- Updated team invitation creation and acceptance logic to handle new profile fields, ensuring proper data management and user experience.
- Implemented logic to copy user profile fields when creating or updating members, enhancing data consistency.
- Refactored the team invitation creation function to utilize the new authorized package for improved user authentication checks.
- Enhanced the invitation acceptance logic to include the user ID of the person who updated the invitation, improving tracking and accountability.
- Adjusted the invitation data preparation to incorporate user-specific scopes, ensuring proper permissions are applied during invitation processing.
- Implemented path normalization in the ACL enforcement logic to ensure consistent matching by removing trailing slashes from request paths.
- Introduced a new utility function, normalizePath, to handle path normalization across various components.
- Updated endpoint matching and public endpoint checks to utilize the normalized paths, improving access decision accuracy.
- Enhanced team and member creation logic to include a new field, __yao_team_id, for better data management.
- Updated ACL configuration to include a PathPrefix field, allowing for dynamic path stripping from request URLs.
- Enhanced ACL enforcement logic to log the configured path prefix and adjust request paths accordingly during access checks.
- Improved logging throughout the enforcement process to provide clearer insights into access decisions and scope matching.
- Registered built-in scopes for temporary access tokens, enhancing flexibility in access control for specific endpoints.
- Updated scope management to support constraints for matched scopes, improving granularity in access control configurations.
- 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.
- Updated GinVerifyInvite function to replace session cookie sending with a new SendLoginCookies function, improving clarity in cookie management during user login processes.
- Enhanced handling of login responses to better accommodate different user statuses, streamlining the authentication flow.
- Updated the LoginThirdParty function to determine user status based on invitation requirements, setting it to "pending_invite" if an invite is required.
- Improved user data mapping to reflect the new status logic, enhancing the user experience during the registration process.
- 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.
- 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.
- 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.
- Implemented GinSendOTP function to handle resending OTP verification codes for user entry.
- Added EntrySendOTPResponse type to structure the response for OTP requests, including OTP ID and expiration time.
- Updated user routing to include a new endpoint for OTP requests, enhancing the 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.
- Added a new function, createPublicEntryConfig, to create a deep copy of EntryConfig without sensitive data, ensuring that global configuration remains intact when returning public config.
- Updated entry verification logic to utilize EntryVerificationStatus for clearer status handling during user verification.
- Enhanced tests to verify that the global config is not modified after multiple requests for public entry configuration, addressing a critical bug related to captcha secret exposure.
- Updated captcha test cases to utilize the new CaptchaGet function for retrieving captcha answers, improving test reliability.
- Refactored CaptchaMake and CaptchaValidate functions to leverage a new utils package for better encapsulation and maintainability.
- Enhanced error handling and logging in captcha-related processes, contributing to a more robust user experience during authentication.
- Streamlined the captcha generation process by integrating with the utils.captcha package, ensuring consistency across the codebase.
- Renamed and updated functions and tests to replace 'login' terminology with 'entry', reflecting the unified handling of login and registration processes.
- Removed deprecated login configuration functions and structures, streamlining the codebase.
- Enhanced test coverage for entry configuration retrieval and validation, ensuring comprehensive testing of the new unified approach.
- Improved error handling and logging for entry configuration scenarios, contributing to a better user experience during authentication.
- Replaced separate register configurations with a unified entry configuration that combines login and registration settings.
- Updated related functions and structures to support the new entry configuration, enhancing the user authentication process.
- Removed deprecated register configuration handling and endpoints, streamlining the codebase.
- Improved error handling for missing entry configurations, ensuring better user experience during authentication.
- Added support for processing environment variables in both register and form configurations, improving flexibility and configurability.
- Introduced a new MessengerConfig structure for handling messenger-related settings in the register configuration.
- Updated the RegisterConfig structure to include ThirdParty and InviteRequired fields, enhancing user registration options.
- Refactored the registration endpoint to retrieve configuration details, ensuring a more robust registration process.
- Implemented logging for missing environment variables to aid in configuration troubleshooting.