diff --git a/go.mod b/go.mod index be2b34e7..4e864394 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/casdoor/go-sms-sender v0.19.0 github.com/casdoor/gomail/v2 v2.0.1 github.com/casdoor/notify v0.45.0 - github.com/casdoor/oss v1.4.1 + github.com/casdoor/oss v1.5.0 github.com/casdoor/xorm-adapter/v3 v3.1.0 github.com/casvisor/casvisor-go-sdk v1.0.3 github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f diff --git a/go.sum b/go.sum index cc87ae52..af4e241b 100644 --- a/go.sum +++ b/go.sum @@ -1091,6 +1091,8 @@ github.com/casdoor/notify v0.45.0 h1:OlaFvcQFjGOgA4mRx07M8AH1gvb5xNo21mcqrVGlLgk github.com/casdoor/notify v0.45.0/go.mod h1:wNHQu0tiDROMBIvz0j3Om3Lhd5yZ+AIfnFb8MYb8OLQ= github.com/casdoor/oss v1.4.1 h1:/P2JCyGzB2TtpJ3LocKocI1VAme2YdvVau2wpMQGt7I= github.com/casdoor/oss v1.4.1/go.mod h1:rJAWA0hLhtu94t6IRpotLUkXO1NWMASirywQYaGizJE= +github.com/casdoor/oss v1.5.0 h1:mi1htaXR5fynskDry1S3wk+Dd2nRY1z1pVcnGsqMqP4= +github.com/casdoor/oss v1.5.0/go.mod h1:rJAWA0hLhtu94t6IRpotLUkXO1NWMASirywQYaGizJE= github.com/casdoor/xorm-adapter/v3 v3.1.0 h1:NodWayRtSLVSeCvL9H3Hc61k0G17KhV9IymTCNfh3kk= github.com/casdoor/xorm-adapter/v3 v3.1.0/go.mod h1:4WTcUw+bTgBylGHeGHzTtBvuTXRS23dtwzFLl9tsgFM= github.com/casvisor/casvisor-go-sdk v1.0.3 h1:TKJQWKnhtznEBhzLPEdNsp7nJK2GgdD8JsB0lFPMW7U= diff --git a/storage/storage.go b/storage/storage.go index a0f987a0..22a2afa2 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -34,6 +34,8 @@ func GetStorageProvider(providerType string, clientId string, clientSecret strin return NewQiniuCloudKodoStorageProvider(clientId, clientSecret, region, bucket, endpoint) case "Google Cloud Storage": return NewGoogleCloudStorageProvider(clientSecret, bucket, endpoint) + case "Synology": + return NewSynologyNasStorageProvider(clientId, clientSecret, endpoint) } return nil diff --git a/storage/synology_nas.go b/storage/synology_nas.go new file mode 100644 index 00000000..234602d4 --- /dev/null +++ b/storage/synology_nas.go @@ -0,0 +1,31 @@ +// 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 storage + +import ( + "github.com/casdoor/oss" + "github.com/casdoor/oss/synology" +) + +func NewSynologyNasStorageProvider(clientId string, clientSecret string, endpoint string) oss.StorageInterface { + sp := synology.New(&synology.Config{ + AccessID: clientId, + AccessKey: clientSecret, + Endpoint: endpoint, + SharedFolder: "/home", + }) + + return sp +} diff --git a/web/src/ProviderEditPage.js b/web/src/ProviderEditPage.js index 44e11b40..fb2ff773 100644 --- a/web/src/ProviderEditPage.js +++ b/web/src/ProviderEditPage.js @@ -796,7 +796,7 @@ class ProviderEditPage extends React.Component { )} - {["Custom HTTP SMS", "Local File System", "MinIO", "Tencent Cloud COS", "Google Cloud Storage", "Qiniu Cloud Kodo"].includes(this.state.provider.type) ? null : ( + {["Custom HTTP SMS", "Local File System", "MinIO", "Tencent Cloud COS", "Google Cloud Storage", "Qiniu Cloud Kodo", "Synology"].includes(this.state.provider.type) ? null : ( {Setting.getLabel(i18next.t("provider:Endpoint (Intranet)"), i18next.t("provider:Region endpoint for Intranet"))} : @@ -832,7 +832,7 @@ class ProviderEditPage extends React.Component { )} - {["Custom HTTP SMS", "MinIO", "Google Cloud Storage", "Qiniu Cloud Kodo"].includes(this.state.provider.type) ? null : ( + {["Custom HTTP SMS", "MinIO", "Google Cloud Storage", "Qiniu Cloud Kodo", "Synology"].includes(this.state.provider.type) ? null : ( {Setting.getLabel(i18next.t("provider:Domain"), i18next.t("provider:Domain - Tooltip"))} : diff --git a/web/src/Setting.js b/web/src/Setting.js index 81275b05..bae2da12 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -207,6 +207,10 @@ export const OtherProviderInfo = { logo: `${StaticBaseUrl}/img/social_google_cloud.png`, url: "https://cloud.google.com/storage", }, + "Synology": { + logo: `${StaticBaseUrl}/img/social_synology.png`, + url: "https://www.synology.com/en-global/dsm/feature/file_sharing", + }, }, SAML: { "Aliyun IDaaS": { @@ -1024,6 +1028,7 @@ export function getProviderTypeOptions(category) { {id: "Azure Blob", name: "Azure Blob"}, {id: "Qiniu Cloud Kodo", name: "Qiniu Cloud Kodo"}, {id: "Google Cloud Storage", name: "Google Cloud Storage"}, + {id: "Synology", name: "Synology"}, ] ); } else if (category === "SAML") {