-
Notifications
You must be signed in to change notification settings - Fork 12
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
Revoke apple token usage #7
Open
RasDeaks
wants to merge
5
commits into
FroMage:main
Choose a base branch
from
RasDeaks:revokeApple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2b31629
revoke apple user access using renarde 3.0.12 SNAPSHOT (conf and priv…
RasDeaks 773c90f
add integration test for /apple-revoke resource
RasDeaks e0fd798
revert unused property
RasDeaks 7dc78af
review: typo on RenardeRevokeController
RasDeaks 44dd4b4
review: update integration test to check 'q_session' cookie after rev…
RasDeaks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,6 +357,67 @@ public void appleLoginTest() { | |
"Foo", "Bar", "AppleUser", "[email protected]", "q_session_apple"); | ||
} | ||
|
||
@Test | ||
public void appleRevokeTest(){ | ||
// GIVEN a registered apple user | ||
RenardeCookieFilter cookieFilter = new RenardeCookieFilter(); | ||
ValidatableResponse response = follow("/_renarde/security/login-apple", cookieFilter); | ||
JsonPath json = response.statusCode(200) | ||
.extract().body().jsonPath(); | ||
String code = json.get("code"); | ||
String state = json.get("state"); | ||
|
||
String location = given() | ||
.when() | ||
.filter(cookieFilter) | ||
.formParam("state", state) | ||
.formParam("code", code) | ||
// can't follow redirects due to cookies | ||
.redirects().follow(false) | ||
// must be precise and not contain an encoding: probably needs fixing in the OIDC side | ||
.contentType("application/x-www-form-urlencoded") | ||
.log().ifValidationFails() | ||
.post("/_renarde/security/oidc-success") | ||
.then() | ||
.log().ifValidationFails() | ||
.statusCode(302) | ||
.extract().header("Location"); | ||
follow(location.replace("https://", "http://"), cookieFilter) | ||
.body(containsString("Complete registration for [email protected]")); | ||
|
||
// WHEN Revoke access | ||
List<String> setCookieHeaderResp = given() | ||
.when() | ||
.filter(cookieFilter) | ||
.redirects().follow(false) | ||
.get("/_renarde/security/apple-revoke") | ||
.then() | ||
.statusCode(303) | ||
.extract().headers() | ||
.getValues("Set-Cookie"); | ||
|
||
// THEN Cookie is reset (no more QuarkusUser nor apple session) | ||
String userLogoutCookie = setCookieHeaderResp.stream() | ||
.filter(c -> c.startsWith("QuarkusUser=")) | ||
.findFirst() | ||
.orElseThrow(); | ||
Assertions.assertEquals("QuarkusUser=;Version=1;Path=/;Max-Age=0", userLogoutCookie); | ||
String userSessionCookie = setCookieHeaderResp.stream() | ||
.filter(c -> c.startsWith("q_session_apple=")) | ||
.findFirst() | ||
.orElseThrow(); | ||
Assertions.assertEquals("q_session_apple=;Version=1;Path=/;Max-Age=0", userSessionCookie); | ||
|
||
// THEN Secure page will redirect to login | ||
Assertions.assertTrue( | ||
given().when().filter(cookieFilter) | ||
.redirects().follow(false) | ||
.get("/Todos/index") | ||
.then() | ||
.statusCode(302).extract().header("Location") | ||
.endsWith("Login/login")); | ||
} | ||
|
||
private void finishConfirmation(RenardeCookieFilter cookieFilter, String confirmationCode, | ||
String firstName, String lastName, String userName, String email, | ||
String cookieName) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this is the right thing to show/do.
The original requirement from Apple is that it be possible to delete an account, and that deleting an account should revoke the tokens.
So I don't think this is the functionality we should expose, as it does not delete the local account (the
User
instance in the DB).There should be an option to delete your account, probably with an intermediate page with a "Are you really sure?" button, and that should delete the account, and revoke the tokens, no?
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, we must also delete the user on our db, not only the apple access.
Don't you think we need an User detail page to place this new button (and not in the top menu) ?
For instance, a link on the user name in the top bar that open a page which display user info plus a revoke/delete account button.
Also, I'll need a custom endpoint on this Todo project to handle de DB deletion of the user. I can do that.
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.
Oh, sorry, I missed this.
Yes, you're right, it makes sense to add an account page, and put the
delete
button there.