Skip to content
Snippets Groups Projects
Commit fa2dcd03 authored by Billy Griffiths's avatar Billy Griffiths
Browse files

oauth - use uuid() as base for nonce

parent 8045c47b
Branches
Tags v1.77.0
No related merge requests found
......@@ -2,8 +2,8 @@ package oauth
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/google/uuid"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/encryption"
"math/rand"
"net/url"
"strconv"
"strings"
......@@ -35,8 +35,11 @@ func (auth Oauth1) GenerateAuthorizationHeader(method, requestUrl string) (Autho
params[key] = rawParams.Get(key)
}
// Make a nonce
nonce := strings.ReplaceAll(uuid.New().String(), "-", "")
urlValues := url.Values{}
urlValues.Add("oauth_nonce", generateNonce())
urlValues.Add("oauth_nonce", nonce)
urlValues.Add("oauth_consumer_key", auth.ConsumerKey)
urlValues.Add("oauth_signature_method", "HMAC-SHA256")
urlValues.Add("oauth_timestamp", strconv.Itoa(int(time.Now().Unix())))
......@@ -74,12 +77,3 @@ func (auth Oauth1) GenerateAuthorizationHeader(method, requestUrl string) (Autho
return aws.String("OAuth " + strings.TrimSuffix(AuthorizationString, ",")), nil
}
func generateNonce() string {
const allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, 48)
for i := range b {
b[i] = allowed[rand.Intn(len(allowed))]
}
return string(b)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment