-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(hmac-auth) add support for RSA signatures #8530
Conversation
The hmac-auth plugin allow authentication with HMAC signatures based on the draft-cavage-http-signatures draft. This commit aims to add support for RSA signatures as described in the draft, providing a stronger layer of security via asymmetric encryption. This implementation has been made with backward compatibility in mind and only one new field has been added to the DAOs to store the RSA public key. Depending on the algorithm used during the request, the plugin will use either the HMAC secret or the RSA public key to verify the signature.
deab67e
to
d7a471d
Compare
The branch has been rebased following 88abdb8, which created some conflicts. |
@@ -17,6 +17,7 @@ return { | |||
{ consumer = { type = "foreign", reference = "consumers", required = true, on_delete = "cascade", }, }, | |||
{ username = { type = "string", required = true, unique = true }, }, | |||
{ secret = { type = "string", auto = true }, }, | |||
{ public_key = { type = "string" }, }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change for version compatibility with older data planes; updates will need to be made to the compatibility layer to handle these changes ahead of time of before a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand what needs to be updated. You linked to a file named removed_fields.lua
but no field has been removed, only added. I've checked in the folder if there was a file named added_fields.lua
but could not find any. I've also checked other PR doing similar changes on the configuration and could not find any modification related to the compatibility layer.
Could you provide more informations on what needs to be done exactly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mideuger This is something that will need to be handled closer to release time when this feature is targeting a particular version of Kong Gateway; I just wanted to mark this PR as something that is going to need further testing and updates when it comes to release time.
I've also checked other PR doing similar changes on the configuration and could not find any modification related to the compatibility layer.
Since you are adding a new field to the hmac-auth
plugin, older data planes will not know how to process this field when it is transmitted in the payload in hybrid mode. To allow for newer control planes to interoperate with older data planes the field public_key
needs to be removed before the payload is sent down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
]], | ||
}, | ||
cassandra = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, cassandra is not supported at present, it might be removed from this commit. Otherwise it will report error:
with kong 3.4+ or kong latest master branch
(kong-dev) xc kong-ee $ kong start
Error: [PostgreSQL error] [PostgreSQL error] migration 'kong.plugins.hmac-auth.migrations.004_add_public_key
' of 'hmac-auth' subsystem is invalid: schema violation (cassandra: unknown field)
Run with --v (verbose) or --vv (debug) for more details
(kong-dev) xc kong-ee $ kong migrations bootstrap
Error: [PostgreSQL error] [PostgreSQL error] migration 'kong.plugins.hmac-auth.migrations.004_add_public_key
' of 'hmac-auth' subsystem is invalid: schema violation (cassandra: unknown field)
Run with --v (verbose) or --vv (debug) for more details
TODO
|
I found that we have an updated pr here: #11133 @hanshuebner |
Closing in favor of #11133 |
Summary
The hmac-auth plugin allow authentication with HMAC signatures based on the draft-cavage-http-signatures draft.
This commit aims to add support for RSA signatures as described in the draft, providing a stronger layer
of security via asymmetric encryption.
Full changelog
algorithms
(rsa-sha256
andrsa-sha512
)public_key
)rsa
algorithmsHow to test
First, create a RSA key pair :
Then, enable the plugin, create a consumer and a corresponding credential with the public key :
Finally, make a signed request :
Possible improvements
Here are some improvements that we might want to implement after this one :
HTTP Signature
Signature
header to provide the signature (or let it be configurable)keyId
from the draft