change s3_account.go package to avoid cycle dependency (#3813)

This commit is contained in:
LHHDZ
2022-10-10 21:44:29 +08:00
committed by GitHub
parent 0711870f43
commit 3550692afc
7 changed files with 41 additions and 34 deletions

View File

@@ -2,6 +2,7 @@ package s3api
import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3account"
"net/http"
"os"
"strings"
@@ -40,7 +41,7 @@ type Identity struct {
}
func (i *Identity) isAnonymous() bool {
return i.Name == AccountAnonymous.Name
return i.Name == s3account.AccountAnonymous.Name
}
type Credential struct {
@@ -132,16 +133,16 @@ func (iam *IdentityAccessManagement) loadS3ApiConfiguration(config *iam_pb.S3Api
for _, ident := range config.Identities {
t := &Identity{
Name: ident.Name,
AccountId: AccountAdmin.Id,
AccountId: s3account.AccountAdmin.Id,
Credentials: nil,
Actions: nil,
}
if ident.Name == AccountAnonymous.Name {
if ident.AccountId != "" && ident.AccountId != AccountAnonymous.Id {
if ident.Name == s3account.AccountAnonymous.Name {
if ident.AccountId != "" && ident.AccountId != s3account.AccountAnonymous.Id {
glog.Warningf("anonymous identity is associated with a non-anonymous account ID, the association is invalid")
}
t.AccountId = AccountAnonymous.Id
t.AccountId = s3account.AccountAnonymous.Id
IdentityAnonymous = t
} else {
if len(ident.AccountId) > 0 {
@@ -163,8 +164,8 @@ func (iam *IdentityAccessManagement) loadS3ApiConfiguration(config *iam_pb.S3Api
if IdentityAnonymous == nil {
IdentityAnonymous = &Identity{
Name: AccountAnonymous.Name,
AccountId: AccountAnonymous.Id,
Name: s3account.AccountAnonymous.Name,
AccountId: s3account.AccountAnonymous.Id,
}
}
iam.m.Lock()