mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-14 20:41:21 +08:00
feat: 合并近期功能与修复
- GLM/MiniMax 模型支持及 provider_name 修复 - OAuth2 登录跳转与重定向 hash 保留 - Azure 模型支持与转发特殊处理 - 后台登录与钉钉邮箱默认域名 - 转发获取密钥、Jinja 路径、RSA 私钥加载 - 模型管理可用模型输入与新增 - 自动更新权限、健康监测、admin 配置等 Co-authored-by: Cursor <github@npc0.com>
This commit is contained in:
@@ -30,6 +30,12 @@ func (appVersionApi *AppVersionApi) GetLatest(c *gin.Context) {
|
||||
platform := c.Query("platform")
|
||||
arch := c.Query("arch")
|
||||
token := c.Query("token")
|
||||
if token == "" {
|
||||
auth := c.GetHeader("Authorization")
|
||||
if len(auth) > 7 && auth[:7] == "Bearer " {
|
||||
token = auth[7:]
|
||||
}
|
||||
}
|
||||
if platform == "" {
|
||||
response.FailWithMessage("platform is required", c)
|
||||
return
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package gaia
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -117,6 +118,26 @@ func (m *ModelProviderApi) Proxy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 打印传入参数便于排查
|
||||
queryProvider := strings.TrimSpace(c.Query("provider"))
|
||||
var bodyModel string
|
||||
if len(body) > 0 {
|
||||
var parseObj map[string]interface{}
|
||||
if jsonErr := json.Unmarshal(body, &parseObj); jsonErr == nil {
|
||||
if m, ok := parseObj["model"].(string); ok {
|
||||
bodyModel = m
|
||||
}
|
||||
}
|
||||
}
|
||||
global.GVA_LOG.Info("Gaia代理请求入参",
|
||||
zap.String("path", path),
|
||||
zap.String("method", c.Request.Method),
|
||||
zap.String("query_provider", queryProvider),
|
||||
zap.Int("body_len", len(body)),
|
||||
zap.String("body_model", bodyModel),
|
||||
zap.String("body", string(body)),
|
||||
)
|
||||
|
||||
if err = modelProviderService.ProxyRequest(
|
||||
userID, path, c.Request.Method, reqHeader, body, c.Writer); err != nil {
|
||||
global.GVA_LOG.Error("代理请求失败", zap.String("user_id", userID), zap.String(
|
||||
|
||||
@@ -4,13 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
gaiaReq "github.com/flipped-aurora/gin-vue-admin/server/model/gaia/request"
|
||||
gaiaResponse "github.com/flipped-aurora/gin-vue-admin/server/model/gaia/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
systemRes "github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/service"
|
||||
@@ -20,6 +18,8 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var gaiaSystemIntegratedService = service.ServiceGroupApp.GaiaServiceGroup.SystemIntegratedService
|
||||
@@ -216,23 +216,25 @@ func (b *BaseApi) GetGaiaLoginOptions(c *gin.Context) {
|
||||
// @Param data body gaiaReq.GaiaOAuth2LoginReq true "code 或 access_token 二选一、redirect_uri、state"
|
||||
// @Router /base/gaiaOAuth2Login [post]
|
||||
func (b *BaseApi) GaiaOAuth2Login(c *gin.Context) {
|
||||
// init
|
||||
var err error
|
||||
var req gaiaReq.GaiaOAuth2LoginReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
var data = make(map[string]interface{})
|
||||
var result *gaiaResponse.GaiaLoginResult
|
||||
if err = c.ShouldBindJSON(&req); err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
result, err := gaiaSystemIntegratedService.OAuth2CodeLogin(req)
|
||||
if err != nil {
|
||||
|
||||
if result, err = gaiaSystemIntegratedService.OAuth2CodeLogin(req); err != nil {
|
||||
global.GVA_LOG.Error("Gaia OAuth2 登录失败", zap.Error(err))
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
data["expiresAt"] = 0
|
||||
data["user"] = result.User
|
||||
data["token"] = result.Token
|
||||
sysSvc.MenuServiceApp.UserAuthorityDefaultRouter(&result.User)
|
||||
data := map[string]interface{}{
|
||||
"user": result.User,
|
||||
"token": result.Token,
|
||||
"expiresAt": 0,
|
||||
}
|
||||
if result.RedirectURI != "" {
|
||||
data["redirect_uri"] = result.RedirectURI
|
||||
}
|
||||
@@ -262,8 +264,8 @@ func (b *BaseApi) GaiaDingTalkLogin(c *gin.Context) {
|
||||
}
|
||||
sysSvc.MenuServiceApp.UserAuthorityDefaultRouter(&result.User)
|
||||
data := map[string]interface{}{
|
||||
"user": result.User,
|
||||
"token": result.Token,
|
||||
"user": result.User,
|
||||
"token": result.Token,
|
||||
"expiresAt": 0,
|
||||
}
|
||||
if result.RedirectURI != "" {
|
||||
|
||||
Reference in New Issue
Block a user