-
Notifications
You must be signed in to change notification settings - Fork 170
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
[THREESCALE-11019] - FAPI advance profile #1466
[THREESCALE-11019] - FAPI advance profile #1466
Conversation
4ae0eef
to
ce1e153
Compare
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.
Great job 🎖️
Before approval, let me do some questions to clarify:
- APIcast does not validate the client (downstream) certificate as regular validation, it only does validation specified in OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens. Am I right? If so, shouldn't APIcast validate the certificate as well (it would require cacerts that signed the client cert)?
- In the verification steps, there is an unknown "keycloak_mtls.json". Maybe leftovers of past tries?
- In the verification steps,
make gateway
command is missing. (which somewhat important :) ) - The verification steps tell that the created client should have enabled the "OAuth 2.0 Mutual TLS Certificate Bound Access Token". Is this really necessary? Maybe it is the setting that adds the
cnf
claim to the JWT? - There is no user generated in keycloak. That means that there is no need for users in keycloak and the client cert is enough as user ID? If so, any user with a certificate signed with the same cacert defined for keycloak can get the token?
- The verification steps miss the client configuration "allow regexp pattern"
- I wonder if this "OAuth 2.0 Mutual TLS Certificate Bound Access Token" use case deserves its own dev env. Mainly because if I want to reproduce this, I would need to come back to this PR and re-do the verification steps. If not dev-env, maybe developer oriented readme?? what do you think?
- No need to get the APICast IP, just need to update the docker-compose.yml and add 8443 port to the gateway service:
ports:
- "8080:8080"
- "8090:8090"
+ - "8443:8443"
According to the spec, we only need to verify the thumbprint. And I think user can use TLS Client Certificate Validation if they wish to validate the certificate.
Yes it is the settings that will calculate the certificate hash and adds
I believe so, FAPI spec also pointed it out as below:
Fixed
Agree
👍 |
20dce47
to
97401f1
Compare
What
This PR support https://issues.redhat.com/browse/THREESCALE-11019.
Verification steps:
Prepare certificates
Generate CA certificate
changeit
as keystore passwordGenerate a certificate signing request (CSR) for the HTTPS keystore.
yes
toTrust this certificate? [no]:
questionWe can verify the certificates are imported with below command.
Generate client certificate
Generate APIcast certificates
Repeat the step above and generate the client certificate
Once the certificate are generated, we are ready to deploy Keycloak
Deploy
https://localhost:9443
admin:adminpass
basic
realmClients -> Create client
Credentials
tab and selectX509 Certificate
asClient Authenticator
Subject DN
, in this test we use(.*?)(?:$)
. Then clickSave
Advanced
tab, and then scroll down toAdvance settings
and enableOAuth 2.0 Mutual TLS Certificate Bound Access Token
-> clickSave
Request token
Now we have everything set up, we can use curl to authenticate with the client certificate to get the access token.
If we decode this token using jwt.io, we can see the payload has the
cnf
claim and its value is certificate sha256 thumbprint. The resource server (APIcast) will use this thumbprint to validate if the same user is making the request. For example:Now we are ready to test
Request should failed with
{"error": "invalid_token"}
Request should return 200