diff --git a/storage/minio_s3.go b/storage/minio_s3.go new file mode 100644 index 00000000..8dde5858 --- /dev/null +++ b/storage/minio_s3.go @@ -0,0 +1,36 @@ +// 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 storage + +import ( + awss3 "github.com/aws/aws-sdk-go/service/s3" + "github.com/casdoor/oss" + "github.com/casdoor/oss/s3" +) + +func NewMinIOS3StorageProvider(clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface { + sp := s3.New(&s3.Config{ + AccessID: clientId, + AccessKey: clientSecret, + Region: region, + Bucket: bucket, + Endpoint: endpoint, + S3Endpoint: endpoint, + ACL: awss3.BucketCannedACLPublicRead, + S3ForcePathStyle: true, + }) + + return sp +} diff --git a/storage/storage.go b/storage/storage.go index 932b3895..b5832827 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -22,6 +22,8 @@ func GetStorageProvider(providerType string, clientId string, clientSecret strin return NewLocalFileSystemStorageProvider(clientId, clientSecret, region, bucket, endpoint) case "AWS S3": return NewAwsS3StorageProvider(clientId, clientSecret, region, bucket, endpoint) + case "MinIO": + return NewMinIOS3StorageProvider(clientId, clientSecret, region, bucket, endpoint) case "Aliyun OSS": return NewAliyunOssStorageProvider(clientId, clientSecret, region, bucket, endpoint) case "Tencent Cloud COS": diff --git a/web/src/ProviderEditPage.js b/web/src/ProviderEditPage.js index 6b6921cc..2f4ebc96 100644 --- a/web/src/ProviderEditPage.js +++ b/web/src/ProviderEditPage.js @@ -474,7 +474,7 @@ class ProviderEditPage extends React.Component { }} /> - {this.state.provider.type === "AWS S3" || this.state.provider.type === "Tencent Cloud COS" ? ( + {["AWS S3", "MinIO", "Tencent Cloud COS"].includes(this.state.provider.type) ? ( {Setting.getLabel(i18next.t("provider:Region ID"), i18next.t("provider:Region ID - Tooltip"))} : diff --git a/web/src/Setting.js b/web/src/Setting.js index a4a49caf..24a57984 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -69,6 +69,10 @@ export const OtherProviderInfo = { logo: `${StaticBaseUrl}/img/social_aws.png`, url: "https://aws.amazon.com/s3", }, + "MinIO": { + logo: "https://min.io/resources/img/logo.svg", + url: "https://min.io/", + }, "Aliyun OSS": { logo: `${StaticBaseUrl}/img/social_aliyun.png`, url: "https://aliyun.com/product/oss", @@ -612,6 +616,7 @@ export function getProviderTypeOptions(category) { [ {id: "Local File System", name: "Local File System"}, {id: "AWS S3", name: "AWS S3"}, + {id: "MinIO", name: "MinIO"}, {id: "Aliyun OSS", name: "Aliyun OSS"}, {id: "Tencent Cloud COS", name: "Tencent Cloud COS"}, {id: "Azure Blob", name: "Azure Blob"},