diff --git a/internal/handler/document.go b/internal/handler/document.go index b641661902..98d2a1af3d 100644 --- a/internal/handler/document.go +++ b/internal/handler/document.go @@ -1347,7 +1347,7 @@ func (h *DocumentHandler) Ingest(c *gin.Context) { userID := strings.TrimSpace(user.ID) if userID == "" { - common.ResponseWithCodeData(c, common.CodeAuthenticationError, nil, "No Authentication") + common.ResponseWithCodeData(c, common.CodeAuthenticationError, nil, "no authentication") return } diff --git a/internal/handler/user.go b/internal/handler/user.go index 223b41f7e0..cec77c6693 100644 --- a/internal/handler/user.go +++ b/internal/handler/user.go @@ -451,7 +451,7 @@ func (h *UserHandler) ChangePassword(c *gin.Context) { // @Tags users // @Success 200 {object} map[string]interface{} // @Router /v1/user/login/channels [get] -func (h *UserHandler) GetLoginChannels(c *gin.Context) { +func (h *UserHandler) GetLoginChannelsDeprecated(c *gin.Context) { channels, code, err := h.userService.GetLoginChannels() if err != nil { common.ResponseWithCodeData(c, code, []interface{}{}, "Load channels failure, error: "+err.Error()) diff --git a/internal/handler/user_auth.go b/internal/handler/user_auth.go index 2027339514..fbbfca6d5c 100644 --- a/internal/handler/user_auth.go +++ b/internal/handler/user_auth.go @@ -52,7 +52,7 @@ const oauthAuthCookie = "ragflow_auth" // @Tags users // @Param channel path string true "channel name" // @Router /api/v1/auth/login/{channel} [get] -func (h *UserHandler) OAuthLogin(c *gin.Context) { +func (h *UserHandler) OAuthLoginDeprecated(c *gin.Context) { channel := c.Param("channel") if channel == "" { common.ResponseWithHttpCodeData(c, http.StatusBadRequest, common.CodeArgumentError, nil, "channel is required") @@ -89,7 +89,7 @@ func (h *UserHandler) OAuthLogin(c *gin.Context) { // @Param code query string true "authorization code" // @Param state query string true "state token" // @Router /api/v1/auth/oauth/{channel}/callback [get] -func (h *UserHandler) OAuthChannelCallback(c *gin.Context) { +func (h *UserHandler) OAuthChannelCallbackDeprecated(c *gin.Context) { channel := c.Param("channel") // An empty channel segment (/auth/oauth//callback) is a malformed path, // not a real channel. Python's router never matches it and returns 404; diff --git a/internal/handler/user_auth_ee.go b/internal/handler/user_auth_ee.go index 9b3e207d17..0657aa7f06 100644 --- a/internal/handler/user_auth_ee.go +++ b/internal/handler/user_auth_ee.go @@ -65,3 +65,15 @@ func (h *UserHandler) IsAdmin(c *gin.Context) { func (h *UserHandler) GetMeta(c *gin.Context) { common.ErrorWithCode(c, common.CodeNotImplemented, "GetMeta not implemented") } + +func (h *UserHandler) OAuthLogin(c *gin.Context) { + common.ErrorWithCode(c, common.CodeNotImplemented, "OAuthLogin not implemented") +} + +func (h *UserHandler) OAuthChannelCallback(c *gin.Context) { + common.ErrorWithCode(c, common.CodeNotImplemented, "OAuthChannelCallback not implemented") +} + +func (h *UserHandler) GetLoginChannels(c *gin.Context) { + common.SuccessWithData(c, []interface{}{}, "success") +} diff --git a/internal/router/router.go b/internal/router/router.go index 6d1d4f4b68..d6c46440da 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -175,19 +175,9 @@ func (r *Router) Setup(engine *gin.Engine) { // searchbots apiNoAuth.GET("/searchbots/detail", r.searchBotHandler.SearchBotDetail) - // User login channels endpoint - apiNoAuth.GET("/auth/login/channels", r.userHandler.GetLoginChannels) - // User login by email endpoint apiNoAuth.POST("/auth/login", r.userHandler.LoginByEmail) - // OAuth / OIDC login routes. The static "channels" segment is - // registered before the wildcard, so gin's tree resolves - // /auth/login/channels to GetLoginChannels and other values to - // OAuthLogin without conflict. - apiNoAuth.GET("/auth/login/:channel", r.userHandler.OAuthLogin) - apiNoAuth.GET("/auth/oauth/:channel/callback", r.userHandler.OAuthChannelCallback) - // Register apiNoAuth.POST("/users", r.userHandler.Register) diff --git a/internal/router/router_ee.go b/internal/router/router_ee.go index 7105e192ce..be0c771017 100644 --- a/internal/router/router_ee.go +++ b/internal/router/router_ee.go @@ -25,6 +25,9 @@ func SetupEERouter(engine *gin.Engine) { func RegisterEENoAuthRouter(apiNoAuth *gin.RouterGroup, r *Router) { // For EE + apiNoAuth.GET("/auth/login/channels", r.userHandler.GetLoginChannels) + apiNoAuth.GET("/auth/login/:channel", r.userHandler.OAuthLogin) + apiNoAuth.GET("/auth/oauth/:channel/callback", r.userHandler.OAuthChannelCallback) apiNoAuth.GET("/auth/oauth/callback", r.userHandler.OAuthCallback) apiNoAuth.GET("/auth/oauth/github/callback", r.userHandler.GitHubAuthCallback) apiNoAuth.GET("/auth/oauth/lark/callback", r.userHandler.LarkAuthCallback)