-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
TrustStore support for OIDC and OIDCClient #18012
Conversation
9690f29
to
7eb1648
Compare
keycloak = new GenericContainer<>(keycloakDockerImage) | ||
.withExposedPorts(8080, 8443) | ||
.withEnv("DB_VENDOR", "H2") | ||
.withEnv("KEYCLOAK_USER", "admin") | ||
.withEnv("KEYCLOAK_PASSWORD", "admin") | ||
.waitingFor(Wait.forHttp("/auth").forPort(8080)); | ||
|
||
if (KEYCLOAK_USE_HTTPS && KEYCLOAK_TRUSTSTORE_REQUIRED) { | ||
keycloak = keycloak.withClasspathResourceMapping(KEYCLOAK_TLS_KEY, KEYCLOAK_TLS_KEY_MOUNTED_PATH, |
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.
@pedroigor is it the right way to mount a key ? I've read in in a rather old Stackoverflow that this is how it should be done, but I'm not sure it is still the case, the test does not work
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.
@pedroigor I have not seen in the latest docs any references to a private key having to be mounted to /etc/x509/http/tls.key
, it is only mentioned in the non up to date docs. I wonder what the current approach is - mounting a private key should lead to WildFly converting it to a keystore, but perhaps now an actual keystore file should be mapped ?
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.
Perhaps it should be /etc/x509/https/tls.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.
@pedroigor thanks, the docs at https://hub.docker.com/r/jboss/keycloak/ do refer to /etc/x509/https
.
I'm pretty sure some progress has been made as a result since now I'm seeing in the logs:
Creating HTTPS keystore via OpenShift's service serving x509 certificate secrets..
HTTPS keystore not created at: /opt/jboss/keycloak/standalone/configuration/keystores/https-keystore.jks (check permissions?)
I've checked, this error is not logged if the path is wrong (http
in /etc/x509/http/tls.key
).
The section at https://hub.docker.com/r/jboss/keycloak/ points out at the possible problem.
The permissions for both tls.crt
and tls.key
are r
for the world on my system.
Host mounting them with withClasspathResourceMapping
or copying to the docker (.withCopyFileToContainer
) makes no difference though....
But it is nearly there, we just need to see how it is done in some working deployments
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.
@pedroigor @rvansa the example here shows how these files are mapped with the specific user/group ids and also the mode. TestContainers
does now allow to set it when mounting the files.
I've also seen somewhere setting the mode to 655
on the local system before mounting the files should work - but I could not make it work.
7eb1648
to
053647b
Compare
@rvansa Would you like to try this PR against your deployment ? If we'll have problems verifying it with the test then I guess we can just merge it without it if you confirm it works for you, though the test should really be done :-) |
@sberyozkin Hi, thanks a lot for the fix. I'll try to verify it soon but I have pretty full hands this week and the next one I won't be available, so have some patience please. |
@rvansa Sounds good :-), I'll be off next week myself, thanks |
I'll try to put that on my list as well since we also have to use TLS to talk to our Keycloak container and in dev env we also use custom certs. |
0b721fd
to
e0c17dd
Compare
I haven't yet gotten around to testing this but I have it on my list for this week. Would be great to have this end up in Quarkus 2.1 Btw, |
@famod Thanks, I believe you meant |
I was actually thinking of the next step that would be client cert auth (for mutual TLS). |
OK |
e0c17dd
to
1c5a9e1
Compare
@sberyozkin Sorry, didn't have the time yet to look at it. Do you think its still realistic to get this into 2.1? |
@famod, np at all - we need at least a single confirmation this PR actually helps - I can try to experiment as well, haven't had time yet; so not sure if it can make it, I believe it would be safe to backport though |
@famod Hi, I've managed to verify this code against a standalone Keycloak instance, by following Server installation Guide and also updating a custom realm configuration to require SSL for all the requests as described here. I copied the JKS file used in this PR, here are the relevant fragment:
and
I've also had to add a new enum, Finally I've tweaked
and it worked. I've temporarily disabled though the test resource factory code which sets up the trust store, I'll open an issue afterwards to try and get the test running, I've found another resource: which suggests that the test factory does exactly the same thing by mounting the key and cert, but something just does not click - all these docs refer to the old image, so it needs some support from the KC guys. Have a look please and I'll merge once you approve |
1c5a9e1
to
90243f7
Compare
90243f7
to
715ccdb
Compare
I have just started testing this PR with my current Quarkus project (that incorporates KC). |
@sberyozkin Hum...it seems like I'm hitting a wall here as I keep getting:
I seems as if the entry in my store is not taken into account. It does find the store though because settings some invalid value for I even tried setting the alias. |
Nevermind, the store was missing our custom CA cert (it only contained the actual server cert). I will conclude my review tomorrow. |
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.
Works in my project/setup and code LGTM.
I'll trust you on that test factory part @sberyozkin 🙂, didn't have a look at it myself.
I'll mark this for backport and see how it goes.
I read that a bit wrong and merged it already but I don't think it matters who merges in the end. 😉 |
@famod cool, thanks for checking it (I just came here to mention that |
@famod in the next iteration we can wire in a mutual tls authentication, will have a look later on |
Fixes #18002.
This draft PR adds support for configuring OIDC, OIDC client and also Keycloak authorization with the trust store file/password - property names are the same as in Vert.x HTTP, we can add more related properties as needed (alias, etc).
CC @rvansa