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

Added struct definition to include ClientCert information to API Gateway when using mTLS #342

Merged
merged 17 commits into from Jul 5, 2021

Conversation

dum0nt73
Copy link
Contributor

@dum0nt73 dum0nt73 commented Dec 5, 2020

Issue #337

Added struct definition to include ClientCert information in APIGatewayCustomAuthorizerRequestTypeRequestIdentity and APIGatewayV2HTTPRequestContext for REST and HTTP API Gateway when mTLS is configured.

https://aws.amazon.com/blogs/compute/introducing-mutual-tls-authentication-for-amazon-api-gateway/
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-mutual-tls.html
https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-mutual-tls.html

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-io
Copy link

codecov-io commented Dec 5, 2020

Codecov Report

Merging #342 (92a9843) into master (e5da494) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #342   +/-   ##
=======================================
  Coverage   72.22%   72.22%           
=======================================
  Files          19       19           
  Lines         738      738           
=======================================
  Hits          533      533           
  Misses        138      138           
  Partials       67       67           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5da494...92a9843. Read the comment docs.

Copy link
Contributor

@harrisonhjones harrisonhjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Left a few comments / questions.

events/apigw.go Outdated
Validity APIGatewayV2HTTPRequestContextAuthenticationClientCertValidity `json:"validity"`
}

// APIGatewayV2HTTPRequestContextAuthentication contains authentication context information for the request caller including client certificate information if using mTLS..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick: here and elsewhere there is an unnecessary extra . at end of doc comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the extra .

events/apigw.go Outdated
@@ -189,10 +190,46 @@ type APIGatewayWebsocketProxyRequestContext struct {
Status string `json:"status"`
}

// APIGatewayCustomAuthorizerRequestTypeRequestIdentity contains identity information for the request caller.
// APIGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidity contains certificate validity information for the request caller if using mTLS..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer for definitions to read top to bottom in the order they are used. In this case that would mean that each of your new types would only come after they were first used. Could we make that update here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the order of definitions to match project conventions.

events/apigw.go Outdated
Comment on lines 195 to 196
NotAfter string `json:"notAfter"`
NotBefore string `json:"notBefore"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these are timestamps. I'm not entirely sure what we do elsewhere in this package but maybe these could be time.Times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to find a way to convert the time format of the validity dates in the JSON unmarshalling not of the Tag hints I could find seam to work. I don't think writing a custom unmarshalling routine would be appropriate but am open to suggestion.

Time string `json:"time"`
TimeEpoch int64 `json:"timeEpoch"`
HTTP APIGatewayV2HTTPRequestContextHTTPDescription `json:"http"`
Authentication APIGatewayV2HTTPRequestContextAuthentication `json:"authentication"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is optional right? Or is it always supplied now by API GW?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supplied by API GW when mTLS is configured, otherwise it will be ignored since we are just unmarshalling.

events/apigw.go Outdated
SourceIP string `json:"sourceIp"`
APIKey string `json:"apiKey"`
SourceIP string `json:"sourceIp"`
ClientCert APIGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert `json:"clientCert"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is optional right? Or is it always supplied now by API GW?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supplied by API GW when mTLS is configured, otherwise it will be ignored since we are just unmarshalling.

@queeno
Copy link

queeno commented May 19, 2021

Are you planning to merge and release this PR soon?

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2021

Codecov Report

Merging #342 (87559da) into master (5d64132) will not change coverage.
The diff coverage is n/a.

❗ Current head 87559da differs from pull request most recent head bc8a460. Consider uploading reports for the commit bc8a460 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #342   +/-   ##
=======================================
  Coverage   72.22%   72.22%           
=======================================
  Files          19       19           
  Lines         738      738           
=======================================
  Hits          533      533           
  Misses        138      138           
  Partials       67       67           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d64132...bc8a460. Read the comment docs.

@kpes
Copy link

kpes commented Jun 28, 2021

@harrisonhjones @dum0nt73 Any chance this could be merged soon?

@dum0nt73
Copy link
Contributor Author

dum0nt73 commented Jul 3, 2021

@kpes , I have requested the review to have it merged just waiting now. Hopefully they will approve it soon.

Copy link
Contributor

@carlzogh carlzogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks @dum0nt73

@carlzogh carlzogh merged commit 159d1c6 into aws:master Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants