From ea7718d7b71455d9480689a7eccca192d6ad27b5 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 19 Aug 2023 23:15:02 +0800 Subject: [PATCH] Use Casvisor for records --- controllers/record.go | 121 ---------------- go.mod | 8 +- go.sum | 2 + main.go | 1 + object/organization.go | 8 -- object/ormer.go | 5 - object/record.go | 78 ++-------- object/record_casvisor.go | 50 +++++++ object/webhook_util.go | 14 +- routers/router.go | 3 - web/src/App.js | 8 +- web/src/RecordListPage.js | 239 ------------------------------- web/src/backend/RecordBackend.js | 25 ---- 13 files changed, 87 insertions(+), 475 deletions(-) delete mode 100644 controllers/record.go create mode 100644 object/record_casvisor.go delete mode 100644 web/src/RecordListPage.js delete mode 100644 web/src/backend/RecordBackend.js diff --git a/controllers/record.go b/controllers/record.go deleted file mode 100644 index 05b535bb..00000000 --- a/controllers/record.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2021 The Casdoor Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package controllers - -import ( - "encoding/json" - - "github.com/beego/beego/utils/pagination" - "github.com/casdoor/casdoor/object" - "github.com/casdoor/casdoor/util" -) - -// GetRecords -// @Title GetRecords -// @Tag Record API -// @Description get all records -// @Param pageSize query string true "The size of each page" -// @Param p query string true "The number of the page" -// @Success 200 {object} object.Record The Response object -// @router /get-records [get] -func (c *ApiController) GetRecords() { - organization, ok := c.RequireAdmin() - if !ok { - return - } - - limit := c.Input().Get("pageSize") - page := c.Input().Get("p") - field := c.Input().Get("field") - value := c.Input().Get("value") - sortField := c.Input().Get("sortField") - sortOrder := c.Input().Get("sortOrder") - organizationName := c.Input().Get("organizationName") - - if limit == "" || page == "" { - records, err := object.GetRecords() - if err != nil { - c.ResponseError(err.Error()) - return - } - - c.ResponseOk(records) - } else { - limit := util.ParseInt(limit) - if c.IsGlobalAdmin() && organizationName != "" { - organization = organizationName - } - filterRecord := &object.Record{Organization: organization} - count, err := object.GetRecordCount(field, value, filterRecord) - if err != nil { - c.ResponseError(err.Error()) - return - } - - paginator := pagination.SetPaginator(c.Ctx, limit, count) - records, err := object.GetPaginationRecords(paginator.Offset(), limit, field, value, sortField, sortOrder, filterRecord) - if err != nil { - c.ResponseError(err.Error()) - return - } - - c.ResponseOk(records, paginator.Nums()) - } -} - -// GetRecordsByFilter -// @Tag Record API -// @Title GetRecordsByFilter -// @Description get records by filter -// @Param filter body string true "filter Record message" -// @Success 200 {object} object.Record The Response object -// @router /get-records-filter [post] -func (c *ApiController) GetRecordsByFilter() { - body := string(c.Ctx.Input.RequestBody) - - record := &object.Record{} - err := util.JsonToStruct(body, record) - if err != nil { - c.ResponseError(err.Error()) - return - } - - records, err := object.GetRecordsByField(record) - if err != nil { - c.ResponseError(err.Error()) - return - } - - c.ResponseOk(records) -} - -// AddRecord -// @Title AddRecord -// @Tag Record API -// @Description add a record -// @Param body body object.Record true "The details of the record" -// @Success 200 {object} controllers.Response The Response object -// @router /add-record [post] -func (c *ApiController) AddRecord() { - var record object.Record - err := json.Unmarshal(c.Ctx.Input.RequestBody, &record) - if err != nil { - c.ResponseError(err.Error()) - return - } - - c.Data["json"] = wrapActionResponse(object.AddRecord(&record)) - c.ServeJSON() -} diff --git a/go.mod b/go.mod index 0357d9b8..8d90886e 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/casdoor/gomail/v2 v2.0.1 github.com/casdoor/oss v1.3.0 github.com/casdoor/xorm-adapter/v3 v3.0.4 + github.com/casvisor/casvisor-go-sdk v1.0.3 github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f github.com/denisenkom/go-mssqldb v0.9.0 github.com/elazarl/go-bindata-assetfs v1.0.1 // indirect @@ -26,7 +27,7 @@ require ( github.com/go-mysql-org/go-mysql v1.7.0 github.com/go-pay/gopay v1.5.72 github.com/go-sql-driver/mysql v1.6.0 - github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect + github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible github.com/go-webauthn/webauthn v0.6.0 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/uuid v1.3.0 @@ -36,7 +37,7 @@ require ( github.com/lor00x/goldap v0.0.0-20180618054307-a546dffdd1a3 github.com/markbates/goth v1.75.2 github.com/mitchellh/mapstructure v1.5.0 - github.com/nikoksr/notify v0.41.0 // indirect + github.com/nikoksr/notify v0.41.0 github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/nyaruka/phonenumbers v1.1.5 github.com/pquerna/otp v1.4.0 @@ -52,7 +53,7 @@ require ( github.com/siddontang/go-log v0.0.0-20190221022429-1e957dd83bed github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/stretchr/testify v1.8.4 - github.com/stripe/stripe-go/v74 v74.29.0 // indirect + github.com/stripe/stripe-go/v74 v74.29.0 github.com/tealeg/xlsx v1.0.5 github.com/thanhpk/randstr v1.0.4 github.com/tklauser/go-sysconf v0.3.10 // indirect @@ -65,6 +66,5 @@ require ( golang.org/x/oauth2 v0.10.0 gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 - gopkg.in/yaml.v2 v2.4.0 // indirect modernc.org/sqlite v1.18.2 ) diff --git a/go.sum b/go.sum index 62424524..e1a9d0a9 100644 --- a/go.sum +++ b/go.sum @@ -893,6 +893,8 @@ github.com/casdoor/oss v1.3.0 h1:D5pcz65tJRqJrWY11Ks7D9LUsmlhqqMHugjDhSxWTvk= github.com/casdoor/oss v1.3.0/go.mod h1:YOi6KpG1pZHTkiy9AYaqI0UaPfE7YkaA07d89f1idqY= github.com/casdoor/xorm-adapter/v3 v3.0.4 h1:vB04Ao8n2jA7aFBI9F+gGXo9+Aa1IQP6mTdo50913DM= github.com/casdoor/xorm-adapter/v3 v3.0.4/go.mod h1:4WTcUw+bTgBylGHeGHzTtBvuTXRS23dtwzFLl9tsgFM= +github.com/casvisor/casvisor-go-sdk v1.0.3 h1:TKJQWKnhtznEBhzLPEdNsp7nJK2GgdD8JsB0lFPMW7U= +github.com/casvisor/casvisor-go-sdk v1.0.3/go.mod h1:frnNtH5GA0wxzAQLyZxxfL0RSsSub9GQPi2Ybe86ocE= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= diff --git a/main.go b/main.go index 93ee30b9..c2765d83 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ func main() { proxy.InitHttpClient() authz.InitApi() object.InitUserManager() + object.InitCasvisorConfig() util.SafeGoroutine(func() { object.RunSyncUsersJob() }) diff --git a/object/organization.go b/object/organization.go index 634225a2..5ed56d3c 100644 --- a/object/organization.go +++ b/object/organization.go @@ -437,14 +437,6 @@ func organizationChangeTrigger(oldName string, newName string) error { return err } - record := new(Record) - record.Owner = newName - record.Organization = newName - _, err = session.Where("organization=?", oldName).Update(record) - if err != nil { - return err - } - resource := new(Resource) resource.Owner = newName _, err = session.Where("owner=?", oldName).Update(resource) diff --git a/object/ormer.go b/object/ormer.go index 205f04e0..9befaaa0 100644 --- a/object/ormer.go +++ b/object/ormer.go @@ -246,11 +246,6 @@ func (a *Ormer) createTable() { panic(err) } - err = a.Engine.Sync2(new(Record)) - if err != nil { - panic(err) - } - err = a.Engine.Sync2(new(Webhook)) if err != nil { panic(err) diff --git a/object/record.go b/object/record.go index c2c20f41..1fba819e 100644 --- a/object/record.go +++ b/object/record.go @@ -21,6 +21,7 @@ import ( "github.com/beego/beego/context" "github.com/casdoor/casdoor/conf" "github.com/casdoor/casdoor/util" + "github.com/casvisor/casvisor-go-sdk/casvisorsdk" ) var logPostOnly bool @@ -30,26 +31,10 @@ func init() { } type Record struct { - Id int `xorm:"int notnull pk autoincr" json:"id"` - - Owner string `xorm:"varchar(100) index" json:"owner"` - Name string `xorm:"varchar(100) index" json:"name"` - CreatedTime string `xorm:"varchar(100)" json:"createdTime"` - - Organization string `xorm:"varchar(100)" json:"organization"` - ClientIp string `xorm:"varchar(100)" json:"clientIp"` - User string `xorm:"varchar(100)" json:"user"` - Method string `xorm:"varchar(100)" json:"method"` - RequestUri string `xorm:"varchar(1000)" json:"requestUri"` - Action string `xorm:"varchar(1000)" json:"action"` - - Object string `xorm:"-" json:"object"` - ExtendedUser *User `xorm:"-" json:"extendedUser"` - - IsTriggered bool `json:"isTriggered"` + casvisorsdk.Record } -func NewRecord(ctx *context.Context) *Record { +func NewRecord(ctx *context.Context) *casvisorsdk.Record { ip := strings.Replace(util.GetIPFromRequest(ctx.Request), ": ", "", -1) action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1) requestUri := util.FilterQuery(ctx.Request.RequestURI, []string{"accessToken"}) @@ -62,7 +47,7 @@ func NewRecord(ctx *context.Context) *Record { object = string(ctx.Input.RequestBody) } - record := Record{ + record := casvisorsdk.Record{ Name: util.GenerateId(), CreatedTime: util.GetCurrentTime(), ClientIp: ip, @@ -76,7 +61,7 @@ func NewRecord(ctx *context.Context) *Record { return &record } -func AddRecord(record *Record) bool { +func AddRecord(record *casvisorsdk.Record) bool { if logPostOnly { if record.Method == "GET" { return false @@ -96,51 +81,19 @@ func AddRecord(record *Record) bool { fmt.Println(errWebhook) } - affected, err := ormer.Engine.Insert(record) + if casvisorsdk.GetClient() == nil { + return false + } + + affected, err := casvisorsdk.AddRecord(record) if err != nil { panic(err) } - return affected != 0 + return affected } -func GetRecordCount(field, value string, filterRecord *Record) (int64, error) { - session := GetSession("", -1, -1, field, value, "", "") - return session.Count(filterRecord) -} - -func GetRecords() ([]*Record, error) { - records := []*Record{} - err := ormer.Engine.Desc("id").Find(&records) - if err != nil { - return records, err - } - - return records, nil -} - -func GetPaginationRecords(offset, limit int, field, value, sortField, sortOrder string, filterRecord *Record) ([]*Record, error) { - records := []*Record{} - session := GetSession("", offset, limit, field, value, sortField, sortOrder) - err := session.Find(&records, filterRecord) - if err != nil { - return records, err - } - - return records, nil -} - -func GetRecordsByField(record *Record) ([]*Record, error) { - records := []*Record{} - err := ormer.Engine.Find(&records, record) - if err != nil { - return records, err - } - - return records, nil -} - -func SendWebhooks(record *Record) error { +func SendWebhooks(record *casvisorsdk.Record) error { webhooks, err := getWebhooksByOrganization(record.Organization) if err != nil { return err @@ -160,17 +113,16 @@ func SendWebhooks(record *Record) error { } if matched { + var user *User if webhook.IsUserExtended { - user, err := getUser(record.Organization, record.User) + user, err = getUser(record.Organization, record.User) user, err = GetMaskedUser(user, false, err) if err != nil { return err } - - record.ExtendedUser = user } - err := sendWebhook(webhook, record) + err = sendWebhook(webhook, record, user) if err != nil { return err } diff --git a/object/record_casvisor.go b/object/record_casvisor.go new file mode 100644 index 00000000..de35faac --- /dev/null +++ b/object/record_casvisor.go @@ -0,0 +1,50 @@ +// Copyright 2023 The Casdoor Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package object + +import ( + "strings" + + "github.com/casvisor/casvisor-go-sdk/casvisorsdk" +) + +func getCasvisorApplication() *Application { + applications, err := GetApplications("admin") + if err != nil { + panic(err) + } + + for _, application := range applications { + if strings.Contains(strings.ToLower(application.Name), "casvisor") { + return application + } + } + return nil +} + +func InitCasvisorConfig() { + application := getCasvisorApplication() + if application == nil { + return + } + + casvisorEndpoint := application.HomepageUrl + clientId := application.ClientId + clientSecret := application.ClientSecret + casdoorOrganization := application.Organization + casdoorApplication := application.Name + + casvisorsdk.InitConfig(casvisorEndpoint, clientId, clientSecret, casdoorOrganization, casdoorApplication) +} diff --git a/object/webhook_util.go b/object/webhook_util.go index a7458d8a..da30ace6 100644 --- a/object/webhook_util.go +++ b/object/webhook_util.go @@ -19,12 +19,22 @@ import ( "strings" "github.com/casdoor/casdoor/util" + "github.com/casvisor/casvisor-go-sdk/casvisorsdk" ) -func sendWebhook(webhook *Webhook, record *Record) error { +func sendWebhook(webhook *Webhook, record *casvisorsdk.Record, extendedUser *User) error { client := &http.Client{} - body := strings.NewReader(util.StructToJson(record)) + type RecordEx struct { + casvisorsdk.Record + ExtendedUser *User `xorm:"-" json:"extendedUser"` + } + recordEx := &RecordEx{ + Record: *record, + ExtendedUser: extendedUser, + } + + body := strings.NewReader(util.StructToJson(recordEx)) req, err := http.NewRequest(webhook.Method, webhook.Url, body) if err != nil { diff --git a/routers/router.go b/routers/router.go index deb646d9..d85c9248 100644 --- a/routers/router.go +++ b/routers/router.go @@ -181,9 +181,6 @@ func initAPI() { beego.Router("/api/login/oauth/access_token", &controllers.ApiController{}, "POST:GetOAuthToken") beego.Router("/api/login/oauth/refresh_token", &controllers.ApiController{}, "POST:RefreshToken") beego.Router("/api/login/oauth/introspect", &controllers.ApiController{}, "POST:IntrospectToken") - beego.Router("/api/get-records", &controllers.ApiController{}, "GET:GetRecords") - beego.Router("/api/get-records-filter", &controllers.ApiController{}, "POST:GetRecordsByFilter") - beego.Router("/api/add-record", &controllers.ApiController{}, "POST:AddRecord") beego.Router("/api/get-sessions", &controllers.ApiController{}, "GET:GetSessions") beego.Router("/api/get-session", &controllers.ApiController{}, "GET:GetSingleSession") diff --git a/web/src/App.js b/web/src/App.js index 5e3f0571..c2809099 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -43,7 +43,6 @@ import LdapEditPage from "./LdapEditPage"; import LdapSyncPage from "./LdapSyncPage"; import TokenListPage from "./TokenListPage"; import TokenEditPage from "./TokenEditPage"; -import RecordListPage from "./RecordListPage"; import WebhookListPage from "./WebhookListPage"; import WebhookEditPage from "./WebhookEditPage"; import SyncerListPage from "./SyncerListPage"; @@ -439,10 +438,10 @@ class App extends Component { } }))); - res.push(Setting.getItem({i18next.t("general:Logging & Auditing")}, "/logs", , [ - Setting.getItem({i18next.t("general:Records")}, "/records"), - Setting.getItem({i18next.t("general:Tokens")}, "/tokens"), + res.push(Setting.getItem({i18next.t("general:Logging & Auditing")}, "/logs", , [ Setting.getItem({i18next.t("general:Sessions")}, "/sessions"), + Setting.getItem({i18next.t("general:Records")}, "/records"), + Setting.getItem({i18next.t("general:Tokens")}, "/tokens"), ])); res.push(Setting.getItem({i18next.t("general:Business & Payments")}, "/business", , [ @@ -527,7 +526,6 @@ class App extends Component { this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> - this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn( this.setState({requiredEnableMfa: false})} {...props} />)} /> } /> this.renderLoginIfNotLoggedIn()} /> diff --git a/web/src/RecordListPage.js b/web/src/RecordListPage.js deleted file mode 100644 index f2b2b41e..00000000 --- a/web/src/RecordListPage.js +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2021 The Casdoor Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import React from "react"; -import {Link} from "react-router-dom"; -import {Switch, Table} from "antd"; -import * as Setting from "./Setting"; -import * as RecordBackend from "./backend/RecordBackend"; -import i18next from "i18next"; -import moment from "moment"; -import BaseListPage from "./BaseListPage"; - -class RecordListPage extends BaseListPage { - UNSAFE_componentWillMount() { - this.state.pagination.pageSize = 20; - const {pagination} = this.state; - this.fetch({pagination}); - } - - newRecord() { - return { - owner: "built-in", - name: "1234", - id: "1234", - clientIp: "::1", - timestamp: moment().format(), - organization: "built-in", - username: "admin", - requestUri: "/api/get-account", - action: "login", - isTriggered: false, - }; - } - - renderTable(records) { - let columns = [ - { - title: i18next.t("general:Name"), - dataIndex: "name", - key: "name", - width: "320px", - sorter: true, - ...this.getColumnSearchProps("name"), - }, - { - title: i18next.t("general:ID"), - dataIndex: "id", - key: "id", - width: "90px", - sorter: true, - ...this.getColumnSearchProps("id"), - }, - { - title: i18next.t("general:Client IP"), - dataIndex: "clientIp", - key: "clientIp", - width: "150px", - sorter: true, - ...this.getColumnSearchProps("clientIp"), - render: (text, record, index) => { - return ( - - {text} - - ); - }, - }, - { - title: i18next.t("general:Timestamp"), - dataIndex: "createdTime", - key: "createdTime", - width: "180px", - sorter: true, - render: (text, record, index) => { - return Setting.getFormattedDate(text); - }, - }, - { - title: i18next.t("general:Organization"), - dataIndex: "organization", - key: "organization", - width: "110px", - sorter: true, - ...this.getColumnSearchProps("organization"), - render: (text, record, index) => { - return ( - - {text} - - ); - }, - }, - { - title: i18next.t("general:User"), - dataIndex: "user", - key: "user", - width: "120px", - sorter: true, - ...this.getColumnSearchProps("user"), - render: (text, record, index) => { - return ( - - {text} - - ); - }, - }, - { - title: i18next.t("general:Method"), - dataIndex: "method", - key: "method", - width: "110px", - sorter: true, - filterMultiple: false, - filters: [ - {text: "GET", value: "GET"}, - {text: "HEAD", value: "HEAD"}, - {text: "POST", value: "POST"}, - {text: "PUT", value: "PUT"}, - {text: "DELETE", value: "DELETE"}, - {text: "CONNECT", value: "CONNECT"}, - {text: "OPTIONS", value: "OPTIONS"}, - {text: "TRACE", value: "TRACE"}, - {text: "PATCH", value: "PATCH"}, - ], - }, - { - title: i18next.t("general:Request URI"), - dataIndex: "requestUri", - key: "requestUri", - // width: '300px', - sorter: true, - ...this.getColumnSearchProps("requestUri"), - }, - { - title: i18next.t("general:Action"), - dataIndex: "action", - key: "action", - width: "200px", - sorter: true, - ...this.getColumnSearchProps("action"), - fixed: (Setting.isMobile()) ? "false" : "right", - render: (text, record, index) => { - return text; - }, - }, - { - title: i18next.t("record:Is triggered"), - dataIndex: "isTriggered", - key: "isTriggered", - width: "140px", - sorter: true, - fixed: (Setting.isMobile()) ? "false" : "right", - render: (text, record, index) => { - if (!["signup", "login", "logout", "update-user"].includes(record.action)) { - return null; - } - - return ( - - ); - }, - }, - ]; - - if (Setting.isLocalAdminUser(this.props.account)) { - columns = columns.filter(column => column.key !== "name"); - } - - const paginationProps = { - total: this.state.pagination.total, - pageSize: this.state.pagination.pageSize, - showQuickJumper: true, - showSizeChanger: true, - showTotal: () => i18next.t("general:{total} in total").replace("{total}", this.state.pagination.total), - }; - - return ( -
- ( -
- {i18next.t("general:Records")}     -
- )} - loading={this.state.loading} - onChange={this.handleTableChange} - /> - - ); - } - - fetch = (params = {}) => { - let field = params.searchedColumn, value = params.searchText; - const sortField = params.sortField, sortOrder = params.sortOrder; - if (params.method !== undefined && params.method !== null) { - field = "method"; - value = params.method; - } - this.setState({loading: true}); - RecordBackend.getRecords(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) - .then((res) => { - this.setState({ - loading: false, - }); - if (res.status === "ok") { - this.setState({ - data: res.data, - pagination: { - ...params.pagination, - total: res.data2, - }, - searchText: params.searchText, - searchedColumn: params.searchedColumn, - }); - } else { - if (res.data.includes("Please login first")) { - this.setState({ - loading: false, - isAuthorized: false, - }); - } - } - }); - }; -} - -export default RecordListPage; diff --git a/web/src/backend/RecordBackend.js b/web/src/backend/RecordBackend.js deleted file mode 100644 index bcc5b574..00000000 --- a/web/src/backend/RecordBackend.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 The Casdoor Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import * as Setting from "../Setting"; - -export function getRecords(organizationName, page, pageSize, field = "", value = "", sortField = "", sortOrder = "") { - return fetch(`${Setting.ServerUrl}/api/get-records?organizationName=${organizationName}&pageSize=${pageSize}&p=${page}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, { - method: "GET", - credentials: "include", - headers: { - "Accept-Language": Setting.getAcceptLanguage(), - }, - }).then(res => res.json()); -}