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

Jwks #59

Merged
merged 34 commits into from
Dec 3, 2021
Merged

Jwks #59

merged 34 commits into from
Dec 3, 2021

Conversation

antonioT90
Copy link
Contributor

List of changes

jwks file generation with jwt certificate

Motivation and context

Type of changes

  • Add new resources
  • Update configuration to existing resources
  • Remove existing resources

Env to apply

  • DEV
  • UAT
  • PROD

Does this introduce a change to production resources with possible user impact?

  • Yes, users may be impacted applying this change
  • No

Does this introduce an unwanted change on infrastructure? Check terraform plan execution result

  • Yes
  • No

Other information


If PR is partially applied, why? (reserved to mantainers)

@antonioT90 antonioT90 requested a review from a team November 26, 2021 22:58
Comment on lines 250 to 255
key_properties {
exportable = true
key_size = 2048
key_type = "RSA"
reuse_key = true
}
Copy link
Member

Choose a reason for hiding this comment

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

maybe it's better an EC algorithm or more length RSA key 4096

Copy link
Member

@pasqualedevita pasqualedevita Nov 29, 2021

Choose a reason for hiding this comment

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

@pp-ps have u a suggestion for algorithm/key length?

Copy link

@pp-ps pp-ps Nov 29, 2021

Choose a reason for hiding this comment

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

As long as the call to forge a token (signed with this key) is authenticated and observable in metrics, I don't have any strong bias against RSA. EC verification (for receiveing systems) is much more expensive.

RSA 2048 bit looks fine too, as long as the key is periodically rotated (1y?, let's think about it as if it's an expiring certificate)

What I find strange is the choice to pack everything in a azurerm_key_vault_certificate. Why can't we use a azurerm_key_vault_key?

Copy link
Member

@pasqualedevita pasqualedevita Nov 29, 2021

Choose a reason for hiding this comment

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

@antonioT90 can u try to use azurerm_key_vault_key?
with azurerm_key_vault_key u can retrieve
n - The RSA modulus of this Key Vault Key
e - The RSA public exponent of this Key Vault Key
and remove python script

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_key#attributes-reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pasqualedevita i'm not able to retrieve the private key generated using key_vault_key, we need it in order to firm JWT token in hubSpidLogin application

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same answer to @pp-ps! the use of key_vault_key will not allow me to read the private key generated

the use of azurerm_key_vault_certificate is due to transform the private and public keys into a X509 certificate, simplifying the calculation of thumbprint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

regarding the rotation of the keys, there is a problem due to the inability to replace a previous version of a key: actually I obtain an error due to the safe delete feature enabled which will not allow to perform a delete and purge of previous value...

@pasqualedevita pasqualedevita requested a review from pp-ps November 29, 2021 11:17
Copy link
Member

@pasqualedevita pasqualedevita left a comment

Choose a reason for hiding this comment

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

LGTM, @pp-ps ?

@pp-ps
Copy link

pp-ps commented Dec 3, 2021

I hear we need to speed up deployment of this, let's go ahead and refactor later.

  • line 46 in jwksFromPems.py is way too complex
  • if we move away from self-signed certs, we can avoid PEMs and so x5c and x5t (use raw keys)

Approving for now.

@antonioT90 antonioT90 merged commit 82a5ba8 into main Dec 3, 2021
@antonioT90 antonioT90 deleted the jwks branch December 3, 2021 10:48
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.

3 participants