Skip to content

Commit

Permalink
feat: add azure storage support (casdoor#735)
Browse files Browse the repository at this point in the history
* feat: add zure storage support

* Update local_file_system.go

Co-authored-by: Gucheng <[email protected]>
  • Loading branch information
leo220yuyaodog and nomeguy authored May 3, 2022
1 parent c4089ea commit 78efc9c
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 28 deletions.
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@ go 1.16

require (
github.com/RobotsAndPencils/go-saml v0.0.0-20170520135329-fb13cb52a46b
github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible // indirect
github.com/astaxie/beego v1.12.3
github.com/aws/aws-sdk-go v1.37.30
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/aws/aws-sdk-go v1.44.4
github.com/beevik/etree v1.1.0
github.com/casbin/casbin/v2 v2.30.1
github.com/casbin/xorm-adapter/v2 v2.5.1
github.com/casdoor/go-sms-sender v0.2.0
github.com/casdoor/goth v1.69.0-FIX1
github.com/casdoor/oss v1.2.0
github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f
github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df
github.com/go-ldap/ldap/v3 v3.3.0
github.com/go-pay/gopay v1.5.72
github.com/go-sql-driver/mysql v1.5.0
github.com/golang-jwt/jwt/v4 v4.2.0
github.com/google/uuid v1.2.0
github.com/jinzhu/configor v1.2.1 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/lestrrat-go/jwx v0.9.0
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/qiangmzsx/string-adapter/v2 v2.1.0
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76
github.com/robfig/cron/v3 v3.0.1
github.com/russellhaering/gosaml2 v0.6.0
github.com/russellhaering/goxmldsig v1.1.1
Expand All @@ -35,9 +32,8 @@ require (
github.com/tealeg/xlsx v1.0.5
github.com/thanhpk/randstr v1.0.4
golang.org/x/crypto v0.0.0-20220208233918-bba287dce954
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
Expand Down
68 changes: 55 additions & 13 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions storage/aliyun_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package storage

import (
"github.com/qor/oss"
"github.com/qor/oss/aliyun"
"github.com/casdoor/oss"
"github.com/casdoor/oss/aliyun"
)

func NewAliyunOssStorageProvider(clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface {
Expand Down
4 changes: 2 additions & 2 deletions storage/aws_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package storage

import (
awss3 "github.com/aws/aws-sdk-go/service/s3"
"github.com/qor/oss"
"github.com/qor/oss/s3"
"github.com/casdoor/oss"
"github.com/casdoor/oss/s3"
)

func NewAwsS3StorageProvider(clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface {
Expand Down
31 changes: 31 additions & 0 deletions storage/azure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 (
"github.com/casdoor/oss"
"github.com/casdoor/oss/azureblob"
)

func NewAzureBlobStorageProvider(clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface {
sp := azureblob.New(&azureblob.Config{
AccessId: clientId,
AccessKey: clientSecret,
Region: region,
Bucket: bucket,
Endpoint: endpoint,
})
return sp
}
2 changes: 1 addition & 1 deletion storage/local_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"path/filepath"
"strings"

"github.com/qor/oss"
"github.com/casdoor/oss"
)

var baseFolder = "files"
Expand Down
4 changes: 3 additions & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package storage

import "github.com/qor/oss"
import "github.com/casdoor/oss"

func GetStorageProvider(providerType string, clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface {
switch providerType {
Expand All @@ -26,6 +26,8 @@ func GetStorageProvider(providerType string, clientId string, clientSecret strin
return NewAliyunOssStorageProvider(clientId, clientSecret, region, bucket, endpoint)
case "Tencent Cloud COS":
return NewTencentCloudCosStorageProvider(clientId, clientSecret, region, bucket, endpoint)
case "Azure Blob":
return NewAzureBlobStorageProvider(clientId, clientSecret, region, bucket, endpoint)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions storage/tencent_cloud_cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package storage

import (
"github.com/qor/oss"
"github.com/qor/oss/tencent"
"github.com/casdoor/oss"
"github.com/casdoor/oss/tencent"
)

func NewTencentCloudCosStorageProvider(clientId string, clientSecret string, region string, bucket string, endpoint string) oss.StorageInterface {
Expand Down
5 changes: 5 additions & 0 deletions web/src/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export const OtherProviderInfo = {
logo: `${StaticBaseUrl}/img/social_tencent_cloud.jpg`,
url: "https://cloud.tencent.com/product/cos",
},
"Azure Blob": {
logo: `${StaticBaseUrl}/img/social_azure.jpg`,
url: "https://azure.microsoft.com/en-us/services/storage/blobs/"
}
},
SAML: {
"Aliyun IDaaS": {
Expand Down Expand Up @@ -576,6 +580,7 @@ export function getProviderTypeOptions(category) {
{id: 'AWS S3', name: 'AWS S3'},
{id: 'Aliyun OSS', name: 'Aliyun OSS'},
{id: 'Tencent Cloud COS', name: 'Tencent Cloud COS'},
{id: 'Azure Blob', name: 'Azure Blob'}
]
);
} else if (category === "SAML") {
Expand Down

0 comments on commit 78efc9c

Please sign in to comment.