mirror of
https://github.com/minio/minio.git
synced 2024-12-25 14:45:54 -05:00
Renaming keys as auth, working towards signature v4 support for all put objects
This commit is contained in:
parent
b71f15d32d
commit
770fd23afa
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package keys
|
||||
package auth
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@ -24,9 +24,9 @@ import (
|
||||
// Static alphaNumeric table used for generating unique keys
|
||||
var alphaNumericTable = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
// GenerateRandomAlphaNumeric - generate random alpha numeric value using only uppercase characters
|
||||
// GenerateAccessKeyID - generate random alpha numeric value using only uppercase characters
|
||||
// takes input as size in integer
|
||||
func GenerateRandomAlphaNumeric(size int) ([]byte, error) {
|
||||
func GenerateAccessKeyID(size int) ([]byte, error) {
|
||||
alpha := make([]byte, size)
|
||||
_, err := rand.Read(alpha)
|
||||
if err != nil {
|
||||
@ -39,13 +39,13 @@ func GenerateRandomAlphaNumeric(size int) ([]byte, error) {
|
||||
return alpha, nil
|
||||
}
|
||||
|
||||
// GenerateRandomBase64 - generate random base64 numeric value from a random seed.
|
||||
func GenerateRandomBase64(size int) ([]byte, error) {
|
||||
// GenerateSecretAccessKey - generate random base64 numeric value from a random seed.
|
||||
func GenerateSecretAccessKey(size int) ([]byte, error) {
|
||||
rb := make([]byte, size)
|
||||
_, err := rand.Read(rb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dest := base64.StdEncoding.EncodeToString(rb)
|
||||
return []byte(dest), nil
|
||||
|
||||
return []byte(base64.StdEncoding.EncodeToString(rb))[:size], nil
|
||||
}
|
@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package keys_test
|
||||
package auth_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/minio/check"
|
||||
"github.com/minio/minio/pkg/server/api/auth/keys"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
@ -29,13 +29,16 @@ type MySuite struct{}
|
||||
|
||||
var _ = Suite(&MySuite{})
|
||||
|
||||
func (s *MySuite) TestingKeys(c *C) {
|
||||
value, err := keys.GenerateRandomBase64(keys.MinioSecretID)
|
||||
func (s *MySuite) TestAuth(c *C) {
|
||||
secretID, err := auth.GenerateSecretAccessKey(auth.MinioSecretID)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
alphanum, err := keys.GenerateRandomAlphaNumeric(keys.MinioAccessID)
|
||||
accessID, err := auth.GenerateAccessKeyID(auth.MinioAccessID)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
c.Log(string(value))
|
||||
c.Log(string(alphanum))
|
||||
c.Assert(len(secretID), Equals, auth.MinioSecretID)
|
||||
c.Assert(len(accessID), Equals, auth.MinioAccessID)
|
||||
|
||||
c.Log(string(secretID))
|
||||
c.Log(string(accessID))
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package keys
|
||||
package auth
|
||||
|
||||
import "regexp"
|
||||
|
Loading…
Reference in New Issue
Block a user