mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-22 01:35:24 -04:00
d80630acd5
* feat: implement OAuth functionality in plugin daemon - Added OAuth service methods for getting authorization URLs and credentials. - Updated access types to include OAuth-related actions. - Created new controller for handling OAuth requests. - Introduced entities for OAuth results and requests. - Enhanced plugin entities to support OAuth schema in tool declarations. * feat: add OAuth endpoints for authorization and credentials retrieval - Introduced new POST endpoints for obtaining authorization URLs and credentials in the OAuth controller. - Enhanced the plugin dispatch group to include these new OAuth routes, improving integration with OAuth services.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/service"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/app"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/entities/requests"
|
|
)
|
|
|
|
func OAuthGetAuthorizationURL(config *app.Config) gin.HandlerFunc {
|
|
type request = plugin_entities.InvokePluginRequest[requests.RequestOAuthGetAuthorizationURL]
|
|
|
|
return func(c *gin.Context) {
|
|
BindPluginDispatchRequest(
|
|
c,
|
|
func(ipr request) {
|
|
service.OAuthGetAuthorizationURL(
|
|
&ipr,
|
|
c,
|
|
time.Duration(config.PluginMaxExecutionTimeout)*time.Second,
|
|
)
|
|
},
|
|
)
|
|
}
|
|
}
|
|
|
|
func OAuthGetCredentials(config *app.Config) gin.HandlerFunc {
|
|
type request = plugin_entities.InvokePluginRequest[requests.RequestOAuthGetCredentials]
|
|
|
|
return func(c *gin.Context) {
|
|
BindPluginDispatchRequest(c, func(ipr request) {
|
|
service.OAuthGetCredentials(
|
|
&ipr,
|
|
c,
|
|
time.Duration(config.PluginMaxExecutionTimeout)*time.Second,
|
|
)
|
|
})
|
|
}
|
|
}
|