mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Simplify the steps to make changes to config.json (#5186)
This change introduces following simplified steps to follow during config migration. ``` // Steps to move from version N to version N+1 // 1. Add new struct serverConfigVN+1 in config-versions.go // 2. Set configCurrentVersion to "N+1" // 3. Set serverConfigCurrent to serverConfigVN+1 // 4. Add new migration function (ex. func migrateVNToVN+1()) in config-migrate.go // 5. Call migrateVNToVN+1() from migrateConfig() in config-migrate.go // 6. Make changes in config-current_test.go for any test change ```
This commit is contained in:
parent
98d07210e7
commit
14e6c5ec08
@ -183,12 +183,12 @@ func (adminAPI adminAPIHandlers) ServiceCredentialsHandler(w http.ResponseWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update local credentials in memory.
|
// Update local credentials in memory.
|
||||||
prevCred := serverConfig.SetCredential(creds)
|
prevCred := globalServerConfig.SetCredential(creds)
|
||||||
|
|
||||||
// Save credentials to config file
|
// Save credentials to config file
|
||||||
if err = serverConfig.Save(); err != nil {
|
if err = globalServerConfig.Save(); err != nil {
|
||||||
// Save the current creds when failed to update.
|
// Save the current creds when failed to update.
|
||||||
serverConfig.SetCredential(prevCred)
|
globalServerConfig.SetCredential(prevCred)
|
||||||
|
|
||||||
errorIf(err, "Unable to update the config with new credentials.")
|
errorIf(err, "Unable to update the config with new credentials.")
|
||||||
writeErrorResponse(w, ErrInternalError, r.URL)
|
writeErrorResponse(w, ErrInternalError, r.URL)
|
||||||
@ -985,7 +985,7 @@ func (adminAPI adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var config serverConfigV20
|
var config serverConfig
|
||||||
err = json.Unmarshal(configBytes, &config)
|
err = json.Unmarshal(configBytes, &config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -995,7 +995,7 @@ func (adminAPI adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
if globalIsEnvCreds {
|
if globalIsEnvCreds {
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
if config.Credential.AccessKey != creds.AccessKey ||
|
if config.Credential.AccessKey != creds.AccessKey ||
|
||||||
config.Credential.SecretKey != creds.SecretKey {
|
config.Credential.SecretKey != creds.SecretKey {
|
||||||
writeErrorResponse(w, ErrAdminCredentialsMismatch, r.URL)
|
writeErrorResponse(w, ErrAdminCredentialsMismatch, r.URL)
|
||||||
|
@ -307,7 +307,7 @@ func testServicesCmdHandler(cmd cmdType, t *testing.T) {
|
|||||||
if cmd == restartCmd {
|
if cmd == restartCmd {
|
||||||
go testServiceSignalReceiver(cmd, t)
|
go testServiceSignalReceiver(cmd, t)
|
||||||
}
|
}
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
var body []byte
|
var body []byte
|
||||||
|
|
||||||
req, err := getServiceCmdRequest(cmd, credentials, body)
|
req, err := getServiceCmdRequest(cmd, credentials, body)
|
||||||
@ -362,7 +362,7 @@ func TestServiceSetCreds(t *testing.T) {
|
|||||||
globalMinioAddr = "127.0.0.1:9000"
|
globalMinioAddr = "127.0.0.1:9000"
|
||||||
initGlobalAdminPeers(mustGetNewEndpointList("http://127.0.0.1:9000/d1"))
|
initGlobalAdminPeers(mustGetNewEndpointList("http://127.0.0.1:9000/d1"))
|
||||||
|
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
var body []byte
|
var body []byte
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -411,7 +411,7 @@ func TestServiceSetCreds(t *testing.T) {
|
|||||||
|
|
||||||
// If we got 200 OK, check if new credentials are really set
|
// If we got 200 OK, check if new credentials are really set
|
||||||
if rec.Code == http.StatusOK {
|
if rec.Code == http.StatusOK {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
if cred.AccessKey != testCase.Username {
|
if cred.AccessKey != testCase.Username {
|
||||||
t.Errorf("Test %d: Wrong access key, expected = %s, found = %s", i+1, testCase.Username, cred.AccessKey)
|
t.Errorf("Test %d: Wrong access key, expected = %s, found = %s", i+1, testCase.Username, cred.AccessKey)
|
||||||
}
|
}
|
||||||
@ -488,7 +488,7 @@ func TestListLocksHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
req.Header.Set(minioAdminOpHeader, "list")
|
req.Header.Set(minioAdminOpHeader, "list")
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d - Failed to sign list locks request - %v", i+1, err)
|
t.Fatalf("Test %d - Failed to sign list locks request - %v", i+1, err)
|
||||||
@ -556,7 +556,7 @@ func TestClearLocksHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
req.Header.Set(minioAdminOpHeader, "clear")
|
req.Header.Set(minioAdminOpHeader, "clear")
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d - Failed to sign clear locks request - %v", i+1, err)
|
t.Fatalf("Test %d - Failed to sign clear locks request - %v", i+1, err)
|
||||||
@ -841,7 +841,7 @@ func TestListObjectsHealHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
req.Header.Set(minioAdminOpHeader, "list-objects")
|
req.Header.Set(minioAdminOpHeader, "list-objects")
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d - Failed to sign list objects needing heal request - %v", i+1, err)
|
t.Fatalf("Test %d - Failed to sign list objects needing heal request - %v", i+1, err)
|
||||||
@ -912,7 +912,7 @@ func TestHealBucketHandler(t *testing.T) {
|
|||||||
|
|
||||||
req.Header.Set(minioAdminOpHeader, "bucket")
|
req.Header.Set(minioAdminOpHeader, "bucket")
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d - Failed to sign heal bucket request - %v",
|
t.Fatalf("Test %d - Failed to sign heal bucket request - %v",
|
||||||
@ -1015,7 +1015,7 @@ func TestHealObjectHandler(t *testing.T) {
|
|||||||
|
|
||||||
req.Header.Set(minioAdminOpHeader, "object")
|
req.Header.Set(minioAdminOpHeader, "object")
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d - Failed to sign heal object request - %v", i+1, err)
|
t.Fatalf("Test %d - Failed to sign heal object request - %v", i+1, err)
|
||||||
@ -1039,7 +1039,7 @@ func buildAdminRequest(queryVal url.Values, opHdr, method string,
|
|||||||
|
|
||||||
req.Header.Set(minioAdminOpHeader, opHdr)
|
req.Header.Set(minioAdminOpHeader, opHdr)
|
||||||
|
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Trace(err)
|
return nil, errors.Trace(err)
|
||||||
|
@ -139,7 +139,7 @@ func (lc localAdminClient) ServerInfoData() (sid ServerInfoData, e error) {
|
|||||||
Version: Version,
|
Version: Version,
|
||||||
CommitID: CommitID,
|
CommitID: CommitID,
|
||||||
SQSARN: arns,
|
SQSARN: arns,
|
||||||
Region: serverConfig.GetRegion(),
|
Region: globalServerConfig.GetRegion(),
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -158,11 +158,11 @@ func (rc remoteAdminClient) ServerInfoData() (sid ServerInfoData, e error) {
|
|||||||
|
|
||||||
// GetConfig - returns config.json of the local server.
|
// GetConfig - returns config.json of the local server.
|
||||||
func (lc localAdminClient) GetConfig() ([]byte, error) {
|
func (lc localAdminClient) GetConfig() ([]byte, error) {
|
||||||
if serverConfig == nil {
|
if globalServerConfig == nil {
|
||||||
return nil, fmt.Errorf("config not present")
|
return nil, fmt.Errorf("config not present")
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(serverConfig)
|
return json.Marshal(globalServerConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfig - returns config.json of the remote server.
|
// GetConfig - returns config.json of the remote server.
|
||||||
@ -246,7 +246,7 @@ func makeAdminPeers(endpoints EndpointList) (adminPeerList adminPeers) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
hostSet := set.CreateStringSet(globalMinioAddr)
|
hostSet := set.CreateStringSet(globalMinioAddr)
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
serviceEndpoint := path.Join(minioReservedBucketPath, adminPath)
|
serviceEndpoint := path.Join(minioReservedBucketPath, adminPath)
|
||||||
for _, host := range GetRemotePeers(endpoints) {
|
for _, host := range GetRemotePeers(endpoints) {
|
||||||
if hostSet.Contains(host) {
|
if hostSet.Contains(host) {
|
||||||
|
@ -148,7 +148,7 @@ func (s *adminCmd) ServerInfoData(args *AuthRPCArgs, reply *ServerInfoDataReply)
|
|||||||
Uptime: UTCNow().Sub(globalBootTime),
|
Uptime: UTCNow().Sub(globalBootTime),
|
||||||
Version: Version,
|
Version: Version,
|
||||||
CommitID: CommitID,
|
CommitID: CommitID,
|
||||||
Region: serverConfig.GetRegion(),
|
Region: globalServerConfig.GetRegion(),
|
||||||
SQSARN: arns,
|
SQSARN: arns,
|
||||||
},
|
},
|
||||||
StorageInfo: storageInfo,
|
StorageInfo: storageInfo,
|
||||||
@ -165,11 +165,11 @@ func (s *adminCmd) GetConfig(args *AuthRPCArgs, reply *ConfigReply) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if serverConfig == nil {
|
if globalServerConfig == nil {
|
||||||
return fmt.Errorf("config not present")
|
return fmt.Errorf("config not present")
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(serverConfig)
|
jsonBytes, err := json.Marshal(globalServerConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -95,7 +95,7 @@ func TestReInitDisks(t *testing.T) {
|
|||||||
globalIsXL = true
|
globalIsXL = true
|
||||||
adminServer := adminCmd{}
|
adminServer := adminCmd{}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -163,7 +163,7 @@ func TestGetConfig(t *testing.T) {
|
|||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
adminServer := adminCmd{}
|
adminServer := adminCmd{}
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -212,7 +212,7 @@ func TestWriteAndCommitConfig(t *testing.T) {
|
|||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
adminServer := adminCmd{}
|
adminServer := adminCmd{}
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -38,7 +38,7 @@ func setCommonHeaders(w http.ResponseWriter) {
|
|||||||
w.Header().Set("Server", globalServerUserAgent)
|
w.Header().Set("Server", globalServerUserAgent)
|
||||||
// Set `x-amz-bucket-region` only if region is set on the server
|
// Set `x-amz-bucket-region` only if region is set on the server
|
||||||
// by default minio uses an empty region.
|
// by default minio uses an empty region.
|
||||||
if region := serverConfig.GetRegion(); region != "" {
|
if region := globalServerConfig.GetRegion(); region != "" {
|
||||||
w.Header().Set("X-Amz-Bucket-Region", region)
|
w.Header().Set("X-Amz-Bucket-Region", region)
|
||||||
}
|
}
|
||||||
w.Header().Set("Accept-Ranges", "bytes")
|
w.Header().Set("Accept-Ranges", "bytes")
|
||||||
|
@ -304,7 +304,7 @@ func mustNewRequest(method string, urlStr string, contentLength int64, body io.R
|
|||||||
// is signed with AWS Signature V4, fails if not able to do so.
|
// is signed with AWS Signature V4, fails if not able to do so.
|
||||||
func mustNewSignedRequest(method string, urlStr string, contentLength int64, body io.ReadSeeker, t *testing.T) *http.Request {
|
func mustNewSignedRequest(method string, urlStr string, contentLength int64, body io.ReadSeeker, t *testing.T) *http.Request {
|
||||||
req := mustNewRequest(method, urlStr, contentLength, body, t)
|
req := mustNewRequest(method, urlStr, contentLength, body, t)
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
if err := signRequestV4(req, cred.AccessKey, cred.SecretKey); err != nil {
|
if err := signRequestV4(req, cred.AccessKey, cred.SecretKey); err != nil {
|
||||||
t.Fatalf("Unable to inititalized new signed http request %s", err)
|
t.Fatalf("Unable to inititalized new signed http request %s", err)
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ func mustNewSignedRequest(method string, urlStr string, contentLength int64, bod
|
|||||||
func mustNewSignedBadMD5Request(method string, urlStr string, contentLength int64, body io.ReadSeeker, t *testing.T) *http.Request {
|
func mustNewSignedBadMD5Request(method string, urlStr string, contentLength int64, body io.ReadSeeker, t *testing.T) *http.Request {
|
||||||
req := mustNewRequest(method, urlStr, contentLength, body, t)
|
req := mustNewRequest(method, urlStr, contentLength, body, t)
|
||||||
req.Header.Set("Content-Md5", "YWFhYWFhYWFhYWFhYWFhCg==")
|
req.Header.Set("Content-Md5", "YWFhYWFhYWFhYWFhYWFhCg==")
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
if err := signRequestV4(req, cred.AccessKey, cred.SecretKey); err != nil {
|
if err := signRequestV4(req, cred.AccessKey, cred.SecretKey); err != nil {
|
||||||
t.Fatalf("Unable to initialized new signed http request %s", err)
|
t.Fatalf("Unable to initialized new signed http request %s", err)
|
||||||
}
|
}
|
||||||
@ -334,7 +334,7 @@ func TestIsReqAuthenticated(t *testing.T) {
|
|||||||
t.Fatalf("unable create credential, %s", err)
|
t.Fatalf("unable create credential, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.SetCredential(creds)
|
globalServerConfig.SetCredential(creds)
|
||||||
|
|
||||||
// List of test cases for validating http request authentication.
|
// List of test cases for validating http request authentication.
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -353,7 +353,7 @@ func TestIsReqAuthenticated(t *testing.T) {
|
|||||||
|
|
||||||
// Validates all testcases.
|
// Validates all testcases.
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
if s3Error := isReqAuthenticated(testCase.req, serverConfig.GetRegion()); s3Error != testCase.s3Error {
|
if s3Error := isReqAuthenticated(testCase.req, globalServerConfig.GetRegion()); s3Error != testCase.s3Error {
|
||||||
t.Fatalf("Unexpected s3error returned wanted %d, got %d", testCase.s3Error, s3Error)
|
t.Fatalf("Unexpected s3error returned wanted %d, got %d", testCase.s3Error, s3Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func TestLogin(t *testing.T) {
|
|||||||
t.Fatalf("Failed to create test config - %v", err)
|
t.Fatalf("Failed to create test config - %v", err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -51,12 +51,12 @@ func (br *browserPeerAPIHandlers) SetAuthPeer(args SetAuthPeerArgs, reply *AuthR
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update credentials in memory
|
// Update credentials in memory
|
||||||
prevCred := serverConfig.SetCredential(args.Creds)
|
prevCred := globalServerConfig.SetCredential(args.Creds)
|
||||||
|
|
||||||
// Save credentials to config file
|
// Save credentials to config file
|
||||||
if err := serverConfig.Save(); err != nil {
|
if err := globalServerConfig.Save(); err != nil {
|
||||||
// Save the current creds when failed to update.
|
// Save the current creds when failed to update.
|
||||||
serverConfig.SetCredential(prevCred)
|
globalServerConfig.SetCredential(prevCred)
|
||||||
|
|
||||||
errorIf(err, "Unable to update the config with new credentials sent from browser RPC.")
|
errorIf(err, "Unable to update the config with new credentials sent from browser RPC.")
|
||||||
return err
|
return err
|
||||||
@ -77,7 +77,7 @@ func updateCredsOnPeers(creds auth.Credentials) map[string]error {
|
|||||||
errs := make([]error, len(peers))
|
errs := make([]error, len(peers))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
serverCred := serverConfig.GetCredential()
|
serverCred := globalServerConfig.GetCredential()
|
||||||
// Launch go routines to send request to each peer in parallel.
|
// Launch go routines to send request to each peer in parallel.
|
||||||
for ix := range peers {
|
for ix := range peers {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
@ -89,7 +89,7 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
|
|||||||
s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", globalMinioDefaultRegion)
|
s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", globalMinioDefaultRegion)
|
||||||
if s3Error == ErrInvalidRegion {
|
if s3Error == ErrInvalidRegion {
|
||||||
// Clients like boto3 send getBucketLocation() call signed with region that is configured.
|
// Clients like boto3 send getBucketLocation() call signed with region that is configured.
|
||||||
s3Error = checkRequestAuthType(r, "", "s3:GetBucketLocation", serverConfig.GetRegion())
|
s3Error = checkRequestAuthType(r, "", "s3:GetBucketLocation", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -136,7 +136,7 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
|
|||||||
// Generate response.
|
// Generate response.
|
||||||
encodedSuccessResponse := encodeResponse(LocationResponse{})
|
encodedSuccessResponse := encodeResponse(LocationResponse{})
|
||||||
// Get current region.
|
// Get current region.
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
if region != globalMinioDefaultRegion {
|
if region != globalMinioDefaultRegion {
|
||||||
encodedSuccessResponse = encodeResponse(LocationResponse{
|
encodedSuccessResponse = encodeResponse(LocationResponse{
|
||||||
Location: region,
|
Location: region,
|
||||||
@ -165,7 +165,7 @@ func (api objectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucketMultipartUploads", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucketMultipartUploads", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
|
|||||||
s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion)
|
s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion)
|
||||||
if s3Error == ErrInvalidRegion {
|
if s3Error == ErrInvalidRegion {
|
||||||
// Clients like boto3 send listBuckets() call signed with region that is configured.
|
// Clients like boto3 send listBuckets() call signed with region that is configured.
|
||||||
s3Error = checkRequestAuthType(r, "", "", serverConfig.GetRegion())
|
s3Error = checkRequestAuthType(r, "", "", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -246,7 +246,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var authError APIErrorCode
|
var authError APIErrorCode
|
||||||
if authError = checkRequestAuthType(r, bucket, "s3:DeleteObject", serverConfig.GetRegion()); authError != ErrNone {
|
if authError = checkRequestAuthType(r, bucket, "s3:DeleteObject", globalServerConfig.GetRegion()); authError != ErrNone {
|
||||||
// In the event access is denied, a 200 response should still be returned
|
// In the event access is denied, a 200 response should still be returned
|
||||||
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
|
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
|
||||||
if authError != ErrAccessDenied {
|
if authError != ErrAccessDenied {
|
||||||
@ -385,7 +385,7 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PutBucket does not have any bucket action.
|
// PutBucket does not have any bucket action.
|
||||||
s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion())
|
s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
@ -649,7 +649,7 @@ func (api objectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:ListBucket", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponseHeadersOnly(w, s3Error)
|
writeErrorResponseHeadersOnly(w, s3Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBucket does not have any bucket action.
|
// DeleteBucket does not have any bucket action.
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -209,5 +209,5 @@ type arnSQS struct {
|
|||||||
|
|
||||||
// Stringer for constructing AWS ARN compatible string.
|
// Stringer for constructing AWS ARN compatible string.
|
||||||
func (m arnSQS) String() string {
|
func (m arnSQS) String() string {
|
||||||
return minioSqs + serverConfig.GetRegion() + ":" + m.AccountID + ":" + m.Type
|
return minioSqs + globalServerConfig.GetRegion() + ":" + m.AccountID + ":" + m.Type
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (api objectAPIHandlers) GetBucketNotificationHandler(w http.ResponseWriter,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ func (api objectAPIHandlers) PutBucketNotificationHandler(w http.ResponseWriter,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ func (api objectAPIHandlers) ListenBucketNotificationHandler(w http.ResponseWrit
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ func (api objectAPIHandlers) ListenBucketNotificationHandler(w http.ResponseWrit
|
|||||||
accountARN := fmt.Sprintf(
|
accountARN := fmt.Sprintf(
|
||||||
"%s:%s:%s:%s-%s",
|
"%s:%s:%s:%s-%s",
|
||||||
minioTopic,
|
minioTopic,
|
||||||
serverConfig.GetRegion(),
|
globalServerConfig.GetRegion(),
|
||||||
accountID,
|
accountID,
|
||||||
snsTypeMinio,
|
snsTypeMinio,
|
||||||
targetServer,
|
targetServer,
|
||||||
|
@ -120,7 +120,7 @@ func checkARN(arn, arnType string) APIErrorCode {
|
|||||||
// Server region is allowed to be empty by default,
|
// Server region is allowed to be empty by default,
|
||||||
// in such a scenario ARN region is not validating
|
// in such a scenario ARN region is not validating
|
||||||
// allowing all regions.
|
// allowing all regions.
|
||||||
if sregion := serverConfig.GetRegion(); sregion != "" {
|
if sregion := globalServerConfig.GetRegion(); sregion != "" {
|
||||||
region := strs[3]
|
region := strs[3]
|
||||||
if region != sregion {
|
if region != sregion {
|
||||||
return ErrRegionNotification
|
return ErrRegionNotification
|
||||||
@ -146,34 +146,34 @@ func isValidQueueID(queueARN string) bool {
|
|||||||
// Is Queue identifier valid?.
|
// Is Queue identifier valid?.
|
||||||
|
|
||||||
if isAMQPQueue(sqsARN) { // AMQP eueue.
|
if isAMQPQueue(sqsARN) { // AMQP eueue.
|
||||||
amqpN := serverConfig.Notify.GetAMQPByID(sqsARN.AccountID)
|
amqpN := globalServerConfig.Notify.GetAMQPByID(sqsARN.AccountID)
|
||||||
return amqpN.Enable && amqpN.URL != ""
|
return amqpN.Enable && amqpN.URL != ""
|
||||||
} else if isMQTTQueue(sqsARN) {
|
} else if isMQTTQueue(sqsARN) {
|
||||||
mqttN := serverConfig.Notify.GetMQTTByID(sqsARN.AccountID)
|
mqttN := globalServerConfig.Notify.GetMQTTByID(sqsARN.AccountID)
|
||||||
return mqttN.Enable && mqttN.Broker != ""
|
return mqttN.Enable && mqttN.Broker != ""
|
||||||
} else if isNATSQueue(sqsARN) {
|
} else if isNATSQueue(sqsARN) {
|
||||||
natsN := serverConfig.Notify.GetNATSByID(sqsARN.AccountID)
|
natsN := globalServerConfig.Notify.GetNATSByID(sqsARN.AccountID)
|
||||||
return natsN.Enable && natsN.Address != ""
|
return natsN.Enable && natsN.Address != ""
|
||||||
} else if isElasticQueue(sqsARN) { // Elastic queue.
|
} else if isElasticQueue(sqsARN) { // Elastic queue.
|
||||||
elasticN := serverConfig.Notify.GetElasticSearchByID(sqsARN.AccountID)
|
elasticN := globalServerConfig.Notify.GetElasticSearchByID(sqsARN.AccountID)
|
||||||
return elasticN.Enable && elasticN.URL != ""
|
return elasticN.Enable && elasticN.URL != ""
|
||||||
} else if isRedisQueue(sqsARN) { // Redis queue.
|
} else if isRedisQueue(sqsARN) { // Redis queue.
|
||||||
redisN := serverConfig.Notify.GetRedisByID(sqsARN.AccountID)
|
redisN := globalServerConfig.Notify.GetRedisByID(sqsARN.AccountID)
|
||||||
return redisN.Enable && redisN.Addr != ""
|
return redisN.Enable && redisN.Addr != ""
|
||||||
} else if isPostgreSQLQueue(sqsARN) {
|
} else if isPostgreSQLQueue(sqsARN) {
|
||||||
pgN := serverConfig.Notify.GetPostgreSQLByID(sqsARN.AccountID)
|
pgN := globalServerConfig.Notify.GetPostgreSQLByID(sqsARN.AccountID)
|
||||||
// Postgres can work with only default conn. info.
|
// Postgres can work with only default conn. info.
|
||||||
return pgN.Enable
|
return pgN.Enable
|
||||||
} else if isMySQLQueue(sqsARN) {
|
} else if isMySQLQueue(sqsARN) {
|
||||||
msqlN := serverConfig.Notify.GetMySQLByID(sqsARN.AccountID)
|
msqlN := globalServerConfig.Notify.GetMySQLByID(sqsARN.AccountID)
|
||||||
// Mysql can work with only default conn. info.
|
// Mysql can work with only default conn. info.
|
||||||
return msqlN.Enable
|
return msqlN.Enable
|
||||||
} else if isKafkaQueue(sqsARN) {
|
} else if isKafkaQueue(sqsARN) {
|
||||||
kafkaN := serverConfig.Notify.GetKafkaByID(sqsARN.AccountID)
|
kafkaN := globalServerConfig.Notify.GetKafkaByID(sqsARN.AccountID)
|
||||||
return (kafkaN.Enable && len(kafkaN.Brokers) > 0 &&
|
return (kafkaN.Enable && len(kafkaN.Brokers) > 0 &&
|
||||||
kafkaN.Topic != "")
|
kafkaN.Topic != "")
|
||||||
} else if isWebhookQueue(sqsARN) {
|
} else if isWebhookQueue(sqsARN) {
|
||||||
webhookN := serverConfig.Notify.GetWebhookByID(sqsARN.AccountID)
|
webhookN := globalServerConfig.Notify.GetWebhookByID(sqsARN.AccountID)
|
||||||
return webhookN.Enable && webhookN.Endpoint != ""
|
return webhookN.Enable && webhookN.Endpoint != ""
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -281,7 +281,7 @@ func unmarshalSqsARN(queueARN string) (mSqs arnSQS) {
|
|||||||
// Server region is allowed to be empty by default,
|
// Server region is allowed to be empty by default,
|
||||||
// in such a scenario ARN region is not validating
|
// in such a scenario ARN region is not validating
|
||||||
// allowing all regions.
|
// allowing all regions.
|
||||||
if sregion := serverConfig.GetRegion(); sregion != "" {
|
if sregion := globalServerConfig.GetRegion(); sregion != "" {
|
||||||
region := strs[3]
|
region := strs[3]
|
||||||
if region != sregion {
|
if region != sregion {
|
||||||
return
|
return
|
||||||
|
@ -225,7 +225,7 @@ func (api objectAPIHandlers) PutBucketPolicyHandler(w http.ResponseWriter, r *ht
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ func (api objectAPIHandlers) DeleteBucketPolicyHandler(w http.ResponseWriter, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -325,7 +325,7 @@ func (api objectAPIHandlers) GetBucketPolicyHandler(w http.ResponseWriter, r *ht
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ func checkUpdate(mode string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func enableLoggers() {
|
func enableLoggers() {
|
||||||
fileLogTarget := serverConfig.Logger.GetFile()
|
fileLogTarget := globalServerConfig.Logger.GetFile()
|
||||||
if fileLogTarget.Enable {
|
if fileLogTarget.Enable {
|
||||||
err := InitFileLogger(&fileLogTarget)
|
err := InitFileLogger(&fileLogTarget)
|
||||||
fatalIf(err, "Unable to initialize file logger")
|
fatalIf(err, "Unable to initialize file logger")
|
||||||
log.AddTarget(fileLogTarget)
|
log.AddTarget(fileLogTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleLogTarget := serverConfig.Logger.GetConsole()
|
consoleLogTarget := globalServerConfig.Logger.GetConsole()
|
||||||
if consoleLogTarget.Enable {
|
if consoleLogTarget.Enable {
|
||||||
InitConsoleLogger(&consoleLogTarget)
|
InitConsoleLogger(&consoleLogTarget)
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func initConfig() {
|
|||||||
// Config file does not exist, we create it fresh and return upon success.
|
// Config file does not exist, we create it fresh and return upon success.
|
||||||
if isFile(getConfigFile()) {
|
if isFile(getConfigFile()) {
|
||||||
fatalIf(migrateConfig(), "Config migration failed.")
|
fatalIf(migrateConfig(), "Config migration failed.")
|
||||||
fatalIf(loadConfig(), "Unable to load config version: '%s'.", v20)
|
fatalIf(loadConfig(), "Unable to load config version: '%s'.", serverConfigVersion)
|
||||||
} else {
|
} else {
|
||||||
fatalIf(newConfig(), "Unable to initialize minio config for the first time.")
|
fatalIf(newConfig(), "Unable to initialize minio config for the first time.")
|
||||||
log.Println("Created minio configuration file successfully at " + getConfigDir())
|
log.Println("Created minio configuration file successfully at " + getConfigDir())
|
||||||
|
@ -27,36 +27,27 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Steps to move from version N to version N+1
|
||||||
|
// 1. Add new struct serverConfigVN+1 in config-versions.go
|
||||||
|
// 2. Set configCurrentVersion to "N+1"
|
||||||
|
// 3. Set serverConfigCurrent to serverConfigVN+1
|
||||||
|
// 4. Add new migration function (ex. func migrateVNToVN+1()) in config-migrate.go
|
||||||
|
// 5. Call migrateVNToVN+1() from migrateConfig() in config-migrate.go
|
||||||
|
// 6. Make changes in config-current_test.go for any test change
|
||||||
|
|
||||||
// Config version
|
// Config version
|
||||||
const v20 = "20"
|
const serverConfigVersion = "20"
|
||||||
|
|
||||||
|
type serverConfig = serverConfigV20
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// serverConfig server config.
|
// globalServerConfig server config.
|
||||||
serverConfig *serverConfigV20
|
globalServerConfig *serverConfig
|
||||||
serverConfigMu sync.RWMutex
|
globalServerConfigMu sync.RWMutex
|
||||||
)
|
)
|
||||||
|
|
||||||
// serverConfigV20 server configuration version '20' which is like
|
|
||||||
// version '19' except it adds support for VirtualHostDomain
|
|
||||||
type serverConfigV20 struct {
|
|
||||||
sync.RWMutex
|
|
||||||
Version string `json:"version"`
|
|
||||||
|
|
||||||
// S3 API configuration.
|
|
||||||
Credential auth.Credentials `json:"credential"`
|
|
||||||
Region string `json:"region"`
|
|
||||||
Browser BrowserFlag `json:"browser"`
|
|
||||||
Domain string `json:"domain"`
|
|
||||||
|
|
||||||
// Additional error logging configuration.
|
|
||||||
Logger *loggers `json:"logger"`
|
|
||||||
|
|
||||||
// Notification queue configuration.
|
|
||||||
Notify *notifier `json:"notify"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetVersion get current config version.
|
// GetVersion get current config version.
|
||||||
func (s *serverConfigV20) GetVersion() string {
|
func (s *serverConfig) GetVersion() string {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
@ -64,7 +55,7 @@ func (s *serverConfigV20) GetVersion() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetRegion set a new region.
|
// SetRegion set a new region.
|
||||||
func (s *serverConfigV20) SetRegion(region string) {
|
func (s *serverConfig) SetRegion(region string) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
@ -73,7 +64,7 @@ func (s *serverConfigV20) SetRegion(region string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetRegion get current region.
|
// GetRegion get current region.
|
||||||
func (s *serverConfigV20) GetRegion() string {
|
func (s *serverConfig) GetRegion() string {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
@ -81,7 +72,7 @@ func (s *serverConfigV20) GetRegion() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetCredentials set new credentials. SetCredential returns the previous credential.
|
// SetCredentials set new credentials. SetCredential returns the previous credential.
|
||||||
func (s *serverConfigV20) SetCredential(creds auth.Credentials) (prevCred auth.Credentials) {
|
func (s *serverConfig) SetCredential(creds auth.Credentials) (prevCred auth.Credentials) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
@ -96,7 +87,7 @@ func (s *serverConfigV20) SetCredential(creds auth.Credentials) (prevCred auth.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetCredentials get current credentials.
|
// GetCredentials get current credentials.
|
||||||
func (s *serverConfigV20) GetCredential() auth.Credentials {
|
func (s *serverConfig) GetCredential() auth.Credentials {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
@ -104,7 +95,7 @@ func (s *serverConfigV20) GetCredential() auth.Credentials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetBrowser set if browser is enabled.
|
// SetBrowser set if browser is enabled.
|
||||||
func (s *serverConfigV20) SetBrowser(b bool) {
|
func (s *serverConfig) SetBrowser(b bool) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
@ -113,7 +104,7 @@ func (s *serverConfigV20) SetBrowser(b bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetCredentials get current credentials.
|
// GetCredentials get current credentials.
|
||||||
func (s *serverConfigV20) GetBrowser() bool {
|
func (s *serverConfig) GetBrowser() bool {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
@ -121,7 +112,7 @@ func (s *serverConfigV20) GetBrowser() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save config.
|
// Save config.
|
||||||
func (s *serverConfigV20) Save() error {
|
func (s *serverConfig) Save() error {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
@ -129,9 +120,9 @@ func (s *serverConfigV20) Save() error {
|
|||||||
return quick.Save(getConfigFile(), s)
|
return quick.Save(getConfigFile(), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newServerConfigV20() *serverConfigV20 {
|
func newServerConfig() *serverConfig {
|
||||||
srvCfg := &serverConfigV20{
|
srvCfg := &serverConfig{
|
||||||
Version: v20,
|
Version: serverConfigVersion,
|
||||||
Credential: auth.MustGetNewCredentials(),
|
Credential: auth.MustGetNewCredentials(),
|
||||||
Region: globalMinioDefaultRegion,
|
Region: globalMinioDefaultRegion,
|
||||||
Browser: true,
|
Browser: true,
|
||||||
@ -169,7 +160,7 @@ func newServerConfigV20() *serverConfigV20 {
|
|||||||
// found, otherwise use default parameters
|
// found, otherwise use default parameters
|
||||||
func newConfig() error {
|
func newConfig() error {
|
||||||
// Initialize server config.
|
// Initialize server config.
|
||||||
srvCfg := newServerConfigV20()
|
srvCfg := newServerConfig()
|
||||||
|
|
||||||
// If env is set override the credentials from config file.
|
// If env is set override the credentials from config file.
|
||||||
if globalIsEnvCreds {
|
if globalIsEnvCreds {
|
||||||
@ -191,12 +182,12 @@ func newConfig() error {
|
|||||||
// hold the mutex lock before a new config is assigned.
|
// hold the mutex lock before a new config is assigned.
|
||||||
// Save the new config globally.
|
// Save the new config globally.
|
||||||
// unlock the mutex.
|
// unlock the mutex.
|
||||||
serverConfigMu.Lock()
|
globalServerConfigMu.Lock()
|
||||||
serverConfig = srvCfg
|
globalServerConfig = srvCfg
|
||||||
serverConfigMu.Unlock()
|
globalServerConfigMu.Unlock()
|
||||||
|
|
||||||
// Save config into file.
|
// Save config into file.
|
||||||
return serverConfig.Save()
|
return globalServerConfig.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
// doCheckDupJSONKeys recursively detects duplicate json keys
|
// doCheckDupJSONKeys recursively detects duplicate json keys
|
||||||
@ -251,8 +242,8 @@ func checkDupJSONKeys(json string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getValidConfig - returns valid server configuration
|
// getValidConfig - returns valid server configuration
|
||||||
func getValidConfig() (*serverConfigV20, error) {
|
func getValidConfig() (*serverConfig, error) {
|
||||||
srvCfg := &serverConfigV20{
|
srvCfg := &serverConfig{
|
||||||
Region: globalMinioDefaultRegion,
|
Region: globalMinioDefaultRegion,
|
||||||
Browser: true,
|
Browser: true,
|
||||||
}
|
}
|
||||||
@ -262,8 +253,8 @@ func getValidConfig() (*serverConfigV20, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if srvCfg.Version != v20 {
|
if srvCfg.Version != serverConfigVersion {
|
||||||
return nil, fmt.Errorf("configuration version mismatch. Expected: ‘%s’, Got: ‘%s’", v20, srvCfg.Version)
|
return nil, fmt.Errorf("configuration version mismatch. Expected: ‘%s’, Got: ‘%s’", serverConfigVersion, srvCfg.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config file json and check for duplication json keys
|
// Load config file json and check for duplication json keys
|
||||||
@ -322,21 +313,21 @@ func loadConfig() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hold the mutex lock before a new config is assigned.
|
// hold the mutex lock before a new config is assigned.
|
||||||
serverConfigMu.Lock()
|
globalServerConfigMu.Lock()
|
||||||
serverConfig = srvCfg
|
globalServerConfig = srvCfg
|
||||||
if !globalIsEnvCreds {
|
if !globalIsEnvCreds {
|
||||||
globalActiveCred = serverConfig.GetCredential()
|
globalActiveCred = globalServerConfig.GetCredential()
|
||||||
}
|
}
|
||||||
if !globalIsEnvBrowser {
|
if !globalIsEnvBrowser {
|
||||||
globalIsBrowserEnabled = serverConfig.GetBrowser()
|
globalIsBrowserEnabled = globalServerConfig.GetBrowser()
|
||||||
}
|
}
|
||||||
if !globalIsEnvRegion {
|
if !globalIsEnvRegion {
|
||||||
globalServerRegion = serverConfig.GetRegion()
|
globalServerRegion = globalServerConfig.GetRegion()
|
||||||
}
|
}
|
||||||
if !globalIsEnvDomainName {
|
if !globalIsEnvDomainName {
|
||||||
globalDomainName = serverConfig.Domain
|
globalDomainName = globalServerConfig.Domain
|
||||||
}
|
}
|
||||||
serverConfigMu.Unlock()
|
globalServerConfigMu.Unlock()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@ -34,95 +34,95 @@ func TestServerConfig(t *testing.T) {
|
|||||||
// remove the root directory after the test ends.
|
// remove the root directory after the test ends.
|
||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
if serverConfig.GetRegion() != globalMinioDefaultRegion {
|
if globalServerConfig.GetRegion() != globalMinioDefaultRegion {
|
||||||
t.Errorf("Expecting region `us-east-1` found %s", serverConfig.GetRegion())
|
t.Errorf("Expecting region `us-east-1` found %s", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new region and verify.
|
// Set new region and verify.
|
||||||
serverConfig.SetRegion("us-west-1")
|
globalServerConfig.SetRegion("us-west-1")
|
||||||
if serverConfig.GetRegion() != "us-west-1" {
|
if globalServerConfig.GetRegion() != "us-west-1" {
|
||||||
t.Errorf("Expecting region `us-west-1` found %s", serverConfig.GetRegion())
|
t.Errorf("Expecting region `us-west-1` found %s", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new amqp notification id.
|
// Set new amqp notification id.
|
||||||
serverConfig.Notify.SetAMQPByID("2", amqpNotify{})
|
globalServerConfig.Notify.SetAMQPByID("2", amqpNotify{})
|
||||||
savedNotifyCfg1 := serverConfig.Notify.GetAMQPByID("2")
|
savedNotifyCfg1 := globalServerConfig.Notify.GetAMQPByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg1, amqpNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg1, amqpNotify{}) {
|
||||||
t.Errorf("Expecting AMQP config %#v found %#v", amqpNotify{}, savedNotifyCfg1)
|
t.Errorf("Expecting AMQP config %#v found %#v", amqpNotify{}, savedNotifyCfg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new elastic search notification id.
|
// Set new elastic search notification id.
|
||||||
serverConfig.Notify.SetElasticSearchByID("2", elasticSearchNotify{})
|
globalServerConfig.Notify.SetElasticSearchByID("2", elasticSearchNotify{})
|
||||||
savedNotifyCfg2 := serverConfig.Notify.GetElasticSearchByID("2")
|
savedNotifyCfg2 := globalServerConfig.Notify.GetElasticSearchByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg2, elasticSearchNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg2, elasticSearchNotify{}) {
|
||||||
t.Errorf("Expecting Elasticsearch config %#v found %#v", elasticSearchNotify{}, savedNotifyCfg2)
|
t.Errorf("Expecting Elasticsearch config %#v found %#v", elasticSearchNotify{}, savedNotifyCfg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new redis notification id.
|
// Set new redis notification id.
|
||||||
serverConfig.Notify.SetRedisByID("2", redisNotify{})
|
globalServerConfig.Notify.SetRedisByID("2", redisNotify{})
|
||||||
savedNotifyCfg3 := serverConfig.Notify.GetRedisByID("2")
|
savedNotifyCfg3 := globalServerConfig.Notify.GetRedisByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg3, redisNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg3, redisNotify{}) {
|
||||||
t.Errorf("Expecting Redis config %#v found %#v", redisNotify{}, savedNotifyCfg3)
|
t.Errorf("Expecting Redis config %#v found %#v", redisNotify{}, savedNotifyCfg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new kafka notification id.
|
// Set new kafka notification id.
|
||||||
serverConfig.Notify.SetKafkaByID("2", kafkaNotify{})
|
globalServerConfig.Notify.SetKafkaByID("2", kafkaNotify{})
|
||||||
savedNotifyCfg4 := serverConfig.Notify.GetKafkaByID("2")
|
savedNotifyCfg4 := globalServerConfig.Notify.GetKafkaByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg4, kafkaNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg4, kafkaNotify{}) {
|
||||||
t.Errorf("Expecting Kafka config %#v found %#v", kafkaNotify{}, savedNotifyCfg4)
|
t.Errorf("Expecting Kafka config %#v found %#v", kafkaNotify{}, savedNotifyCfg4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new Webhook notification id.
|
// Set new Webhook notification id.
|
||||||
serverConfig.Notify.SetWebhookByID("2", webhookNotify{})
|
globalServerConfig.Notify.SetWebhookByID("2", webhookNotify{})
|
||||||
savedNotifyCfg5 := serverConfig.Notify.GetWebhookByID("2")
|
savedNotifyCfg5 := globalServerConfig.Notify.GetWebhookByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg5, webhookNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg5, webhookNotify{}) {
|
||||||
t.Errorf("Expecting Webhook config %#v found %#v", webhookNotify{}, savedNotifyCfg5)
|
t.Errorf("Expecting Webhook config %#v found %#v", webhookNotify{}, savedNotifyCfg5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new console logger.
|
// Set new console logger.
|
||||||
// Set new MySQL notification id.
|
// Set new MySQL notification id.
|
||||||
serverConfig.Notify.SetMySQLByID("2", mySQLNotify{})
|
globalServerConfig.Notify.SetMySQLByID("2", mySQLNotify{})
|
||||||
savedNotifyCfg6 := serverConfig.Notify.GetMySQLByID("2")
|
savedNotifyCfg6 := globalServerConfig.Notify.GetMySQLByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg6, mySQLNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg6, mySQLNotify{}) {
|
||||||
t.Errorf("Expecting Webhook config %#v found %#v", mySQLNotify{}, savedNotifyCfg6)
|
t.Errorf("Expecting Webhook config %#v found %#v", mySQLNotify{}, savedNotifyCfg6)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new console logger.
|
// Set new console logger.
|
||||||
// Set new MQTT notification id.
|
// Set new MQTT notification id.
|
||||||
serverConfig.Notify.SetMQTTByID("2", mqttNotify{})
|
globalServerConfig.Notify.SetMQTTByID("2", mqttNotify{})
|
||||||
savedNotifyCfg7 := serverConfig.Notify.GetMQTTByID("2")
|
savedNotifyCfg7 := globalServerConfig.Notify.GetMQTTByID("2")
|
||||||
if !reflect.DeepEqual(savedNotifyCfg7, mqttNotify{}) {
|
if !reflect.DeepEqual(savedNotifyCfg7, mqttNotify{}) {
|
||||||
t.Errorf("Expecting Webhook config %#v found %#v", mqttNotify{}, savedNotifyCfg7)
|
t.Errorf("Expecting Webhook config %#v found %#v", mqttNotify{}, savedNotifyCfg7)
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleLogger := NewConsoleLogger()
|
consoleLogger := NewConsoleLogger()
|
||||||
serverConfig.Logger.SetConsole(consoleLogger)
|
globalServerConfig.Logger.SetConsole(consoleLogger)
|
||||||
consoleCfg := serverConfig.Logger.GetConsole()
|
consoleCfg := globalServerConfig.Logger.GetConsole()
|
||||||
if !reflect.DeepEqual(consoleCfg, consoleLogger) {
|
if !reflect.DeepEqual(consoleCfg, consoleLogger) {
|
||||||
t.Errorf("Expecting console logger config %#v found %#v", consoleLogger, consoleCfg)
|
t.Errorf("Expecting console logger config %#v found %#v", consoleLogger, consoleCfg)
|
||||||
}
|
}
|
||||||
// Set new console logger.
|
// Set new console logger.
|
||||||
consoleLogger.Enable = false
|
consoleLogger.Enable = false
|
||||||
serverConfig.Logger.SetConsole(consoleLogger)
|
globalServerConfig.Logger.SetConsole(consoleLogger)
|
||||||
|
|
||||||
// Set new file logger.
|
// Set new file logger.
|
||||||
fileLogger := NewFileLogger("test-log-file")
|
fileLogger := NewFileLogger("test-log-file")
|
||||||
serverConfig.Logger.SetFile(fileLogger)
|
globalServerConfig.Logger.SetFile(fileLogger)
|
||||||
fileCfg := serverConfig.Logger.GetFile()
|
fileCfg := globalServerConfig.Logger.GetFile()
|
||||||
if !reflect.DeepEqual(fileCfg, fileLogger) {
|
if !reflect.DeepEqual(fileCfg, fileLogger) {
|
||||||
t.Errorf("Expecting file logger config %#v found %#v", fileLogger, fileCfg)
|
t.Errorf("Expecting file logger config %#v found %#v", fileLogger, fileCfg)
|
||||||
}
|
}
|
||||||
// Set new file logger.
|
// Set new file logger.
|
||||||
fileLogger.Enable = false
|
fileLogger.Enable = false
|
||||||
serverConfig.Logger.SetFile(fileLogger)
|
globalServerConfig.Logger.SetFile(fileLogger)
|
||||||
|
|
||||||
// Match version.
|
// Match version.
|
||||||
if serverConfig.GetVersion() != v20 {
|
if globalServerConfig.GetVersion() != serverConfigVersion {
|
||||||
t.Errorf("Expecting version %s found %s", serverConfig.GetVersion(), v20)
|
t.Errorf("Expecting version %s found %s", globalServerConfig.GetVersion(), serverConfigVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to save.
|
// Attempt to save.
|
||||||
if err := serverConfig.Save(); err != nil {
|
if err := globalServerConfig.Save(); err != nil {
|
||||||
t.Fatalf("Unable to save updated config file %s", err)
|
t.Fatalf("Unable to save updated config file %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,17 +172,17 @@ func TestServerConfigWithEnvs(t *testing.T) {
|
|||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig has
|
||||||
if serverConfig.GetBrowser() {
|
if globalServerConfig.GetBrowser() {
|
||||||
t.Errorf("Expecting browser is set to false found %v", serverConfig.GetBrowser())
|
t.Errorf("Expecting browser is set to false found %v", globalServerConfig.GetBrowser())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig has
|
||||||
if serverConfig.GetRegion() != "us-west-1" {
|
if globalServerConfig.GetRegion() != "us-west-1" {
|
||||||
t.Errorf("Expecting region to be \"us-west-1\" found %v", serverConfig.GetRegion())
|
t.Errorf("Expecting region to be \"us-west-1\" found %v", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig has
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
if cred.AccessKey != "minio" {
|
if cred.AccessKey != "minio" {
|
||||||
t.Errorf("Expecting access key to be `minio` found %s", cred.AccessKey)
|
t.Errorf("Expecting access key to be `minio` found %s", cred.AccessKey)
|
||||||
@ -192,8 +192,8 @@ func TestServerConfigWithEnvs(t *testing.T) {
|
|||||||
t.Errorf("Expecting access key to be `minio123` found %s", cred.SecretKey)
|
t.Errorf("Expecting access key to be `minio123` found %s", cred.SecretKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if serverConfig.Domain != "domain.com" {
|
if globalServerConfig.Domain != "domain.com" {
|
||||||
t.Errorf("Expecting Domain to be `domain.com` found " + serverConfig.Domain)
|
t.Errorf("Expecting Domain to be `domain.com` found " + globalServerConfig.Domain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ func TestValidateConfig(t *testing.T) {
|
|||||||
|
|
||||||
configPath := filepath.Join(rootPath, minioConfigFile)
|
configPath := filepath.Join(rootPath, minioConfigFile)
|
||||||
|
|
||||||
v := v20
|
v := serverConfigVersion
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
configData string
|
configData string
|
@ -1500,7 +1500,7 @@ func migrateV19ToV20() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy over fields from V19 into V20 config struct
|
// Copy over fields from V19 into V20 config struct
|
||||||
srvConfig := &serverConfigV20{
|
srvConfig := &serverConfig{
|
||||||
Logger: &loggers{},
|
Logger: &loggers{},
|
||||||
Notify: ¬ifier{},
|
Notify: ¬ifier{},
|
||||||
}
|
}
|
||||||
|
@ -169,17 +169,17 @@ func TestServerConfigMigrateV2toV19(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the version number in the upgraded config file
|
// Check the version number in the upgraded config file
|
||||||
expectedVersion := v20
|
expectedVersion := serverConfigVersion
|
||||||
if serverConfig.Version != expectedVersion {
|
if globalServerConfig.Version != expectedVersion {
|
||||||
t.Fatalf("Expect version "+expectedVersion+", found: %v", serverConfig.Version)
|
t.Fatalf("Expect version "+expectedVersion+", found: %v", globalServerConfig.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if accessKey and secretKey are not altered during migration
|
// Check if accessKey and secretKey are not altered during migration
|
||||||
if serverConfig.Credential.AccessKey != accessKey {
|
if globalServerConfig.Credential.AccessKey != accessKey {
|
||||||
t.Fatalf("Access key lost during migration, expected: %v, found:%v", accessKey, serverConfig.Credential.AccessKey)
|
t.Fatalf("Access key lost during migration, expected: %v, found:%v", accessKey, globalServerConfig.Credential.AccessKey)
|
||||||
}
|
}
|
||||||
if serverConfig.Credential.SecretKey != secretKey {
|
if globalServerConfig.Credential.SecretKey != secretKey {
|
||||||
t.Fatalf("Secret key lost during migration, expected: %v, found: %v", secretKey, serverConfig.Credential.SecretKey)
|
t.Fatalf("Secret key lost during migration, expected: %v, found: %v", secretKey, globalServerConfig.Credential.SecretKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,3 +490,22 @@ type serverConfigV19 struct {
|
|||||||
// Notification queue configuration.
|
// Notification queue configuration.
|
||||||
Notify *notifier `json:"notify"`
|
Notify *notifier `json:"notify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// serverConfigV20 server configuration version '20' which is like
|
||||||
|
// version '19' except it adds support for VirtualHostDomain
|
||||||
|
type serverConfigV20 struct {
|
||||||
|
sync.RWMutex
|
||||||
|
Version string `json:"version"`
|
||||||
|
|
||||||
|
// S3 API configuration.
|
||||||
|
Credential auth.Credentials `json:"credential"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
Browser BrowserFlag `json:"browser"`
|
||||||
|
Domain string `json:"domain"`
|
||||||
|
|
||||||
|
// Additional error logging configuration.
|
||||||
|
Logger *loggers `json:"logger"`
|
||||||
|
|
||||||
|
// Notification queue configuration.
|
||||||
|
Notify *notifier `json:"notify"`
|
||||||
|
}
|
@ -107,10 +107,10 @@ func newNotificationEvent(event eventData) NotificationEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the region.
|
// Fetch the region.
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
// Fetch the credentials.
|
// Fetch the credentials.
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Time when Minio finished processing the request.
|
// Time when Minio finished processing the request.
|
||||||
eventTime := UTCNow()
|
eventTime := UTCNow()
|
||||||
@ -596,7 +596,7 @@ func addQueueTarget(queueTargets map[string]*logrus.Logger,
|
|||||||
newTargetFunc func(string) (*logrus.Logger, error)) (string, error) {
|
newTargetFunc func(string) (*logrus.Logger, error)) (string, error) {
|
||||||
|
|
||||||
// Construct the queue ARN for AMQP.
|
// Construct the queue ARN for AMQP.
|
||||||
queueARN := minioSqs + serverConfig.GetRegion() + ":" + accountID + ":" + queueType
|
queueARN := minioSqs + globalServerConfig.GetRegion() + ":" + accountID + ":" + queueType
|
||||||
|
|
||||||
// Queue target if already initialized we move to the next ARN.
|
// Queue target if already initialized we move to the next ARN.
|
||||||
if _, ok := queueTargets[queueARN]; ok {
|
if _, ok := queueTargets[queueARN]; ok {
|
||||||
@ -619,7 +619,7 @@ func addQueueTarget(queueTargets map[string]*logrus.Logger,
|
|||||||
func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
||||||
queueTargets := make(map[string]*logrus.Logger)
|
queueTargets := make(map[string]*logrus.Logger)
|
||||||
// Load all amqp targets, initialize their respective loggers.
|
// Load all amqp targets, initialize their respective loggers.
|
||||||
for accountID, amqpN := range serverConfig.Notify.GetAMQP() {
|
for accountID, amqpN := range globalServerConfig.Notify.GetAMQP() {
|
||||||
if !amqpN.Enable {
|
if !amqpN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -638,7 +638,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load all mqtt targets, initialize their respective loggers.
|
// Load all mqtt targets, initialize their respective loggers.
|
||||||
for accountID, mqttN := range serverConfig.Notify.GetMQTT() {
|
for accountID, mqttN := range globalServerConfig.Notify.GetMQTT() {
|
||||||
if !mqttN.Enable {
|
if !mqttN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load all nats targets, initialize their respective loggers.
|
// Load all nats targets, initialize their respective loggers.
|
||||||
for accountID, natsN := range serverConfig.Notify.GetNATS() {
|
for accountID, natsN := range globalServerConfig.Notify.GetNATS() {
|
||||||
if !natsN.Enable {
|
if !natsN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -676,7 +676,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load redis targets, initialize their respective loggers.
|
// Load redis targets, initialize their respective loggers.
|
||||||
for accountID, redisN := range serverConfig.Notify.GetRedis() {
|
for accountID, redisN := range globalServerConfig.Notify.GetRedis() {
|
||||||
if !redisN.Enable {
|
if !redisN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -695,7 +695,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load Webhook targets, initialize their respective loggers.
|
// Load Webhook targets, initialize their respective loggers.
|
||||||
for accountID, webhookN := range serverConfig.Notify.GetWebhook() {
|
for accountID, webhookN := range globalServerConfig.Notify.GetWebhook() {
|
||||||
if !webhookN.Enable {
|
if !webhookN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -705,7 +705,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load elastic targets, initialize their respective loggers.
|
// Load elastic targets, initialize their respective loggers.
|
||||||
for accountID, elasticN := range serverConfig.Notify.GetElasticSearch() {
|
for accountID, elasticN := range globalServerConfig.Notify.GetElasticSearch() {
|
||||||
if !elasticN.Enable {
|
if !elasticN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -724,7 +724,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load PostgreSQL targets, initialize their respective loggers.
|
// Load PostgreSQL targets, initialize their respective loggers.
|
||||||
for accountID, pgN := range serverConfig.Notify.GetPostgreSQL() {
|
for accountID, pgN := range globalServerConfig.Notify.GetPostgreSQL() {
|
||||||
if !pgN.Enable {
|
if !pgN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -743,7 +743,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load MySQL targets, initialize their respective loggers.
|
// Load MySQL targets, initialize their respective loggers.
|
||||||
for accountID, msqlN := range serverConfig.Notify.GetMySQL() {
|
for accountID, msqlN := range globalServerConfig.Notify.GetMySQL() {
|
||||||
if !msqlN.Enable {
|
if !msqlN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load Kafka targets, initialize their respective loggers.
|
// Load Kafka targets, initialize their respective loggers.
|
||||||
for accountID, kafkaN := range serverConfig.Notify.GetKafka() {
|
for accountID, kafkaN := range globalServerConfig.Notify.GetKafka() {
|
||||||
if !kafkaN.Enable {
|
if !kafkaN.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func TestInitEventNotifierWithPostgreSQL(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetPostgreSQLByID("1", postgreSQLNotify{Enable: true})
|
globalServerConfig.Notify.SetPostgreSQLByID("1", postgreSQLNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("PostgreSQL config didn't fail.")
|
t.Fatal("PostgreSQL config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ func TestInitEventNotifierWithNATS(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetNATSByID("1", natsNotify{Enable: true})
|
globalServerConfig.Notify.SetNATSByID("1", natsNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("NATS config didn't fail.")
|
t.Fatal("NATS config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func TestInitEventNotifierWithWebHook(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetWebhookByID("1", webhookNotify{Enable: true})
|
globalServerConfig.Notify.SetWebhookByID("1", webhookNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("WebHook config didn't fail.")
|
t.Fatal("WebHook config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ func TestInitEventNotifierWithAMQP(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetAMQPByID("1", amqpNotify{Enable: true})
|
globalServerConfig.Notify.SetAMQPByID("1", amqpNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("AMQP config didn't fail.")
|
t.Fatal("AMQP config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ func TestInitEventNotifierWithElasticSearch(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetElasticSearchByID("1", elasticSearchNotify{Enable: true})
|
globalServerConfig.Notify.SetElasticSearchByID("1", elasticSearchNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("ElasticSearch config didn't fail.")
|
t.Fatal("ElasticSearch config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ func TestInitEventNotifierWithRedis(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize FS backend.", err)
|
t.Fatal("Unable to initialize FS backend.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetRedisByID("1", redisNotify{Enable: true})
|
globalServerConfig.Notify.SetRedisByID("1", redisNotify{Enable: true})
|
||||||
if err := initEventNotifier(fs); err == nil {
|
if err := initEventNotifier(fs); err == nil {
|
||||||
t.Fatal("Redis config didn't fail.")
|
t.Fatal("Redis config didn't fail.")
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ func TestListenBucketNotification(t *testing.T) {
|
|||||||
|
|
||||||
listenARN := fmt.Sprintf("%s:%s:1:%s-%s",
|
listenARN := fmt.Sprintf("%s:%s:1:%s-%s",
|
||||||
minioTopic,
|
minioTopic,
|
||||||
serverConfig.GetRegion(),
|
globalServerConfig.GetRegion(),
|
||||||
snsTypeMinio,
|
snsTypeMinio,
|
||||||
s.testServer.Server.Listener.Addr(),
|
s.testServer.Server.Listener.Addr(),
|
||||||
)
|
)
|
||||||
@ -525,7 +525,7 @@ func TestAddRemoveBucketListenerConfig(t *testing.T) {
|
|||||||
accountID := fmt.Sprintf("%d", UTCNow().UnixNano())
|
accountID := fmt.Sprintf("%d", UTCNow().UnixNano())
|
||||||
accountARN := fmt.Sprintf(
|
accountARN := fmt.Sprintf(
|
||||||
"arn:minio:sqs:%s:%s:listen-%s",
|
"arn:minio:sqs:%s:%s:listen-%s",
|
||||||
serverConfig.GetRegion(),
|
globalServerConfig.GetRegion(),
|
||||||
accountID,
|
accountID,
|
||||||
globalMinioAddr,
|
globalMinioAddr,
|
||||||
)
|
)
|
||||||
|
@ -374,7 +374,7 @@ func newAzureLayer(host string) (GatewayLayer, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
c, err := storage.NewClient(creds.AccessKey, creds.SecretKey, endpoint, globalAzureAPIVersion, secure)
|
c, err := storage.NewClient(creds.AccessKey, creds.SecretKey, endpoint, globalAzureAPIVersion, secure)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &azureObjects{}, err
|
return &azureObjects{}, err
|
||||||
|
@ -112,7 +112,7 @@ type b2Objects struct {
|
|||||||
// newB2GatewayLayer returns b2 gateway layer.
|
// newB2GatewayLayer returns b2 gateway layer.
|
||||||
func newB2GatewayLayer() (GatewayLayer, error) {
|
func newB2GatewayLayer() (GatewayLayer, error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
client, err := b2.AuthorizeAccount(ctx, creds.AccessKey, creds.SecretKey, b2.Transport(newCustomHTTPTransport()))
|
client, err := b2.AuthorizeAccount(ctx, creds.AccessKey, creds.SecretKey, b2.Transport(newCustomHTTPTransport()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,7 +61,7 @@ func (api gatewayAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypeSigned, authTypePresigned:
|
case authTypeSigned, authTypePresigned:
|
||||||
s3Error := isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error := isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -286,7 +286,7 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypePresigned, authTypeSigned:
|
case authTypePresigned, authTypeSigned:
|
||||||
if s3Error := reqSignatureV4Verify(r, serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := reqSignatureV4Verify(r, globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
@ -357,7 +357,7 @@ func (api gatewayAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypeSigned, authTypePresigned:
|
case authTypeSigned, authTypePresigned:
|
||||||
s3Error := isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error := isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -429,7 +429,7 @@ func (api gatewayAPIHandlers) PutBucketPolicyHandler(w http.ResponseWriter, r *h
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -492,7 +492,7 @@ func (api gatewayAPIHandlers) DeleteBucketPolicyHandler(w http.ResponseWriter, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -526,7 +526,7 @@ func (api gatewayAPIHandlers) GetBucketPolicyHandler(w http.ResponseWriter, r *h
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -596,7 +596,7 @@ func (api gatewayAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PutBucket does not have any bucket action.
|
// PutBucket does not have any bucket action.
|
||||||
s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion())
|
s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
@ -643,7 +643,7 @@ func (api gatewayAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBucket does not have any bucket action.
|
// DeleteBucket does not have any bucket action.
|
||||||
if s3Error := checkRequestAuthType(r, "", "", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, "", "", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -690,7 +690,7 @@ func (api gatewayAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypeSigned, authTypePresigned:
|
case authTypeSigned, authTypePresigned:
|
||||||
s3Error := isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error := isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -764,7 +764,7 @@ func (api gatewayAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypeSigned, authTypePresigned:
|
case authTypeSigned, authTypePresigned:
|
||||||
s3Error := isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error := isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, dumpRequest(r))
|
errorIf(errSignatureMismatch, dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -843,7 +843,7 @@ func (api gatewayAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypeSigned, authTypePresigned:
|
case authTypeSigned, authTypePresigned:
|
||||||
s3Error := isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error := isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
@ -898,7 +898,7 @@ func (api gatewayAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r
|
|||||||
s3Error := isReqAuthenticated(r, globalMinioDefaultRegion)
|
s3Error := isReqAuthenticated(r, globalMinioDefaultRegion)
|
||||||
if s3Error == ErrInvalidRegion {
|
if s3Error == ErrInvalidRegion {
|
||||||
// Clients like boto3 send getBucketLocation() call signed with region that is configured.
|
// Clients like boto3 send getBucketLocation() call signed with region that is configured.
|
||||||
s3Error = isReqAuthenticated(r, serverConfig.GetRegion())
|
s3Error = isReqAuthenticated(r, globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
if s3Error != ErrNone {
|
if s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
@ -927,7 +927,7 @@ func (api gatewayAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r
|
|||||||
// Generate response.
|
// Generate response.
|
||||||
encodedSuccessResponse := encodeResponse(LocationResponse{})
|
encodedSuccessResponse := encodeResponse(LocationResponse{})
|
||||||
// Get current region.
|
// Get current region.
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
if region != globalMinioDefaultRegion {
|
if region != globalMinioDefaultRegion {
|
||||||
encodedSuccessResponse = encodeResponse(LocationResponse{
|
encodedSuccessResponse = encodeResponse(LocationResponse{
|
||||||
Location: region,
|
Location: region,
|
||||||
|
@ -195,7 +195,7 @@ func newS3GatewayLayer(host string) (GatewayLayer, error) {
|
|||||||
endpoint = "s3.amazonaws.com"
|
endpoint = "s3.amazonaws.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Initialize minio client object.
|
// Initialize minio client object.
|
||||||
client, err := minio.NewCore(endpoint, creds.AccessKey, creds.SecretKey, secure)
|
client, err := minio.NewCore(endpoint, creds.AccessKey, creds.SecretKey, secure)
|
||||||
|
@ -45,7 +45,7 @@ func printGatewayStartupMessage(apiEndPoints []string, backendType string) {
|
|||||||
// Prints common server startup message. Prints credential, region and browser access.
|
// Prints common server startup message. Prints credential, region and browser access.
|
||||||
func printGatewayCommonMsg(apiEndpoints []string) {
|
func printGatewayCommonMsg(apiEndpoints []string) {
|
||||||
// Get saved credentials.
|
// Get saved credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
apiEndpointStr := strings.Join(apiEndpoints, " ")
|
apiEndpointStr := strings.Join(apiEndpoints, " ")
|
||||||
// Colorize the message and print.
|
// Colorize the message and print.
|
||||||
|
@ -43,7 +43,7 @@ func parseLocationConstraint(r *http.Request) (location string, s3Error APIError
|
|||||||
} // else for both err as nil or io.EOF
|
} // else for both err as nil or io.EOF
|
||||||
location = locationConstraint.Location
|
location = locationConstraint.Location
|
||||||
if location == "" {
|
if location == "" {
|
||||||
location = serverConfig.GetRegion()
|
location = globalServerConfig.GetRegion()
|
||||||
}
|
}
|
||||||
return location, ErrNone
|
return location, ErrNone
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ func parseLocationConstraint(r *http.Request) (location string, s3Error APIError
|
|||||||
// Validates input location is same as configured region
|
// Validates input location is same as configured region
|
||||||
// of Minio server.
|
// of Minio server.
|
||||||
func isValidLocation(location string) bool {
|
func isValidLocation(location string) bool {
|
||||||
return serverConfig.GetRegion() == "" || serverConfig.GetRegion() == location
|
return globalServerConfig.GetRegion() == "" || globalServerConfig.GetRegion() == location
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supported headers that needs to be extracted.
|
// Supported headers that needs to be extracted.
|
||||||
|
@ -77,7 +77,7 @@ func TestIsValidLocationContraint(t *testing.T) {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
t.Fatalf("Test %d: Failed to Marshal bucket configuration", i+1)
|
t.Fatalf("Test %d: Failed to Marshal bucket configuration", i+1)
|
||||||
}
|
}
|
||||||
serverConfig.SetRegion(testCase.serverConfigRegion)
|
globalServerConfig.SetRegion(testCase.serverConfigRegion)
|
||||||
_, actualCode := parseLocationConstraint(inputRequest)
|
_, actualCode := parseLocationConstraint(inputRequest)
|
||||||
if testCase.expectedCode != actualCode {
|
if testCase.expectedCode != actualCode {
|
||||||
t.Errorf("Test %d: Expected the APIErrCode to be %d, but instead found %d", i+1, testCase.expectedCode, actualCode)
|
t.Errorf("Test %d: Expected the APIErrCode to be %d, but instead found %d", i+1, testCase.expectedCode, actualCode)
|
||||||
|
@ -53,7 +53,7 @@ func authenticateJWT(accessKey, secretKey string, expiry time.Duration) (string,
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
serverCred := serverConfig.GetCredential()
|
serverCred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
if serverCred.AccessKey != passedCredential.AccessKey {
|
if serverCred.AccessKey != passedCredential.AccessKey {
|
||||||
return "", errInvalidAccessKeyID
|
return "", errInvalidAccessKeyID
|
||||||
@ -90,7 +90,7 @@ func keyFuncCallback(jwtToken *jwtgo.Token) (interface{}, error) {
|
|||||||
return nil, fmt.Errorf("Unexpected signing method: %v", jwtToken.Header["alg"])
|
return nil, fmt.Errorf("Unexpected signing method: %v", jwtToken.Header["alg"])
|
||||||
}
|
}
|
||||||
|
|
||||||
return []byte(serverConfig.GetCredential().SecretKey), nil
|
return []byte(globalServerConfig.GetCredential().SecretKey), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAuthTokenValid(tokenString string) bool {
|
func isAuthTokenValid(tokenString string) bool {
|
||||||
@ -107,7 +107,7 @@ func isAuthTokenValid(tokenString string) bool {
|
|||||||
errorIf(err, "Invalid claims in JWT token string")
|
errorIf(err, "Invalid claims in JWT token string")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return jwtToken.Valid && claims.Subject == serverConfig.GetCredential().AccessKey
|
return jwtToken.Valid && claims.Subject == globalServerConfig.GetCredential().AccessKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHTTPRequestValid(req *http.Request) bool {
|
func isHTTPRequestValid(req *http.Request) bool {
|
||||||
@ -129,7 +129,7 @@ func webRequestAuthenticate(req *http.Request) error {
|
|||||||
if err = claims.Valid(); err != nil {
|
if err = claims.Valid(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if claims.Subject != serverConfig.GetCredential().AccessKey {
|
if claims.Subject != globalServerConfig.GetCredential().AccessKey {
|
||||||
return errInvalidAccessKeyID
|
return errInvalidAccessKeyID
|
||||||
}
|
}
|
||||||
if !jwtToken.Valid {
|
if !jwtToken.Valid {
|
||||||
|
@ -31,7 +31,7 @@ func testAuthenticate(authType string, t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(testPath)
|
defer os.RemoveAll(testPath)
|
||||||
cred := auth.MustGetNewCredentials()
|
cred := auth.MustGetNewCredentials()
|
||||||
serverConfig.SetCredential(cred)
|
globalServerConfig.SetCredential(cred)
|
||||||
|
|
||||||
// Define test cases.
|
// Define test cases.
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -95,7 +95,7 @@ func TestWebRequestAuthenticate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(testPath)
|
defer os.RemoveAll(testPath)
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := getTokenString(creds.AccessKey, creds.SecretKey)
|
token, err := getTokenString(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable get token %s", err)
|
t.Fatalf("unable get token %s", err)
|
||||||
@ -146,7 +146,7 @@ func BenchmarkAuthenticateNode(b *testing.B) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(testPath)
|
defer os.RemoveAll(testPath)
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
@ -161,7 +161,7 @@ func BenchmarkAuthenticateWeb(b *testing.B) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(testPath)
|
defer os.RemoveAll(testPath)
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
|
@ -310,7 +310,7 @@ func (l *lockServer) lockMaintenance(interval time.Duration) {
|
|||||||
nlripLongLived := getLongLivedLocks(l.ll.lockMap, interval)
|
nlripLongLived := getLongLivedLocks(l.ll.lockMap, interval)
|
||||||
l.ll.mutex.Unlock()
|
l.ll.mutex.Unlock()
|
||||||
|
|
||||||
serverCred := serverConfig.GetCredential()
|
serverCred := globalServerConfig.GetCredential()
|
||||||
// Validate if long lived locks are indeed clean.
|
// Validate if long lived locks are indeed clean.
|
||||||
for _, nlrip := range nlripLongLived {
|
for _, nlrip := range nlripLongLived {
|
||||||
// Initialize client based on the long live locks.
|
// Initialize client based on the long live locks.
|
||||||
|
@ -57,7 +57,7 @@ func createLockTestServer(t *testing.T) (string, *lockServer, string) {
|
|||||||
lockMap: make(map[string][]lockRequesterInfo),
|
lockMap: make(map[string][]lockRequesterInfo),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateNode(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -53,7 +53,7 @@ type RWLockerSync interface {
|
|||||||
// Initialize distributed locking only in case of distributed setup.
|
// Initialize distributed locking only in case of distributed setup.
|
||||||
// Returns lock clients and the node index for the current server.
|
// Returns lock clients and the node index for the current server.
|
||||||
func newDsyncNodes(endpoints EndpointList) (clnts []dsync.NetLocker, myNode int) {
|
func newDsyncNodes(endpoints EndpointList) (clnts []dsync.NetLocker, myNode int) {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
clnts = make([]dsync.NetLocker, len(endpoints))
|
clnts = make([]dsync.NetLocker, len(endpoints))
|
||||||
myNode = -1
|
myNode = -1
|
||||||
for index, endpoint := range endpoints {
|
for index, endpoint := range endpoints {
|
||||||
|
@ -68,7 +68,7 @@ func isAMQPQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeAMQP {
|
if sqsArn.Type != queueTypeAMQP {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
amqpL := serverConfig.Notify.GetAMQPByID(sqsArn.AccountID)
|
amqpL := globalServerConfig.Notify.GetAMQPByID(sqsArn.AccountID)
|
||||||
if !amqpL.Enable {
|
if !amqpL.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ func isMQTTQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeMQTT {
|
if sqsArn.Type != queueTypeMQTT {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mqttL := serverConfig.Notify.GetMQTTByID(sqsArn.AccountID)
|
mqttL := globalServerConfig.Notify.GetMQTTByID(sqsArn.AccountID)
|
||||||
if !mqttL.Enable {
|
if !mqttL.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func isNATSQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeNATS {
|
if sqsArn.Type != queueTypeNATS {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
natsL := serverConfig.Notify.GetNATSByID(sqsArn.AccountID)
|
natsL := globalServerConfig.Notify.GetNATSByID(sqsArn.AccountID)
|
||||||
if !natsL.Enable {
|
if !natsL.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ func isWebhookQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeWebhook {
|
if sqsArn.Type != queueTypeWebhook {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
rNotify := serverConfig.Notify.GetWebhookByID(sqsArn.AccountID)
|
rNotify := globalServerConfig.Notify.GetWebhookByID(sqsArn.AccountID)
|
||||||
return rNotify.Enable
|
return rNotify.Enable
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func isRedisQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeRedis {
|
if sqsArn.Type != queueTypeRedis {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
rNotify := serverConfig.Notify.GetRedisByID(sqsArn.AccountID)
|
rNotify := globalServerConfig.Notify.GetRedisByID(sqsArn.AccountID)
|
||||||
if !rNotify.Enable {
|
if !rNotify.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ func isElasticQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeElastic {
|
if sqsArn.Type != queueTypeElastic {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
esNotify := serverConfig.Notify.GetElasticSearchByID(sqsArn.AccountID)
|
esNotify := globalServerConfig.Notify.GetElasticSearchByID(sqsArn.AccountID)
|
||||||
if !esNotify.Enable {
|
if !esNotify.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func isPostgreSQLQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypePostgreSQL {
|
if sqsArn.Type != queueTypePostgreSQL {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
pgNotify := serverConfig.Notify.GetPostgreSQLByID(sqsArn.AccountID)
|
pgNotify := globalServerConfig.Notify.GetPostgreSQLByID(sqsArn.AccountID)
|
||||||
if !pgNotify.Enable {
|
if !pgNotify.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ func isMySQLQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeMySQL {
|
if sqsArn.Type != queueTypeMySQL {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
msqlNotify := serverConfig.Notify.GetMySQLByID(sqsArn.AccountID)
|
msqlNotify := globalServerConfig.Notify.GetMySQLByID(sqsArn.AccountID)
|
||||||
if !msqlNotify.Enable {
|
if !msqlNotify.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ func isKafkaQueue(sqsArn arnSQS) bool {
|
|||||||
if sqsArn.Type != queueTypeKafka {
|
if sqsArn.Type != queueTypeKafka {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
kafkaNotifyCfg := serverConfig.Notify.GetKafkaByID(sqsArn.AccountID)
|
kafkaNotifyCfg := globalServerConfig.Notify.GetKafkaByID(sqsArn.AccountID)
|
||||||
if !kafkaNotifyCfg.Enable {
|
if !kafkaNotifyCfg.Enable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func dialAMQP(amqpL amqpNotify) (*amqpConn, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newAMQPNotify(accountID string) (*logrus.Logger, error) {
|
func newAMQPNotify(accountID string) (*logrus.Logger, error) {
|
||||||
amqpL := serverConfig.Notify.GetAMQPByID(accountID)
|
amqpL := globalServerConfig.Notify.GetAMQPByID(accountID)
|
||||||
|
|
||||||
// Connect to amqp server.
|
// Connect to amqp server.
|
||||||
amqpC, err := dialAMQP(amqpL)
|
amqpC, err := dialAMQP(amqpL)
|
||||||
|
@ -75,7 +75,7 @@ func dialElastic(esNotify elasticSearchNotify) (*elastic.Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newElasticNotify(accountID string) (*logrus.Logger, error) {
|
func newElasticNotify(accountID string) (*logrus.Logger, error) {
|
||||||
esNotify := serverConfig.Notify.GetElasticSearchByID(accountID)
|
esNotify := globalServerConfig.Notify.GetElasticSearchByID(accountID)
|
||||||
|
|
||||||
// Dial to elastic search.
|
// Dial to elastic search.
|
||||||
client, err := dialElastic(esNotify)
|
client, err := dialElastic(esNotify)
|
||||||
|
@ -92,7 +92,7 @@ func dialKafka(kn kafkaNotify) (kc kafkaConn, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newKafkaNotify(accountID string) (*logrus.Logger, error) {
|
func newKafkaNotify(accountID string) (*logrus.Logger, error) {
|
||||||
kafkaNotifyCfg := serverConfig.Notify.GetKafkaByID(accountID)
|
kafkaNotifyCfg := globalServerConfig.Notify.GetKafkaByID(accountID)
|
||||||
|
|
||||||
// Try connecting to the configured Kafka broker(s).
|
// Try connecting to the configured Kafka broker(s).
|
||||||
kc, err := dialKafka(kafkaNotifyCfg)
|
kc, err := dialKafka(kafkaNotifyCfg)
|
||||||
|
@ -72,7 +72,7 @@ func dialMQTT(mqttL mqttNotify) (mc mqttConn, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newMQTTNotify(accountID string) (*logrus.Logger, error) {
|
func newMQTTNotify(accountID string) (*logrus.Logger, error) {
|
||||||
mqttL := serverConfig.Notify.GetMQTTByID(accountID)
|
mqttL := globalServerConfig.Notify.GetMQTTByID(accountID)
|
||||||
|
|
||||||
//connect to MQTT Server
|
//connect to MQTT Server
|
||||||
mqttC, err := dialMQTT(mqttL)
|
mqttC, err := dialMQTT(mqttL)
|
||||||
|
@ -227,7 +227,7 @@ func dialMySQL(msql mySQLNotify) (mc mySQLConn, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newMySQLNotify(accountID string) (*logrus.Logger, error) {
|
func newMySQLNotify(accountID string) (*logrus.Logger, error) {
|
||||||
mysqlNotify := serverConfig.Notify.GetMySQLByID(accountID)
|
mysqlNotify := globalServerConfig.Notify.GetMySQLByID(accountID)
|
||||||
|
|
||||||
// Dial mysql
|
// Dial mysql
|
||||||
myC, err := dialMySQL(mysqlNotify)
|
myC, err := dialMySQL(mysqlNotify)
|
||||||
|
@ -138,7 +138,7 @@ func closeNATS(conn natsIOConn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newNATSNotify(accountID string) (*logrus.Logger, error) {
|
func newNATSNotify(accountID string) (*logrus.Logger, error) {
|
||||||
natsL := serverConfig.Notify.GetNATSByID(accountID)
|
natsL := globalServerConfig.Notify.GetNATSByID(accountID)
|
||||||
|
|
||||||
// Connect to nats server.
|
// Connect to nats server.
|
||||||
natsC, err := dialNATS(natsL, false)
|
natsC, err := dialNATS(natsL, false)
|
||||||
|
@ -242,7 +242,7 @@ func dialPostgreSQL(pgN postgreSQLNotify) (pc pgConn, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newPostgreSQLNotify(accountID string) (*logrus.Logger, error) {
|
func newPostgreSQLNotify(accountID string) (*logrus.Logger, error) {
|
||||||
pgNotify := serverConfig.Notify.GetPostgreSQLByID(accountID)
|
pgNotify := globalServerConfig.Notify.GetPostgreSQLByID(accountID)
|
||||||
|
|
||||||
// Dial postgres
|
// Dial postgres
|
||||||
pgC, err := dialPostgreSQL(pgNotify)
|
pgC, err := dialPostgreSQL(pgNotify)
|
||||||
|
@ -128,7 +128,7 @@ func dialRedis(rNotify redisNotify) (*redis.Pool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newRedisNotify(accountID string) (*logrus.Logger, error) {
|
func newRedisNotify(accountID string) (*logrus.Logger, error) {
|
||||||
rNotify := serverConfig.Notify.GetRedisByID(accountID)
|
rNotify := globalServerConfig.Notify.GetRedisByID(accountID)
|
||||||
|
|
||||||
// Dial redis.
|
// Dial redis.
|
||||||
rPool, err := dialRedis(rNotify)
|
rPool, err := dialRedis(rNotify)
|
||||||
|
@ -130,7 +130,7 @@ func lookupEndpoint(urlStr string) error {
|
|||||||
|
|
||||||
// Initializes new webhook logrus notifier.
|
// Initializes new webhook logrus notifier.
|
||||||
func newWebhookNotify(accountID string) (*logrus.Logger, error) {
|
func newWebhookNotify(accountID string) (*logrus.Logger, error) {
|
||||||
rNotify := serverConfig.Notify.GetWebhookByID(accountID)
|
rNotify := globalServerConfig.Notify.GetWebhookByID(accountID)
|
||||||
if rNotify.Endpoint == "" {
|
if rNotify.Endpoint == "" {
|
||||||
return nil, errInvalidArgument
|
return nil, errInvalidArgument
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,13 @@ func TestNewWebHookNotify(t *testing.T) {
|
|||||||
t.Fatal("Unexpected should fail")
|
t.Fatal("Unexpected should fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetWebhookByID("10", webhookNotify{Enable: true, Endpoint: "http://127.0.0.1:80"})
|
globalServerConfig.Notify.SetWebhookByID("10", webhookNotify{Enable: true, Endpoint: "http://127.0.0.1:80"})
|
||||||
_, err = newWebhookNotify("10")
|
_, err = newWebhookNotify("10")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected should not fail with lookupEndpoint", err)
|
t.Fatal("Unexpected should not fail with lookupEndpoint", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig.Notify.SetWebhookByID("15", webhookNotify{Enable: true, Endpoint: "http://%"})
|
globalServerConfig.Notify.SetWebhookByID("15", webhookNotify{Enable: true, Endpoint: "http://%"})
|
||||||
_, err = newWebhookNotify("15")
|
_, err = newWebhookNotify("15")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Unexpected should fail with invalid URL escape")
|
t.Fatal("Unexpected should fail with invalid URL escape")
|
||||||
@ -74,7 +74,7 @@ func TestNewWebHookNotify(t *testing.T) {
|
|||||||
server := httptest.NewServer(postHandler{})
|
server := httptest.NewServer(postHandler{})
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
serverConfig.Notify.SetWebhookByID("20", webhookNotify{Enable: true, Endpoint: server.URL})
|
globalServerConfig.Notify.SetWebhookByID("20", webhookNotify{Enable: true, Endpoint: server.URL})
|
||||||
webhook, err := newWebhookNotify("20")
|
webhook, err := newWebhookNotify("20")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected shouldn't fail", err)
|
t.Fatal("Unexpected shouldn't fail", err)
|
||||||
|
@ -102,7 +102,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:GetObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:GetObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:GetObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:GetObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponseHeadersOnly(w, s3Error)
|
writeErrorResponseHeadersOnly(w, s3Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, dstBucket, "s3:PutObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, dstBucket, "s3:PutObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -578,7 +578,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypePresigned, authTypeSigned:
|
case authTypePresigned, authTypeSigned:
|
||||||
if s3Err = reqSignatureV4Verify(r, serverConfig.GetRegion()); s3Err != ErrNone {
|
if s3Err = reqSignatureV4Verify(r, globalServerConfig.GetRegion()); s3Err != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Err, r.URL)
|
writeErrorResponse(w, s3Err, r.URL)
|
||||||
return
|
return
|
||||||
@ -654,7 +654,7 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:PutObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:PutObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, dstBucket, "s3:PutObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, dstBucket, "s3:PutObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -909,7 +909,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case authTypePresigned, authTypeSigned:
|
case authTypePresigned, authTypeSigned:
|
||||||
if s3Error := reqSignatureV4Verify(r, serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := reqSignatureV4Verify(r, globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r))
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
@ -954,7 +954,7 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:AbortMultipartUpload", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:AbortMultipartUpload", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -980,7 +980,7 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:ListMultipartUploadParts", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:ListMultipartUploadParts", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1019,7 +1019,7 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:PutObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:PutObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1127,7 +1127,7 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s3Error := checkRequestAuthType(r, bucket, "s3:DeleteObject", serverConfig.GetRegion()); s3Error != ErrNone {
|
if s3Error := checkRequestAuthType(r, bucket, "s3:DeleteObject", globalServerConfig.GetRegion()); s3Error != ErrNone {
|
||||||
writeErrorResponse(w, s3Error, r.URL)
|
writeErrorResponse(w, s3Error, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func testPostPolicyBucketHandler(obj ObjectLayer, instanceType string, t TestErr
|
|||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestAPIEndPoints(obj, []string{"PostPolicy"})
|
apiRouter := initTestAPIEndPoints(obj, []string{"PostPolicy"})
|
||||||
|
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
curTime := UTCNow()
|
curTime := UTCNow()
|
||||||
curTimePlus5Min := curTime.Add(time.Minute * 5)
|
curTimePlus5Min := curTime.Add(time.Minute * 5)
|
||||||
@ -455,7 +455,7 @@ func testPostPolicyBucketHandlerRedirect(obj ObjectLayer, instanceType string, t
|
|||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestAPIEndPoints(obj, []string{"PostPolicy"})
|
apiRouter := initTestAPIEndPoints(obj, []string{"PostPolicy"})
|
||||||
|
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
curTime := UTCNow()
|
curTime := UTCNow()
|
||||||
curTimePlus5Min := curTime.Add(time.Minute * 5)
|
curTimePlus5Min := curTime.Add(time.Minute * 5)
|
||||||
|
@ -48,7 +48,7 @@ func makeS3Peers(endpoints EndpointList) (s3PeerList s3Peers) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
hostSet := set.CreateStringSet(localAddr)
|
hostSet := set.CreateStringSet(localAddr)
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
serviceEndpoint := path.Join(minioReservedBucketPath, s3Path)
|
serviceEndpoint := path.Join(minioReservedBucketPath, s3Path)
|
||||||
for _, host := range GetRemotePeers(endpoints) {
|
for _, host := range GetRemotePeers(endpoints) {
|
||||||
if hostSet.Contains(host) {
|
if hostSet.Contains(host) {
|
||||||
|
@ -101,10 +101,10 @@ func stripStandardPorts(apiEndpoints []string) (newAPIEndpoints []string) {
|
|||||||
// Prints common server startup message. Prints credential, region and browser access.
|
// Prints common server startup message. Prints credential, region and browser access.
|
||||||
func printServerCommonMsg(apiEndpoints []string) {
|
func printServerCommonMsg(apiEndpoints []string) {
|
||||||
// Get saved credentials.
|
// Get saved credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Get saved region.
|
// Get saved region.
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
apiEndpointStr := strings.Join(apiEndpoints, " ")
|
apiEndpointStr := strings.Join(apiEndpoints, " ")
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ func printEventNotifiers() {
|
|||||||
// and custom platform specific message.
|
// and custom platform specific message.
|
||||||
func printCLIAccessMsg(endPoint string, alias string) {
|
func printCLIAccessMsg(endPoint string, alias string) {
|
||||||
// Get saved credentials.
|
// Get saved credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Configure 'mc', following block prints platform specific information for minio client.
|
// Configure 'mc', following block prints platform specific information for minio client.
|
||||||
log.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
|
log.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
|
||||||
|
@ -64,7 +64,7 @@ var resourceList = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doesPolicySignatureV2Match(formValues http.Header) APIErrorCode {
|
func doesPolicySignatureV2Match(formValues http.Header) APIErrorCode {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
accessKey := formValues.Get("AWSAccessKeyId")
|
accessKey := formValues.Get("AWSAccessKeyId")
|
||||||
if accessKey != cred.AccessKey {
|
if accessKey != cred.AccessKey {
|
||||||
return ErrInvalidAccessKeyID
|
return ErrInvalidAccessKeyID
|
||||||
@ -96,7 +96,7 @@ func unescapeQueries(encodedQuery string) (unescapedQueries []string, err error)
|
|||||||
// returns ErrNone if matches. S3 errors otherwise.
|
// returns ErrNone if matches. S3 errors otherwise.
|
||||||
func doesPresignV2SignatureMatch(r *http.Request) APIErrorCode {
|
func doesPresignV2SignatureMatch(r *http.Request) APIErrorCode {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// r.RequestURI will have raw encoded URI as sent by the client.
|
// r.RequestURI will have raw encoded URI as sent by the client.
|
||||||
tokens := strings.SplitN(r.RequestURI, "?", 2)
|
tokens := strings.SplitN(r.RequestURI, "?", 2)
|
||||||
@ -213,7 +213,7 @@ func validateV2AuthHeader(v2Auth string) APIErrorCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
if keySignFields[0] != cred.AccessKey {
|
if keySignFields[0] != cred.AccessKey {
|
||||||
return ErrInvalidAccessKeyID
|
return ErrInvalidAccessKeyID
|
||||||
}
|
}
|
||||||
@ -263,14 +263,14 @@ func calculateSignatureV2(stringToSign string, secret string) string {
|
|||||||
|
|
||||||
// Return signature-v2 for the presigned request.
|
// Return signature-v2 for the presigned request.
|
||||||
func preSignatureV2(method string, encodedResource string, encodedQuery string, headers http.Header, expires string) string {
|
func preSignatureV2(method string, encodedResource string, encodedQuery string, headers http.Header, expires string) string {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
stringToSign := getStringToSignV2(method, encodedResource, encodedQuery, headers, expires)
|
stringToSign := getStringToSignV2(method, encodedResource, encodedQuery, headers, expires)
|
||||||
return calculateSignatureV2(stringToSign, cred.SecretKey)
|
return calculateSignatureV2(stringToSign, cred.SecretKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return signature-v2 authrization header.
|
// Return signature-v2 authrization header.
|
||||||
func signatureV2(method string, encodedResource string, encodedQuery string, headers http.Header) string {
|
func signatureV2(method string, encodedResource string, encodedQuery string, headers http.Header) string {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
stringToSign := getStringToSignV2(method, encodedResource, encodedQuery, headers, "")
|
stringToSign := getStringToSignV2(method, encodedResource, encodedQuery, headers, "")
|
||||||
signature := calculateSignatureV2(stringToSign, cred.SecretKey)
|
signature := calculateSignatureV2(stringToSign, cred.SecretKey)
|
||||||
return fmt.Sprintf("%s %s:%s", signV2Algorithm, cred.AccessKey, signature)
|
return fmt.Sprintf("%s %s:%s", signV2Algorithm, cred.AccessKey, signature)
|
||||||
|
@ -49,8 +49,8 @@ func TestDoesPresignedV2SignatureMatch(t *testing.T) {
|
|||||||
now := UTCNow()
|
now := UTCNow()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
accessKey = serverConfig.GetCredential().AccessKey
|
accessKey = globalServerConfig.GetCredential().AccessKey
|
||||||
secretKey = serverConfig.GetCredential().SecretKey
|
secretKey = globalServerConfig.GetCredential().SecretKey
|
||||||
)
|
)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
queryParams map[string]string
|
queryParams map[string]string
|
||||||
@ -163,7 +163,7 @@ func TestValidateV2AuthHeader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
accessID := serverConfig.GetCredential().AccessKey
|
accessID := globalServerConfig.GetCredential().AccessKey
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
authString string
|
authString string
|
||||||
expectedError APIErrorCode
|
expectedError APIErrorCode
|
||||||
@ -233,7 +233,7 @@ func TestDoesPolicySignatureV2Match(t *testing.T) {
|
|||||||
t.Fatal("Unable to initialize test config.")
|
t.Fatal("Unable to initialize test config.")
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
policy := "policy"
|
policy := "policy"
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
accessKey string
|
accessKey string
|
||||||
|
@ -151,10 +151,10 @@ func doesPolicySignatureMatch(formValues http.Header) APIErrorCode {
|
|||||||
// returns ErrNone if the signature matches.
|
// returns ErrNone if the signature matches.
|
||||||
func doesPolicySignatureV4Match(formValues http.Header) APIErrorCode {
|
func doesPolicySignatureV4Match(formValues http.Header) APIErrorCode {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Server region.
|
// Server region.
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
// Parse credential tag.
|
// Parse credential tag.
|
||||||
credHeader, err := parseCredentialHeader("Credential=" + formValues.Get("X-Amz-Credential"))
|
credHeader, err := parseCredentialHeader("Credential=" + formValues.Get("X-Amz-Credential"))
|
||||||
@ -193,7 +193,7 @@ func doesPolicySignatureV4Match(formValues http.Header) APIErrorCode {
|
|||||||
// returns ErrNone if the signature matches.
|
// returns ErrNone if the signature matches.
|
||||||
func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, region string) APIErrorCode {
|
func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, region string) APIErrorCode {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Copy request
|
// Copy request
|
||||||
req := *r
|
req := *r
|
||||||
@ -312,7 +312,7 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, region s
|
|||||||
// returns ErrNone if signature matches.
|
// returns ErrNone if signature matches.
|
||||||
func doesSignatureMatch(hashedPayload string, r *http.Request, region string) APIErrorCode {
|
func doesSignatureMatch(hashedPayload string, r *http.Request, region string) APIErrorCode {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Copy request.
|
// Copy request.
|
||||||
req := *r
|
req := *r
|
||||||
|
@ -37,7 +37,7 @@ func niceError(code APIErrorCode) string {
|
|||||||
func TestDoesPolicySignatureMatch(t *testing.T) {
|
func TestDoesPolicySignatureMatch(t *testing.T) {
|
||||||
credentialTemplate := "%s/%s/%s/s3/aws4_request"
|
credentialTemplate := "%s/%s/%s/s3/aws4_request"
|
||||||
now := UTCNow()
|
now := UTCNow()
|
||||||
accessKey := serverConfig.GetCredential().AccessKey
|
accessKey := globalServerConfig.GetCredential().AccessKey
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
form http.Header
|
form http.Header
|
||||||
@ -73,7 +73,7 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"X-Amz-Date": []string{now.Format(iso8601Format)},
|
"X-Amz-Date": []string{now.Format(iso8601Format)},
|
||||||
"X-Amz-Signature": []string{
|
"X-Amz-Signature": []string{
|
||||||
getSignature(getSigningKey(serverConfig.GetCredential().SecretKey, now,
|
getSignature(getSigningKey(globalServerConfig.GetCredential().SecretKey, now,
|
||||||
globalMinioDefaultRegion), "policy"),
|
globalMinioDefaultRegion), "policy"),
|
||||||
},
|
},
|
||||||
"Policy": []string{"policy"},
|
"Policy": []string{"policy"},
|
||||||
@ -103,8 +103,8 @@ func TestDoesPresignedSignatureMatch(t *testing.T) {
|
|||||||
now := UTCNow()
|
now := UTCNow()
|
||||||
credentialTemplate := "%s/%s/%s/s3/aws4_request"
|
credentialTemplate := "%s/%s/%s/s3/aws4_request"
|
||||||
|
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
accessKeyID := serverConfig.GetCredential().AccessKey
|
accessKeyID := globalServerConfig.GetCredential().AccessKey
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
queryParams map[string]string
|
queryParams map[string]string
|
||||||
headers map[string]string
|
headers map[string]string
|
||||||
|
@ -97,7 +97,7 @@ func toStorageErr(err error) error {
|
|||||||
func newStorageRPC(endpoint Endpoint) StorageAPI {
|
func newStorageRPC(endpoint Endpoint) StorageAPI {
|
||||||
// Dial minio rpc storage http path.
|
// Dial minio rpc storage http path.
|
||||||
rpcPath := path.Join(minioReservedBucketPath, storageRPCPath, endpoint.Path)
|
rpcPath := path.Join(minioReservedBucketPath, storageRPCPath, endpoint.Path)
|
||||||
serverCred := serverConfig.GetCredential()
|
serverCred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
return &networkStorage{
|
return &networkStorage{
|
||||||
rpcClient: newAuthRPCClient(authConfig{
|
rpcClient: newAuthRPCClient(authConfig{
|
||||||
|
@ -38,7 +38,7 @@ func createTestStorageServer(t *testing.T) *testStorageRPCServer {
|
|||||||
t.Fatalf("unable initialize config file, %s", err)
|
t.Fatalf("unable initialize config file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverCred := serverConfig.GetCredential()
|
serverCred := globalServerConfig.GetCredential()
|
||||||
token, err := authenticateNode(serverCred.AccessKey, serverCred.SecretKey)
|
token, err := authenticateNode(serverCred.AccessKey, serverCred.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable for JWT to generate token, %s", err)
|
t.Fatalf("unable for JWT to generate token, %s", err)
|
||||||
|
@ -43,7 +43,7 @@ const (
|
|||||||
// getChunkSignature - get chunk signature.
|
// getChunkSignature - get chunk signature.
|
||||||
func getChunkSignature(seedSignature string, region string, date time.Time, hashedChunk string) string {
|
func getChunkSignature(seedSignature string, region string, date time.Time, hashedChunk string) string {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Calculate string to sign.
|
// Calculate string to sign.
|
||||||
stringToSign := signV4ChunkedAlgorithm + "\n" +
|
stringToSign := signV4ChunkedAlgorithm + "\n" +
|
||||||
@ -68,10 +68,10 @@ func getChunkSignature(seedSignature string, region string, date time.Time, hash
|
|||||||
// error while parsing and validating.
|
// error while parsing and validating.
|
||||||
func calculateSeedSignature(r *http.Request) (signature string, region string, date time.Time, errCode APIErrorCode) {
|
func calculateSeedSignature(r *http.Request) (signature string, region string, date time.Time, errCode APIErrorCode) {
|
||||||
// Access credentials.
|
// Access credentials.
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// Configured region.
|
// Configured region.
|
||||||
confRegion := serverConfig.GetRegion()
|
confRegion := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
// Copy request.
|
// Copy request.
|
||||||
req := *r
|
req := *r
|
||||||
|
@ -287,7 +287,7 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
|
|||||||
|
|
||||||
// Test Server needs to start before formatting of disks.
|
// Test Server needs to start before formatting of disks.
|
||||||
// Get credential.
|
// Get credential.
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
testServer.Obj = objLayer
|
testServer.Obj = objLayer
|
||||||
testServer.Disks = mustGetNewEndpointList(disks...)
|
testServer.Disks = mustGetNewEndpointList(disks...)
|
||||||
@ -377,7 +377,7 @@ func StartTestStorageRPCServer(t TestErrHandler, instanceType string, diskN int)
|
|||||||
// Create an instance of TestServer.
|
// Create an instance of TestServer.
|
||||||
testRPCServer := TestServer{}
|
testRPCServer := TestServer{}
|
||||||
// Get credential.
|
// Get credential.
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
endpoints := mustGetNewEndpointList(disks...)
|
endpoints := mustGetNewEndpointList(disks...)
|
||||||
testRPCServer.Root = root
|
testRPCServer.Root = root
|
||||||
@ -407,7 +407,7 @@ func StartTestPeersRPCServer(t TestErrHandler, instanceType string) TestServer {
|
|||||||
// create an instance of TestServer.
|
// create an instance of TestServer.
|
||||||
testRPCServer := TestServer{}
|
testRPCServer := TestServer{}
|
||||||
// Get credential.
|
// Get credential.
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
endpoints := mustGetNewEndpointList(disks...)
|
endpoints := mustGetNewEndpointList(disks...)
|
||||||
testRPCServer.Root = root
|
testRPCServer.Root = root
|
||||||
@ -459,10 +459,10 @@ func resetGlobalObjectAPI() {
|
|||||||
// set it to `nil`.
|
// set it to `nil`.
|
||||||
func resetGlobalConfig() {
|
func resetGlobalConfig() {
|
||||||
// hold the mutex lock before a new config is assigned.
|
// hold the mutex lock before a new config is assigned.
|
||||||
serverConfigMu.Lock()
|
globalServerConfigMu.Lock()
|
||||||
// Save the loaded config globally.
|
// Save the loaded config globally.
|
||||||
serverConfig = nil
|
globalServerConfig = nil
|
||||||
serverConfigMu.Unlock()
|
globalServerConfigMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset global NSLock.
|
// reset global NSLock.
|
||||||
@ -529,10 +529,10 @@ func newTestConfig(bucketLocation string) (rootPath string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set a default region.
|
// Set a default region.
|
||||||
serverConfig.SetRegion(bucketLocation)
|
globalServerConfig.SetRegion(bucketLocation)
|
||||||
|
|
||||||
// Save config.
|
// Save config.
|
||||||
if err = serverConfig.Save(); err != nil {
|
if err = globalServerConfig.Save(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ func newTestStreamingRequest(method, urlStr string, dataLength, chunkSize int64,
|
|||||||
func assembleStreamingChunks(req *http.Request, body io.ReadSeeker, chunkSize int64,
|
func assembleStreamingChunks(req *http.Request, body io.ReadSeeker, chunkSize int64,
|
||||||
secretKey, signature string, currTime time.Time) (*http.Request, error) {
|
secretKey, signature string, currTime time.Time) (*http.Request, error) {
|
||||||
|
|
||||||
regionStr := serverConfig.GetRegion()
|
regionStr := globalServerConfig.GetRegion()
|
||||||
var stream []byte
|
var stream []byte
|
||||||
var buffer []byte
|
var buffer []byte
|
||||||
body.Seek(0, 0)
|
body.Seek(0, 0)
|
||||||
@ -874,7 +874,7 @@ func preSignV4(req *http.Request, accessKeyID, secretAccessKey string, expires i
|
|||||||
return errors.New("Presign cannot be generated without access and secret keys")
|
return errors.New("Presign cannot be generated without access and secret keys")
|
||||||
}
|
}
|
||||||
|
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
date := UTCNow()
|
date := UTCNow()
|
||||||
scope := getScope(date, region)
|
scope := getScope(date, region)
|
||||||
credential := fmt.Sprintf("%s/%s", accessKeyID, scope)
|
credential := fmt.Sprintf("%s/%s", accessKeyID, scope)
|
||||||
@ -1002,7 +1002,7 @@ func signRequestV4(req *http.Request, accessKey, secretKey string) error {
|
|||||||
}
|
}
|
||||||
sort.Strings(headers)
|
sort.Strings(headers)
|
||||||
|
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
// Get canonical headers.
|
// Get canonical headers.
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
@ -1943,7 +1943,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Initialzation of API handler tests failed: <ERROR> %s", err)
|
t.Fatalf("Initialzation of API handler tests failed: <ERROR> %s", err)
|
||||||
}
|
}
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
// Executing the object layer tests for single node setup.
|
// Executing the object layer tests for single node setup.
|
||||||
objAPITest(objLayer, FSTestStr, bucketFS, fsAPIRouter, credentials, t)
|
objAPITest(objLayer, FSTestStr, bucketFS, fsAPIRouter, credentials, t)
|
||||||
|
|
||||||
@ -2191,7 +2191,7 @@ func StartTestBrowserPeerRPCServer(t TestErrHandler, instanceType string) TestSe
|
|||||||
testRPCServer := TestServer{}
|
testRPCServer := TestServer{}
|
||||||
|
|
||||||
// Fetch credentials for the test server.
|
// Fetch credentials for the test server.
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
testRPCServer.Root = root
|
testRPCServer.Root = root
|
||||||
testRPCServer.AccessKey = credentials.AccessKey
|
testRPCServer.AccessKey = credentials.AccessKey
|
||||||
@ -2212,7 +2212,7 @@ func StartTestS3PeerRPCServer(t TestErrHandler) (TestServer, []string) {
|
|||||||
testRPCServer := TestServer{}
|
testRPCServer := TestServer{}
|
||||||
|
|
||||||
// Fetch credentials for the test server.
|
// Fetch credentials for the test server.
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
testRPCServer.Root = root
|
testRPCServer.Root = root
|
||||||
testRPCServer.AccessKey = credentials.AccessKey
|
testRPCServer.AccessKey = credentials.AccessKey
|
||||||
|
@ -137,7 +137,7 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
|
|||||||
}
|
}
|
||||||
defer bucketLock.Unlock()
|
defer bucketLock.Unlock()
|
||||||
|
|
||||||
if err := objectAPI.MakeBucketWithLocation(args.BucketName, serverConfig.GetRegion()); err != nil {
|
if err := objectAPI.MakeBucketWithLocation(args.BucketName, globalServerConfig.GetRegion()); err != nil {
|
||||||
return toJSONError(err, args.BucketName)
|
return toJSONError(err, args.BucketName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,12 +409,12 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se
|
|||||||
errsMap := updateCredsOnPeers(creds)
|
errsMap := updateCredsOnPeers(creds)
|
||||||
|
|
||||||
// Update local credentials
|
// Update local credentials
|
||||||
prevCred := serverConfig.SetCredential(creds)
|
prevCred := globalServerConfig.SetCredential(creds)
|
||||||
|
|
||||||
// Persist updated credentials.
|
// Persist updated credentials.
|
||||||
if err = serverConfig.Save(); err != nil {
|
if err = globalServerConfig.Save(); err != nil {
|
||||||
// Save the current creds when failed to update.
|
// Save the current creds when failed to update.
|
||||||
serverConfig.SetCredential(prevCred)
|
globalServerConfig.SetCredential(prevCred)
|
||||||
|
|
||||||
errsMap[globalMinioAddr] = err
|
errsMap[globalMinioAddr] = err
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ func (web *webAPIHandlers) GetAuth(r *http.Request, args *WebGenericArgs, reply
|
|||||||
if !isHTTPRequestValid(r) {
|
if !isHTTPRequestValid(r) {
|
||||||
return toJSONError(errAuthentication)
|
return toJSONError(errAuthentication)
|
||||||
}
|
}
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
reply.AccessKey = creds.AccessKey
|
reply.AccessKey = creds.AccessKey
|
||||||
reply.SecretKey = creds.SecretKey
|
reply.SecretKey = creds.SecretKey
|
||||||
reply.UIVersion = browser.UIVersion
|
reply.UIVersion = browser.UIVersion
|
||||||
@ -486,7 +486,7 @@ func (web *webAPIHandlers) CreateURLToken(r *http.Request, args *WebGenericArgs,
|
|||||||
return toJSONError(errAuthentication)
|
return toJSONError(errAuthentication)
|
||||||
}
|
}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
token, err := authenticateURL(creds.AccessKey, creds.SecretKey)
|
token, err := authenticateURL(creds.AccessKey, creds.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -925,8 +925,8 @@ func (web *webAPIHandlers) PresignedGet(r *http.Request, args *PresignedGetArgs,
|
|||||||
|
|
||||||
// Returns presigned url for GET method.
|
// Returns presigned url for GET method.
|
||||||
func presignedGet(host, bucket, object string, expiry int64) string {
|
func presignedGet(host, bucket, object string, expiry int64) string {
|
||||||
cred := serverConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
region := serverConfig.GetRegion()
|
region := globalServerConfig.GetRegion()
|
||||||
|
|
||||||
accessKey := cred.AccessKey
|
accessKey := cred.AccessKey
|
||||||
secretKey := cred.SecretKey
|
secretKey := cred.SecretKey
|
||||||
|
@ -143,7 +143,7 @@ func TestWebHandlerLogin(t *testing.T) {
|
|||||||
func testLoginWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testLoginWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
// test cases with sample input and expected output.
|
// test cases with sample input and expected output.
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -183,7 +183,7 @@ func testStorageInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHa
|
|||||||
// get random bucket name.
|
// get random bucket name.
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -220,7 +220,7 @@ func TestWebHandlerServerInfo(t *testing.T) {
|
|||||||
func testServerInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testServerInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -261,7 +261,7 @@ func TestWebHandlerMakeBucket(t *testing.T) {
|
|||||||
func testMakeBucketWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testMakeBucketWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -314,7 +314,7 @@ func TestWebHandlerListBuckets(t *testing.T) {
|
|||||||
func testListBucketsWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testListBucketsWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -362,7 +362,7 @@ func TestWebHandlerListObjects(t *testing.T) {
|
|||||||
func testListObjectsWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testListObjectsWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ func TestWebHandlerRemoveObject(t *testing.T) {
|
|||||||
func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
@ -548,7 +548,7 @@ func TestWebHandlerGenerateAuth(t *testing.T) {
|
|||||||
func testGenerateAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testGenerateAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
@ -585,7 +585,7 @@ func TestWebHandlerSetAuth(t *testing.T) {
|
|||||||
func testSetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testSetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
@ -637,7 +637,7 @@ func TestWebHandlerGetAuth(t *testing.T) {
|
|||||||
func testGetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testGetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
@ -680,7 +680,7 @@ func getTokenString(accessKey, secretKey string) (string, error) {
|
|||||||
|
|
||||||
func testCreateURLToken(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testCreateURLToken(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -737,7 +737,7 @@ func TestWebHandlerUpload(t *testing.T) {
|
|||||||
func testUploadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testUploadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
content := []byte("temporary file's content")
|
content := []byte("temporary file's content")
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
@ -830,7 +830,7 @@ func TestWebHandlerDownload(t *testing.T) {
|
|||||||
func testDownloadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testDownloadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -939,7 +939,7 @@ func TestWebHandlerDownloadZip(t *testing.T) {
|
|||||||
|
|
||||||
func testWebHandlerDownloadZip(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testWebHandlerDownloadZip(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := authenticateURL(credentials.AccessKey, credentials.SecretKey)
|
authorization, err := authenticateURL(credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1023,7 +1023,7 @@ func TestWebHandlerPresignedGetHandler(t *testing.T) {
|
|||||||
func testWebPresignedGetHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testWebPresignedGetHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1128,7 +1128,7 @@ func TestWebHandlerGetBucketPolicyHandler(t *testing.T) {
|
|||||||
func testWebGetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testWebGetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1206,7 +1206,7 @@ func TestWebHandlerListAllBucketPoliciesHandler(t *testing.T) {
|
|||||||
func testWebListAllBucketPoliciesHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testWebListAllBucketPoliciesHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1303,7 +1303,7 @@ func TestWebHandlerSetBucketPolicyHandler(t *testing.T) {
|
|||||||
func testWebSetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
func testWebSetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
|
||||||
// Register the API end points with XL/FS object layer.
|
// Register the API end points with XL/FS object layer.
|
||||||
apiRouter := initTestWebRPCEndPoint(obj)
|
apiRouter := initTestWebRPCEndPoint(obj)
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1465,7 +1465,7 @@ func TestWebObjectLayerNotReady(t *testing.T) {
|
|||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Cannot authenticate", err)
|
t.Fatal("Cannot authenticate", err)
|
||||||
@ -1575,7 +1575,7 @@ func TestWebObjectLayerFaultyDisks(t *testing.T) {
|
|||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
credentials := serverConfig.GetCredential()
|
credentials := globalServerConfig.GetCredential()
|
||||||
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
authorization, err := getWebRPCToken(apiRouter, credentials.AccessKey, credentials.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Cannot authenticate", err)
|
t.Fatal("Cannot authenticate", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user