Authorization validation in accordance with S3 signer AWSv2

This commit is contained in:
Harshavardhana
2015-01-28 15:45:42 -08:00
parent e25c39e20f
commit d78cd581c5
7 changed files with 218 additions and 26 deletions

View File

@@ -1,8 +1,6 @@
package keys
import (
"bufio"
"bytes"
"crypto/rand"
"encoding/base64"
)
@@ -41,28 +39,6 @@ func GetRandomBase64(size int) ([]byte, error) {
if err != nil {
return nil, err
}
var bytesBuffer bytes.Buffer
writer := bufio.NewWriter(&bytesBuffer)
encoder := base64.NewEncoder(base64.StdEncoding, writer)
encoder.Write(rb)
encoder.Close()
return bytesBuffer.Bytes(), nil
}
func ValidateAccessKey(key []byte) bool {
for _, char := range key {
if isalnum(char) {
continue
}
switch char {
case '-':
case '.':
case '_':
case '~':
continue
default:
return false
}
}
return true
dest := base64.StdEncoding.EncodeToString(rb)
return []byte(dest), nil
}