Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose GenerateHeader() directly #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generateHMAC.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func GenerateAuthHeader(credsFile, httpMethod, url string) (string, error) {
return "", err
}

headerValue, err := generateHeader(host, params, httpMethod, credentials[0], credentials[1], defaultAuthScheme)
headerValue, err := GenerateHeader(host, params, httpMethod, credentials[0], credentials[1], defaultAuthScheme)
if err != nil {
return "", err
}
Expand Down
7 changes: 6 additions & 1 deletion vcodeHMACAuth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import (

const defaultAuthScheme = "VERACODE-HMAC-SHA-256"

func generateHeader(host, path, method, apiKeyID, apiKeySecret, authScheme string) (string, error) {
// Generates the Authorization header to pass into the API call
// host is usually api.veracode.com, path is in the form /path/to/function
// method is GET, PUT, POST, or DELETE
// the API key and secret must be set
// authScheme is VERACODE-HMAC-SHA-256
func GenerateHeader(host, path, method, apiKeyID, apiKeySecret, authScheme string) (string, error) {
signingData := formatSigningData(apiKeyID, host, path, method)
timestamp := getCurrentTimestamp()
nonce := generateNonce()
Expand Down