Commit graph

341 commits

Author SHA1 Message Date
Max
d603504db9 Enhance OAuth authorization URL handling and improve public configuration creation
- Added debug logging for redirect URI and client ID in the OAuth authorization URL function to aid in troubleshooting.
- Refactored the createPublicConfig function to perform deep copies of configuration structures, ensuring sensitive data is not exposed while maintaining necessary fields for frontend use.
- Improved handling of Captcha and ThirdParty provider configurations to exclude sensitive information, enhancing security in public-facing configurations.
2025-07-31 15:18:20 +08:00
Max
e0b12d7bb7 Add Captcha handlers to OpenAPI routing
- Integrated Captcha functionality by adding a new route for captcha handlers within the OpenAPI structure.
- Updated the Attach method to include the Captcha endpoint, ensuring OAuth protection for the new route.
- Enhanced overall routing organization by grouping captcha-related handlers under a dedicated path.
2025-07-31 10:35:02 +08:00
Max
409151037a Add Cloudflare Turnstile configuration and enhance OAuth handling in Signin API
- Added Cloudflare Turnstile site key and secret to the environment variables in both `pr-test.yml` and `unit-test.yml` workflows.
- Introduced a new endpoint in the Signin API for generating OAuth authorization URLs, improving support for third-party authentication providers.
- Enhanced the handling of OAuth provider configurations, including validation and error responses for missing or incomplete settings.
- Updated tests to cover the new OAuth authorization URL functionality and ensure sensitive data is not exposed in public configurations.
2025-07-30 20:19:55 +08:00
Max
315618da47 Add Signin API and update file management endpoints
- Introduced a comprehensive Signin API for user authentication, supporting multiple OAuth providers (Google, GitHub, Microsoft, Apple).
- Updated the file management API endpoints to use a singular `/file` path instead of `/files`, enhancing consistency across the API.
- Revised README documentation to include detailed descriptions of the new Signin API and updated file management endpoints.
- Enhanced test cases to reflect the changes in endpoint structure and ensure robust coverage for the new Signin functionality.
2025-07-30 16:49:28 +08:00
Max
1f2eaf6974 Refactor Agent API to Chat API for AI interactions
- Replaced the Agent API with the Chat API, focusing on AI chat completions with full OpenAI client compatibility and real-time streaming capabilities.
- Updated routing to attach chat handlers instead of agent handlers, ensuring OAuth protection for all endpoints.
- Revised README documentation to reflect the new Chat API structure, including detailed descriptions of endpoints, features, and usage examples.
- Removed the deprecated agent files and their associated documentation to streamline the codebase.
2025-07-27 15:35:55 +08:00
Max
f54d030486 Add Agent API for AI interactions and chat completions
- Introduced the Agent API to facilitate AI agent interactions, including chat completions with real-time streaming capabilities.
- Implemented endpoints for GET and POST requests to handle chat completions, supporting features like context management and assistant selection.
- Updated the README to include comprehensive documentation for the Agent API, detailing its functionalities, key endpoints, and usage examples.
- Enhanced the OpenAPI structure to integrate the new agent handlers into the existing routing system, ensuring OAuth protection for all endpoints.
2025-07-27 15:18:54 +08:00
Max
c3b374f043 Implement LocalPath functionality for attachment management
- Added LocalPath method to the Manager and Storage interfaces to retrieve the absolute path and content type of files.
- Enhanced local and S3 storage implementations to support LocalPath, including handling gzipped files and content type detection.
- Introduced comprehensive tests for LocalPath functionality, covering various file types, non-existent files, and gzipped content.
- Updated AddFile API to utilize LocalPath for retrieving file information, improving error handling and response consistency.
2025-07-27 09:48:49 +08:00
Max
070ff59225 Enhance attachment management with file storage improvements
- Refactored the attachment manager to support file uploads with a new storage path and improved metadata handling.
- Implemented chunked uploads and direct content retrieval, enhancing performance and flexibility.
- Updated the file management API to include comprehensive operations for file uploads, downloads, and metadata management.
- Added support for multiple storage backends, including local and S3, with improved error handling and validation.
- Enhanced test coverage for file operations, ensuring reliability and consistency across different storage implementations.
2025-07-26 19:25:41 +08:00
Max
1c4fd3d20c Implement file and segment management API endpoints with error handling
- Added AddFile, AddText, AddURL, and AddSegments functions to handle file and segment uploads, including JSON request parsing and validation.
- Integrated error handling for invalid requests and uninitialized Knowledge Base instances, ensuring robust API responses.
- Enhanced response structures for success and error cases, improving consistency across the API.
- Updated AutoDetectConverter function to use a single content type parameter instead of multiple content types.
2025-07-25 16:35:19 +08:00
Max
bb64eef20d Implement environment variable resolution in configuration parsing and enhance collection management API
- Added a new test for resolving environment variables during configuration parsing, ensuring that environment variables are correctly substituted in the configuration.
- Refactored the configuration handling to resolve environment variables immediately after parsing, improving the clarity and usability of the configuration structure.
- Enhanced the collection management API by standardizing error responses and success responses using a custom response structure, improving consistency across endpoints.
- Implemented cleanup logic for test collections to ensure proper resource management during testing.
2025-07-24 17:08:58 +08:00
Max
8d35e824ae Remove deprecated test files and refactor OAuth response handling
- Deleted obsolete test files for various OpenAPI components, including config_test.go, dsl_test.go, hello_test.go, oauth_test.go, oauth_token_test.go, and openapi_test.go, to streamline the codebase.
- Refactored OAuth response handling by integrating response methods from the response package, ensuring consistent error and success responses across OAuth endpoints.
- Enhanced error handling and response structure for improved clarity and maintainability, aligning with best practices for API responses.
2025-07-24 15:53:29 +08:00
Max
aae1bccf88 Add Knowledge Base API endpoints and integrate with OpenAPI router
- Introduced the Knowledge Base (KB) API by creating a new kb package with various endpoints for collection and document management, segment management, and search functionalities.
- Updated the OpenAPI router to attach the KB API, ensuring OAuth protection for all endpoints.
- Implemented logging for configuration validation to enhance error handling and user feedback.
2025-07-23 15:19:40 +08:00
Max
92d21c5389 Remove hello world endpoints and refactor routing to use new hello package
- Deleted the existing hello world handlers from hello.go to streamline the codebase.
- Updated openapi.go to attach the new hello package for handling hello world routes, ensuring OAuth protection is applied correctly.
- Enhanced the README.md to reflect the new structure and provide comprehensive documentation for the hello world API endpoints.
2025-07-22 16:55:24 +08:00
Max
d54572a7d1 Refactor OAuth response handling and improve content type management
- Updated response methods to standardize Content-Type header to "application/json" across OAuth endpoints, enhancing compliance with JSON standards.
- Refactored error and success response methods to streamline response generation without unnecessary wrappers, improving clarity and maintainability.
- Enhanced security by ensuring all responses include appropriate OAuth security headers, aligning with best practices for sensitive endpoints.
- Simplified test assertions for Content-Type in OAuth tests, ensuring consistency in response validation.
2025-07-22 15:36:41 +08:00
Max
7e8d4a9ba9 Enhance OAuth token management with PKCE support and refactor tests
- Updated OAuth token handling to include PKCE (Proof Key for Code Exchange) parameters, improving security for authorization code grants.
- Refactored token management tests to incorporate PKCE code verifier and challenge, ensuring compliance with OAuth 2.1 standards.
- Enhanced refresh token handling to validate requested scopes against originally granted scopes, improving security and compliance.
- Updated various methods to support optional scope parameters, streamlining token management and validation processes.
- Improved test coverage for token introspection and exchange scenarios, ensuring robust validation of token handling logic.
2025-07-22 12:55:44 +08:00
Max
41c44cb726 Implement JWKS endpoint and enhance OAuth tests
- Added the JWKS endpoint to return JSON Web Key Set in compliance with RFC 7517, including necessary security headers.
- Refactored the JWKS generation logic to retrieve signing certificates and construct the JWK from the RSA public key.
- Introduced comprehensive tests for the JWKS endpoint, validating response format, compliance, and security headers.
- Updated go.mod to include the MongoDB driver as a required dependency.
2025-07-21 20:07:46 +08:00
Max
966e0cfd00 Enhance OAuth test setup with reusable certificate management
- Introduced global test certificate paths to avoid redundant certificate generation across tests, improving efficiency.
- Implemented a function to create temporary certificates once for all tests, ensuring consistent usage of signing certificates.
- Updated test configurations to utilize the new certificate management, enhancing clarity and maintainability.
- Added cleanup functionality for global test certificates to ensure proper resource management after tests.
2025-07-21 19:44:00 +08:00
Max
e1428551ba Refactor OAuth token management tests and remove deprecated methods
- Removed outdated token management tests from the user provider, including tests for storing, revoking, and retrieving tokens.
- Updated the user provider interface to reflect the removal of token management methods, ensuring cleaner code and improved maintainability.
- Streamlined the test suite by focusing on relevant user management functionalities, enhancing overall test clarity and effectiveness.
2025-07-21 18:59:26 +08:00
Max
8d1174d566 Refactor hello world endpoints and add OAuth protection
- Renamed existing hello world endpoints to public and added a new protected endpoint with OAuth guard.
- Updated test cases to reflect the new endpoint structure and added tests for protected endpoint access with and without valid tokens.
- Enhanced response handling for public and protected endpoints to ensure consistent output and proper status codes.
2025-07-21 18:49:20 +08:00
Max
55931bb59b Add OAuth token revocation and introspection tests
- Implemented comprehensive tests for the OAuth token revocation and introspection endpoints, ensuring correct handling of valid, invalid, and missing token scenarios.
- Enhanced the oauthRevoke and oauthIntrospect methods to comply with RFC specifications, returning appropriate status codes and responses.
- Introduced a utility function for obtaining access tokens directly in tests, streamlining the testing process for OAuth endpoints.
- Improved error handling and logging for better debugging and verification during tests.
2025-07-21 17:57:34 +08:00
Max
2b171c3540 Refactor OAuth token handling and enhance grant type support
- Consolidated token grant handling into a unified method for authorization code, client credentials, and device code grants, improving code organization and reducing duplication.
- Introduced new methods for handling token exchange and refresh token grants, ensuring compliance with relevant RFCs.
- Enhanced error handling and validation for client credentials and grant types, improving robustness and security.
- Updated tests to utilize real authorization codes and ensure comprehensive coverage of the new functionality.
2025-07-21 17:40:08 +08:00
Max
e4a02d6b9c Add OAuth authorization tests and improve error handling 2025-07-21 16:21:40 +08:00
Max
e936407452 Enhance OAuth functionality with registration tests and response improvements
- Added a comprehensive test for the OAuth client registration endpoint, ensuring proper handling of valid requests and responses.
- Updated the response handling methods to comply with RFC standards, including a new method for direct OAuth responses.
- Refactored existing response methods to improve security header management and streamline response generation.
- Enhanced test logging for better debugging and verification of response data during OAuth registration tests.
2025-07-21 16:07:40 +08:00
Max
517a4cf5b0 Implement OAuth endpoint logic and enhance test setup
- Added core functionality for OAuth authorization, token handling, and user info retrieval, including error handling and response generation.
- Introduced helper functions for managing different grant types, improving code organization and clarity.
- Enhanced the test setup with a new Prepare function to initialize the OpenAPI test environment and a Clean function for proper resource management.
- Updated tests to ensure the OpenAPI server is correctly loaded and operational during testing.
2025-07-21 15:34:13 +08:00
Max
458391f5b4 Refactor OAuth endpoint structure and add well-known handlers
- Removed OAuth discovery and metadata endpoints from the attachOAuth function to streamline the code.
- Introduced a new method to handle well-known endpoints, improving organization and clarity in the OAuth implementation.
- Updated the Attach method to include the new well-known handlers, ensuring proper routing for OAuth-related metadata.
2025-07-20 19:11:16 +08:00
Max
6256e131b3 Add OAuth documentation for versioned paths and discovery endpoints
- Added notes in the OAuth handler to clarify the requirements for using versioned paths, including the placement of discovery endpoints and server metadata.
- Emphasized the importance of mounting discovery endpoints at the root level for proper MCP client configuration and OAuth functionality.
2025-07-20 19:05:41 +08:00
Max
b96a400869 Add OpenAPI support and enhance configuration handling
- Integrated OpenAPI loading functionality into the engine's Load and Reload processes, allowing for better API management.
- Updated the OpenAPI configuration to set a default BaseURL and ensure it does not have a trailing slash.
- Implemented the Attach method to connect the OpenAPI server to the Gin router, facilitating API endpoint management.
- Removed the obsolete hello package to streamline the OpenAPI module.
2025-07-20 18:52:30 +08:00
Max
0fff602c93 Implement JSON marshaling and unmarshaling for configuration with duration parsing
- Enhanced the Config struct to support JSON marshaling and unmarshaling with human-readable duration strings for various OAuth settings.
- Introduced temporary structures to facilitate the conversion of string duration fields to time.Duration types during JSON operations.
- Added utility functions for parsing and formatting duration strings, ensuring accurate handling of time-related configurations.
- Updated tests to validate the correct parsing and formatting of duration fields in the configuration.
2025-07-20 17:49:01 +08:00
Max
8523170992 Implement system store management and enhance store loading functionality
- Introduced a new system store management feature, allowing for the loading of predefined system stores such as cache and OAuth client stores.
- Added a `loadSystemStores` function to handle the loading of system stores with variable replacement for configuration paths.
- Enhanced the `Load` function to include the loading of system stores, improving the overall store management process.
- Updated test utilities to support loading system stores for testing, ensuring comprehensive coverage and functionality.
- Refactored the `replaceVars` function to facilitate variable replacement in JSON strings, enhancing flexibility in store configurations.
2025-07-20 11:23:00 +08:00
Max
72b732348d Enhance OAuth configuration types with optional defaults
- Updated the SigningConfig, TokenConfig, SecurityConfig, and ClientConfig structures to include optional default values for various fields, improving clarity and usability.
- Added comments to specify default values and optionality for each configuration parameter, enhancing documentation within the code.
- This change aims to streamline the configuration process for OAuth service implementations.
2025-07-18 17:05:13 +08:00
Max
ef07622e7e Add user and security tests 2025-07-18 15:48:50 +08:00
Max
2610036082 Refactor token exchange implementation in OAuth service
- Updated the TokenExchange method to utilize a new generateExchangedToken function for improved token generation.
- Enhanced error handling to return a descriptive error response if token generation fails.
- Added a new generateExchangedToken function to encapsulate the logic for creating exchanged tokens, improving code organization and maintainability.
2025-07-18 15:30:52 +08:00
Max
b959768016 Refactor dynamic client registration tests in OAuth service
- Updated test cases to improve coverage for dynamic client registration scenarios.
- Enhanced error handling tests for various client registration edge cases, ensuring robustness in validation processes.
- Streamlined test setup for consistency across different testing environments.
2025-07-18 15:13:08 +08:00
Max
9fd0d4713a Add tests for dynamic client registration validation in OAuth service
- Implemented tests to verify error handling for disallowed redirect URI hosts and schemes during dynamic client registration.
- Updated test clients to use localhost for redirect URIs, ensuring consistency in testing environment.
2025-07-18 14:58:29 +08:00
Max
944c3e1b8e Enhance client creation and dynamic registration in OAuth service
- Added default values for grant types, response types, application type, and token endpoint auth method during dynamic client registration.
- Implemented nil checks for client information in the CreateClient and UpdateClient methods to ensure robust error handling and validation.
2025-07-18 14:51:34 +08:00
Max
d3874b28ad Refactor OAuth service to improve client registration and user management
- Enhanced dynamic client registration by refining client ID and secret generation methods.
- Improved validation processes for client registration requests and authorization flows.
- Streamlined user management integration with the updated user model, ensuring compatibility and efficiency.
- Updated token management features to support new client and user interactions, enhancing overall service functionality.
2025-07-18 14:28:44 +08:00
Max
58eb00f8f2 Implement dynamic client registration and enhance OAuth service functionality
- Added dynamic client registration support in the OAuth service, implementing RFC 7591 for automatic client registration.
- Introduced methods for generating client IDs and secrets, validating registration requests, and creating client information.
- Enhanced authorization flow by validating client requests, redirect URIs, and response types.
- Implemented token management features, including token introspection, token exchange, and refresh token handling.
- Improved security with state parameter generation and validation, as well as code challenge methods for PKCE.
- Updated endpoint discovery and server metadata retrieval to include new features and capabilities.
2025-07-18 12:11:21 +08:00
Max
fb20eb54c5 Add user model integration and enhance OAuth user provider
- Introduced a new user model `yao/models/user.mod.yao` to support user management functionalities.
- Updated the OAuth service to utilize the new `DefaultUser` provider, enhancing user authentication and management capabilities.
- Refactored user retrieval methods to align with the new user model structure, ensuring compatibility and improved functionality.
- Added token management methods to the user provider interface, streamlining token handling processes.
- Enhanced test utilities to include the new user model for comprehensive testing coverage.
2025-07-18 11:31:39 +08:00
Max
e19aa4b8df Remove deprecated OAuth interfaces and types
- Deleted the OAuth interface and related types that were previously defined in the `interfaces.go` and `types.go` files, streamlining the codebase.
- Updated the `oauth.go` file to integrate user and client providers directly, enhancing the service's functionality and reducing complexity.
- Refactored the user information retrieval method to utilize the new user provider structure, ensuring compatibility with the updated architecture.
2025-07-17 17:19:22 +08:00
Max
54607bc3ee Add OAuth service implementation with configuration and validation
- Introduced the OAuth service structure, including configuration management and user provider integration.
- Implemented default settings and validation for various configuration parameters, ensuring robust service initialization.
- Added methods for retrieving service configuration and user information based on access tokens.
- Defined error handling for configuration issues, enhancing reliability of the OAuth service.
2025-07-17 12:04:42 +08:00
Max
a13fe36aa6 Update dependencies in go.mod and go.sum to latest versions for improved stability and performance 2025-07-13 09:15:54 +08:00