2017-02-05 471 views
0

我試圖寫一個基本的測試,以確保我的minio安裝正常工作。我寫了一個測試,使用presigned POST policy的例子,它工作得很好,但我似乎無法創建一個presigned PUT的工作示例。我得到了403 Forbidden,原因是:minio presigned放在超強結果在403

cause="Signature does not match" 
source="[objecthandlers.go:468:objectAPIHandlers.PutObjectHandler()]" 

這裏是測試代碼。我已經promisified minio JavaScript API,並使用磁帶作爲測試工具。 POST策略的類似代碼工作得很好。

編輯:這是這是問題的根源的重要組成部分:

var minio = new Minio.Client({ 
    endPoint: 'minioTest',  // <- the problem 
    port: 9000, 
    secure: false, 
    accessKey: 'DONALDJTRUMP', 
    secretKey: 'DONALDJTRUMP' 
}); 

test('should be able to PUT to a presigned URL', function(assert) { 

    const filename = 'signedtest2.txt'; 

    return minio.presignedPutObjectAsync(bucket, filename, 60) 
    .then(url => { 
    assert.ok(url.length > 200, 'URL is non empty'); 
    console.log(url); 
    return agent 
    .put(url) 
    .set('Content-Type', 'text/plain') 
    .attach('file', 'test/data/test.txt'); 
    }).then(r => { 
    assert.ok(r.ok); 
    console.log(JSON.stringify(r, null, 2)); 
    }).catch(err => { 
    assert.fail('got error', err); 
    console.log(err); 
    }); 
}); 

我在做什麼錯那得到了我403紫禁城?

回答

2

SuperAgent,minio-js或minio服務器不喜歡在主機名(endPoint)中有大寫字母。唉,我使用自動分配主機名的docker,因此如果您使用camelCase作爲容器名稱,並允許這樣做,我只需剪切並粘貼容器名稱即可。

改變此行以小寫解決了這個問題:

endPoint: 'miniotest',  // <- this must be lower case 

主機名是case insensitive所以應該也無妨。我還沒有確定是哪個部件的事,但很可能是強迫爲小寫在生成或驗證簽名時,因此它們不匹配。

我注意到我沒有必要將容器從camelCase中移開。

1

@paul我們已經解決了這個問題,它在源代碼中已經修復。請升級。