-
Notifications
You must be signed in to change notification settings - Fork 2.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
Generate RSA-256 keys on dev mode #44272
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
Hey @mcruzdev Thanks for giving it a try, indeed, we'd like to make it easy for But what should really be done is that none of those properties should be required in devmode, no any temporary files should be created... If The code which will generate tokens using the published private key @michalvavrik, do you recall which build item can be used to report build time properties ? (smallrye-jwt ones related to keys are currently build time only...) |
If this https://github.com/smallrye/smallrye-jwt/blob/74638c415a0096e1916363e51571e6ed4aecf8d2/implementation/jwt-auth/src/main/java/io/smallrye/jwt/config/JWTAuthContextInfoProvider.java#L219 is the only place where this property is used, then I'd expect returning them from |
Hi @sberyozkin, was necessary to get the properties (*.location) from the user, because I do not know how to change configuration values on build time, I think that config is read-only. I will try the customizer here. |
Thank you, it works! Now I will continue here... |
🎊 PR Preview 98942f6 has been successfully built and deployed to https://quarkus-pr-main-44272-preview.surge.sh/version/main/guides/
|
.../deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtBuildTimeConfig.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...ye-jwt/deployment/src/main/java/io/quarkus/smallrye/jwt/deployment/SmallRyeJwtProcessor.java
Outdated
Show resolved
Hide resolved
...-jwt/deployment/src/test/java/io/quarkus/jwt/test/devmode/KeyPairOutOfTheBoxDevModeTest.java
Outdated
Show resolved
Hide resolved
...-jwt/deployment/src/test/java/io/quarkus/jwt/test/devmode/KeyPairOutOfTheBoxDevModeTest.java
Outdated
Show resolved
Hide resolved
...-jwt/deployment/src/test/java/io/quarkus/jwt/test/devmode/KeyPairOutOfTheBoxDevModeTest.java
Outdated
Show resolved
Hide resolved
...-jwt/deployment/src/test/java/io/quarkus/jwt/test/devmode/KeyPairOutOfTheBoxDevModeTest.java
Outdated
Show resolved
Hide resolved
Thanks @mcruzdev, IMHO it will be a nice addition, I've left a few comments, but it all is going well, thanks for the effort, and please take your time to address the comments |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
||
private static String getStringKey(Key key) { | ||
return Base64.getEncoder() | ||
.encodeToString(key.getEncoded()); |
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 don't know that part of the codebase, but is this intended to be a PEM format?
RSA Key needs to use PKCS#1 format.
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 @cescoffier It is intended to be a PEM format. mp.jwt.verify.publickey
uses it, see here.
EDIT: intended to be a base64 encoded key
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.
ok, this is NOT PEM format :-) This is just a base64 encoded key.
If you want PEM format you need the header and footer explaining what's the content (RSA KEY, PRIVATE KEY ...)
I agree with @FroMage about generating a proper PEM file (Be aware, this is a trap) in the output directory (target or build) so it can be reused between runs and used for both test and dev. Now, generating a proper PEM file can be tricky because there are several formats: PKCS#1, PKCS#8, PKCS#7., SEC1 (EC)... Also, I learned that PKCS#8 can be encrypted. In this case, I would just pick one (but the runtime would need to support most of them, if not all) |
Hi @FroMage
Well, our plan is to offer a DevUI support for Also, while You say users spent most of their time in devmode, but in devmode one does not cold-stop the server, usually we do it if something goes wrong with the live coding. What is the scenario that you have in mind where a server is cold-stopped when the authenticated user is around ? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@FroMage, @sberyozkin any update about this one? We have a direction to follow? |
Just rebase on the latest quarkus |
9188ea0
to
576482a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Works @FroMage, TY! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
LGTM, although I'd still prefer this would be stored in a file to survive restarts 🤷
This comment has been minimized.
This comment has been minimized.
I'll try to test this PR soon, thanks @mcruzdev |
Perfect @sberyozkin, I am excited to continue the improvement on devx :) |
5d62732
to
51d2494
Compare
Status for workflow
|
Status for workflow
|
Description
Fixes #44179
This PR aims to add on DEV mode, to generate a RSA-256 pair key.
It is great for development and test environments, the user just need to set two 3 config properties:
Status: In progress