Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: init commit for security feature #75

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ api:
web:
enabled: true
embedding_api: false
auth:
enabled: true
network:
binding: $[[env.WEB_BINDING]]
tls:
Expand Down
24 changes: 16 additions & 8 deletions docs/content.en/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ Information about release notes of Coco Server is provided here.
## Latest (In development)

### Features
- Indexing API
- Search API
- Suggest API
- Assistant Chat API
- Google Drive Connector
- Yuque Connector
- Notion Connector
- RAG based Chat
### Breaking changes
### Bug fix
### Improvements

## 0.1.0 (2015-02-16)

### Features
- Indexing API
- Search API
- Suggest API
- Assistant Chat API
- Google Drive Connector
- Yuque Connector
- Notion Connector
- RAG based Chat
- Basic security

### Breaking changes

Expand Down
15 changes: 8 additions & 7 deletions modules/assistant/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package assistant

import (
"infini.sh/coco/plugins/security/core"
"infini.sh/framework/core/api"
)

Expand All @@ -15,11 +16,11 @@ type APIHandler struct {
func init() {
handler := APIHandler{}

api.HandleAPIMethod(api.GET, "/chat/_history", handler.getChatSessions)
api.HandleAPIMethod(api.POST, "/chat/_new", handler.newChatSession)
api.HandleAPIMethod(api.POST, "/chat/:session_id/_open", handler.openChatSession)
api.HandleAPIMethod(api.POST, "/chat/:session_id/_send", handler.sendChatMessage)
api.HandleAPIMethod(api.POST, "/chat/:session_id/_cancel", handler.cancelReplyMessage)
api.HandleAPIMethod(api.POST, "/chat/:session_id/_close", handler.closeChatSession)
api.HandleAPIMethod(api.GET, "/chat/:session_id/_history", handler.getChatHistoryBySession)
api.HandleUIMethod(api.GET, "/chat/_history", core.RequireLogin(handler.getChatSessions))
api.HandleUIMethod(api.POST, "/chat/_new", core.RequireLogin(handler.newChatSession))
api.HandleUIMethod(api.POST, "/chat/:session_id/_open", core.RequireLogin(handler.openChatSession))
api.HandleUIMethod(api.POST, "/chat/:session_id/_send", core.RequireLogin(handler.sendChatMessage))
api.HandleUIMethod(api.POST, "/chat/:session_id/_cancel", core.RequireLogin(handler.cancelReplyMessage))
api.HandleUIMethod(api.POST, "/chat/:session_id/_close", core.RequireLogin(handler.closeChatSession))
api.HandleUIMethod(api.GET, "/chat/:session_id/_history", core.RequireLogin(handler.getChatHistoryBySession))
}
57 changes: 0 additions & 57 deletions modules/auth/init.go

This file was deleted.

21 changes: 11 additions & 10 deletions modules/connector/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package connector

import (
"infini.sh/coco/plugins/security/core"
"infini.sh/framework/core/api"
)

Expand All @@ -15,16 +16,16 @@ type APIHandler struct {
func init() {
handler := APIHandler{}

api.HandleAPIMethod(api.POST, "/connector/", handler.create)
api.HandleAPIMethod(api.GET, "/connector/:id", handler.get)
api.HandleAPIMethod(api.PUT, "/connector/:id", handler.update)
api.HandleAPIMethod(api.DELETE, "/connector/:id", handler.delete)
api.HandleAPIMethod(api.GET, "/connector/_search", handler.search)
api.HandleUIMethod(api.POST, "/connector/", core.RequireLogin(handler.create))
api.HandleUIMethod(api.GET, "/connector/:id", core.RequireLogin(handler.get))
api.HandleUIMethod(api.PUT, "/connector/:id", core.RequireLogin(handler.update))
api.HandleUIMethod(api.DELETE, "/connector/:id", core.RequireLogin(handler.delete))
api.HandleUIMethod(api.GET, "/connector/_search", core.RequireLogin(handler.search))

api.HandleAPIMethod(api.POST, "/datasource/", handler.createDatasource)
api.HandleAPIMethod(api.DELETE, "/datasource/:id", handler.deleteDatasource)
api.HandleAPIMethod(api.GET, "/datasource/:id", handler.getDatasource)
api.HandleAPIMethod(api.PUT, "/datasource/:id", handler.updateDatasource)
api.HandleAPIMethod(api.GET, "/datasource/_search", handler.searchDatasource)
api.HandleUIMethod(api.POST, "/datasource/", core.RequireLogin(handler.createDatasource))
api.HandleUIMethod(api.DELETE, "/datasource/:id", core.RequireLogin(handler.deleteDatasource))
api.HandleUIMethod(api.GET, "/datasource/:id", core.RequireLogin(handler.getDatasource))
api.HandleUIMethod(api.PUT, "/datasource/:id", core.RequireLogin(handler.updateDatasource))
api.HandleUIMethod(api.GET, "/datasource/_search", core.RequireLogin(handler.searchDatasource))

}
11 changes: 6 additions & 5 deletions modules/indexing/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package indexing

import (
"infini.sh/coco/plugins/security/core"
"infini.sh/framework/core/api"
)

Expand All @@ -16,9 +17,9 @@ func init() {
handler := APIHandler{}

//for internal document management, security should be enabled
api.HandleAPIMethod(api.POST, "/document/", handler.createDoc)
api.HandleAPIMethod(api.GET, "/document/:doc_id", handler.getDoc)
api.HandleAPIMethod(api.PUT, "/document/:doc_id", handler.updateDoc)
api.HandleAPIMethod(api.DELETE, "/document/:doc_id", handler.deleteDoc)
api.HandleAPIMethod(api.GET, "/document/_search", handler.searchDocs)
api.HandleUIMethod(api.POST, "/document/", core.RequireLogin(handler.createDoc))
api.HandleUIMethod(api.GET, "/document/:doc_id", core.RequireLogin(handler.getDoc))
api.HandleUIMethod(api.PUT, "/document/:doc_id", core.RequireLogin(handler.updateDoc))
api.HandleUIMethod(api.DELETE, "/document/:doc_id", core.RequireLogin(handler.deleteDoc))
api.HandleUIMethod(api.GET, "/document/_search", core.RequireLogin(handler.searchDocs))
}
7 changes: 4 additions & 3 deletions modules/search/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package search

import (
"infini.sh/coco/plugins/security/core"
"infini.sh/framework/core/api"
)

Expand All @@ -15,8 +16,8 @@ type APIHandler struct {
func init() {
handler := APIHandler{}

api.HandleAPIMethod(api.GET, "/query/_suggest", handler.suggest)
api.HandleAPIMethod(api.GET, "/query/_recommend", handler.recommend)
api.HandleAPIMethod(api.GET, "/query/_search", handler.search)
api.HandleUIMethod(api.GET, "/query/_suggest", core.RequireLogin(handler.suggest))
api.HandleUIMethod(api.GET, "/query/_recommend", core.RequireLogin(handler.recommend))
api.HandleUIMethod(api.GET, "/query/_search", core.RequireLogin(handler.search))

}
7 changes: 4 additions & 3 deletions plugins/connectors/google_drive/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"golang.org/x/oauth2/google"
"google.golang.org/api/drive/v3"
"infini.sh/coco/modules/common"
"infini.sh/coco/plugins/security/core"
"infini.sh/framework/core/api"
config3 "infini.sh/framework/core/config"
"infini.sh/framework/core/env"
Expand Down Expand Up @@ -97,9 +98,9 @@ func (this *Plugin) Setup() {
"https://www.googleapis.com/auth/userinfo.profile", // Access the user's profile information
}

api.HandleUIMethod(api.GET, "/connector/google_drive/connect", this.connect)
api.HandleUIMethod(api.POST, "/connector/google_drive/reset", this.reset)
api.HandleUIMethod(api.GET, "/connector/google_drive/oauth_redirect", this.oAuthRedirect)
api.HandleUIMethod(api.GET, "/connector/google_drive/connect", core.RequireLogin(this.connect))
api.HandleUIMethod(api.POST, "/connector/google_drive/reset", core.RequireLogin(this.reset))
api.HandleUIMethod(api.GET, "/connector/google_drive/oauth_redirect", core.RequireLogin(this.oAuthRedirect))

}

Expand Down
Loading