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

[Go] Adds a sha256 configuration option to hs2019 #14467

Merged
merged 19 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5c28f79
Merge pull request #26 from OpenAPITools/master
code-lucidal58 Nov 2, 2020
f4028ff
Merge pull request #27 from OpenAPITools/master
code-lucidal58 Dec 17, 2020
5d1956b
Merge branch 'OpenAPITools:master' into master
code-lucidal58 May 11, 2021
2efa03e
Merge branch 'master' of ssh://github.com/OpenAPITools/openapi-genera…
vvb Aug 13, 2021
232cc89
Merge pull request #28 from CiscoM31/feature/refresh_master
vvb Aug 13, 2021
d3e3725
Merge branch 'master' of ssh://github.com/OpenAPITools/openapi-genera…
vvb Aug 18, 2021
91716ea
Merge pull request #42 from CiscoM31/refresh/master
vvb Aug 18, 2021
76f570e
Merge branch 'master' of ssh://github.com/OpenAPITools/openapi-genera…
vvb Aug 23, 2021
3ba948b
Merge pull request #43 from CiscoM31/refresh/master
vvb Aug 23, 2021
56f32d5
Merge branch 'master' of ssh://github.com/OpenAPITools/openapi-genera…
vvb Aug 25, 2021
058f491
Merge pull request #44 from CiscoM31/refresh/master
vvb Aug 25, 2021
b19bb30
Merge branch 'OpenAPITools:master' into master
vvb Sep 3, 2021
d58e4a2
Merge branch 'OpenAPITools:master' into master
sebastien-rosset Oct 11, 2021
7cd305c
Merge branch 'OpenAPITools:master' into master
sebastien-rosset Oct 12, 2021
6debc0b
Merge branch 'master' of ssh://github.com/OpenAPITools/openapi-genera…
vvb Mar 31, 2022
dfb40dc
Merge pull request #62 from CiscoM31/refresh/upstream
vvb Mar 31, 2022
a0e05b8
Merge pull request #78 from CiscoM31/feature/refresh_13_Jul_2022
vvb Jul 13, 2022
2fd6b57
enables configuration of sha256 with hs2019
vvb Jan 16, 2023
c9ad1a5
committing generated examples
vvb Jan 16, 2023
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
18 changes: 17 additions & 1 deletion modules/openapi-generator/src/main/resources/go/signing.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ const (
// Calculate the message signature using probabilistic signature scheme RSASSA-PSS.
// PSS is randomized and will produce a different signature value each time.
HttpSigningAlgorithmRsaPSS string = "RSASSA-PSS"

// HashAlgorithm Sha256 for generating hash
HttpHashAlgorithmSha256 string = "sha256"

// HashAlgorithm Sha512 for generating hash
HttpHashAlgorithmSha512 string = "sha512"
)

var supportedSigningSchemes = map[string]bool{
Expand Down Expand Up @@ -107,6 +113,7 @@ type HttpSignatureAuth struct {
// The signature algorithm, when signing HTTP requests.
// Supported values are RSASSA-PKCS1-v1_5, RSASSA-PSS.
SigningAlgorithm string
HashAlgorithm string // supported values are sha256 and sha512. This also allows using sha256 with hs2019, which defaults to sha512.
SignedHeaders []string // A list of HTTP headers included when generating the signature for the message.
// SignatureMaxValidity specifies the maximum duration of the signature validity.
// The value is used to set the '(expires)' signature parameter in the HTTP request.
Expand Down Expand Up @@ -270,13 +277,22 @@ func SignRequest(
}
// Determine the cryptographic hash to be used for the signature and the body digest.
switch auth.SigningScheme {
case HttpSigningSchemeRsaSha512, HttpSigningSchemeHs2019:
case HttpSigningSchemeRsaSha512:
h = crypto.SHA512
prefix = "SHA-512="
case HttpSigningSchemeRsaSha256:
// This is deprecated and should no longer be used.
h = crypto.SHA256
prefix = "SHA-256="
case HttpSigningSchemeHs2019:
if auth.HashAlgorithm == HttpHashAlgorithmSha256 {
h = crypto.SHA256
prefix = "SHA-256="
} else {
h = crypto.SHA512
prefix = "SHA-512="
}

default:
return fmt.Errorf("Unsupported signature scheme: %v", auth.SigningScheme)
}
Expand Down
18 changes: 17 additions & 1 deletion samples/openapi3/client/petstore/go/go-petstore/signing.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.