-
Notifications
You must be signed in to change notification settings - Fork 22
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
Bugfix/43 Apple revoke use-case #205
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for the contrib, let's wait for @sberyozkin 's answer on Zulip before we figure out where to take this.
.statusCode(303) | ||
.extract().headers() | ||
.getValues("Set-Cookie") | ||
.stream().filter(c -> c.startsWith("QuarkusUser=")).findFirst().get(); |
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 assume this should also make sure that the q_session_apple
cookie is cleared as well.
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.
That's right, it's an oversight. I just updated the test to check that. I did the same on the 'Todos' demo.
oidc/src/main/java/io/quarkiverse/renarde/oidc/impl/RernardeRevokeController.java
Outdated
Show resolved
Hide resolved
@Path("apple-revoke") | ||
@Authenticated | ||
public Response revokeApple() { | ||
String clientSecret = Jwt.audience("https://appleid.apple.com") |
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 feel like this is the sort of thing Quarkus OIDC should be able to give us, since it has all that config.
.keyId(appleOidcKeyId) | ||
.algorithm(SignatureAlgorithm.ES256) | ||
.sign(getPrivateKey(appleKeyFile)); | ||
renardeAppleClient.revokeAppleUser(appleClientId, clientSecret, accessToken.getToken(), "access_token"); |
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 we also need to revoke the refresh token? The docs do mention it.
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 thought we had choice, using the access token OR the refresh token. I might be wrong. Do you think I should make a double call to this endpoint, one for each ? Starting with the refresh_token ?
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 am not sure, TBH. But it looks like the docs mention having to revoke both, no? In theory, the way it works, the refresh token (if there is one) is longer-lived than the access token. But if you're logged in, both must be valid.
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'll read again and make some test, if needed, I'll add this second call.
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.
Since the refresh token is supposed to be longer-lived than the access token it must be invalidated as well. I just added that part.
I also added a check for the tenant id on the back-end side.
|
||
private PrivateKey getPrivateKey(String filename) { | ||
try { | ||
String content = Files.readString(Paths.get("target/classes/" + filename)); |
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 pretty sure this is where we should fetch it from. In fact, for native compiled or packaged production applications, this folder will not exist. This will only work in DEV mode, I think.
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've tried using quarkus-run.jar
and it was ok but you must be right. Unfortunatelly I didn't find a better solution. I guess quarkus-oidc lib got something to help on that as it already read this file. WDYT ?
@RasDeaks It is a nicely done PR, but indeed, hopefully we can get Quarkus do it for Renarde, as @FroMage also suggests. At the moment, the option which will work is to configure OIDC client, for example:
and then in the controller:
The above should handle it, the revocation endpoint is expected to be discovered because Apple supports it and therefore it should be included in the discovery doc. But I was thinking that may be
So may be we can have something like:
How about that ? That would be the simplest option for sure. Or if you prefer to handle the revocation and the local session cookie deletion separately, we can do:
|
Thanks for your help @sberyozkin , |
Thanks @RasDeaks for the feedback on Zulip. Indeed, having a standalone If it can be of interest, then please open a Quarkus enhancement request and work on the PR ( |
@RasDeaks I was just typing my response and noticed your comment. It would be great if you could look at the Quarkus enhancement, it should be an interesting PR to look at, we can help you with Steph along the way |
Hello!
I've tried to implements the revocation use-case, it contains :
See FroMage/quarkus-renarde-todo#7 for usage.
Let me know if this helps, I'd be glad to contribute. I'm open for reveiw, I can update my work if needed.