Skip to content
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

Add config to control whether to perform "OpenID Connect RP-Initiated Logout" when using an external OIDC provider #2590

Merged
merged 7 commits into from
Nov 15, 2023

Conversation

peterhaochen47
Copy link
Member

@peterhaochen47 peterhaochen47 commented Nov 6, 2023

Fixes #2589

Notes for reviewer:

  • refactors of the impacted classes/code path will be in a different PR, so this PR would be easier to review.
  • reasons for the config name performRpInitiatedLogout:
    • The exact language of the spec
    • Follow the pattern of the other boolean configs of this endpoint: starting with a verb
    • alternatives considered: SSOLogout, performSSOLogoutOnIdpAfterUAALogout, triggerExternalOIDCProviderLogout etc.

@peterhaochen47 peterhaochen47 added the DO NOT MERGE Internal Test or WIP, please DO NOT MERGE label Nov 6, 2023
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/186419332

The labels on this github issue will be updated when the story is started.

- Add test coverage on the existing behavior described in
  #2589 where UAA attempts to
  log the user out of the external OIDC provider after a successful UAA
  logout (this is called the RP initiated logout)

[#184752215]
@peterhaochen47 peterhaochen47 force-pushed the pr/develop/rp-initiated-logout-config branch from 677283f to 388ecbc Compare November 7, 2023 00:00
@peterhaochen47 peterhaochen47 changed the title [DRAFT] Add config for "OpenID Connect RP-Initiated Logout" when using an external OIDC provider [DRAFT] Add config to control "OpenID Connect RP-Initiated Logout" when using an external OIDC provider Nov 7, 2023
@peterhaochen47 peterhaochen47 changed the title [DRAFT] Add config to control "OpenID Connect RP-Initiated Logout" when using an external OIDC provider [DRAFT] Add config to control whether to perform "OpenID Connect RP-Initiated Logout" when using an external OIDC provider Nov 7, 2023
@peterhaochen47 peterhaochen47 force-pushed the pr/develop/rp-initiated-logout-config branch from 388ecbc to 1f895f6 Compare November 7, 2023 00:02
- New config "performRpInitiatedLogout" (default to true to preserve existing behavior)
added to /identity-providers API and uaa.yml. It is a flag controlling whether to log out of
the external provider after a successful UAA logout
per [OIDC RP-Initiated Logout](https://openid.net/specs/openid-connect-rpinitiated-1_0.html)"
- doc changes

[more context: #2589]
[#184752215]
@peterhaochen47 peterhaochen47 force-pushed the pr/develop/rp-initiated-logout-config branch from 1f895f6 to c4b2118 Compare November 7, 2023 02:46
Copy link
Contributor

@bruce-ricard bruce-ricard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite confident that the change works as expected.

Just added a few minor readability comments inline.

Comment on lines 563 to 583
@Test
public void successfulUaaLogoutTriggersExternalOIDCProviderLogout() {
validateSuccessfulOIDCLogin(zoneUrl, testAccounts.getUserName(), testAccounts.getPassword());

String externalOIDCProviderLoginPage = baseUrl;
webDriver.get(externalOIDCProviderLoginPage);
Assert.assertThat("URL validation failed", webDriver.getCurrentUrl(), endsWith("/login"));
}

@Test
public void successfulUaaLogoutDoesNotTriggerExternalOIDCProviderLogout_whenConfiguredNotTo() {
identityProvider.getConfig().setPerformRpInitiatedLogout(false);
updateProvider();

validateSuccessfulOIDCLogin(zoneUrl, testAccounts.getUserName(), testAccounts.getPassword());

String externalOIDCProviderLoginPage = baseUrl;
webDriver.get(externalOIDCProviderLoginPage);
Assert.assertThat(webDriver.getPageSource(), containsString("Where to?"));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand which part of the tests check whether the OIDC logout is triggered or not.

It appears that you are testing that through the currentUrl and the PageSource of the webDriver?

If the integration tests aren't more precisely checking that we are indeed logged in/our of the OIDC provider, I don't really see the added value compared to the tests in ZoneAwareWhitelistLogoutHandlerTests.java

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        webDriver.get(externalOIDCProviderLoginPage);
        Assert.assertThat("URL validation failed", webDriver.getCurrentUrl(), endsWith("/login"));

^ This is going to the external OIDC provider login page (which is also a UAA), and verifies that you are redirected to the UAA /login endpoint. (which only happens if the user is unauthenticated/logged-out).

        Assert.assertThat(webDriver.getPageSource(), containsString("Where to?"));

This "Where to?" string only shows up on the external OIDC provider login page (which is also a UAA), if you are still logged in as an authenticated user.

I understand that this way of checking is sort of hard to read, but it's consistent with how we perform the same type of check elsewhere. The "page object" refactor sort of addresses this readability issue by including this check inside of page objects, but I don't wanna include the page objects refactor in this PR, but I make it easy to perform that refactor in the future.


String externalOIDCProviderLoginPage = baseUrl;
webDriver.get(externalOIDCProviderLoginPage);
Assert.assertThat("URL validation failed", webDriver.getCurrentUrl(), endsWith("/login"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide to add "URL validation failed" as the response to a failed assertion here? I don't feel like that's going to help debug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just following the newest existing pattern brought by the "page objects" refactor. I assumed there's some benefit to this pattern? At least shouldn't harm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't like the word "validation" in this context.

shouldn't harm

I feel like the word "validation" shouts "I'm not test code". In test code we typically "assert", "test", "check". Validation is IMO when typically when real production code needs to validate something before doing something else with it.
It "harmed" my understanding when I read the code at first. I was thinking that it was a bad copy and paste from some functional code. I didn't think we could validate in tests.

@swalchemist what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should improve that message. We should only add these assertion messages if there's no better way to improve our understanding of what the test is doing and/or what happens when it fails.

In this case, I think "We're at the right URL" works better as the message, e.g., "AssertThat ... we're at the right URL."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, how about for the purpose of this PR, I'll forget about refactoring to using the shared "validateUrl" function in the future, and just formulate a reason param that works for the test here specifically (how about reason = "Not redirected to external OIDC provider login page." as that is what I'm actually testing here), or just taking the reason param out for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit pushed.

- to improve readibility, in test setup, explicitly set "performRpInitiatedLogout"
config to "true" (even though that is the current default)

[#186127119]

String externalOIDCProviderLoginPage = baseUrl;
webDriver.get(externalOIDCProviderLoginPage);
Assert.assertThat("URL validation failed", webDriver.getCurrentUrl(), endsWith("/login"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't like the word "validation" in this context.

shouldn't harm

I feel like the word "validation" shouts "I'm not test code". In test code we typically "assert", "test", "check". Validation is IMO when typically when real production code needs to validate something before doing something else with it.
It "harmed" my understanding when I read the code at first. I was thinking that it was a bad copy and paste from some functional code. I didn't think we could validate in tests.

@swalchemist what do you think?

- no need to use the Object Boolean when primitive boolean will do

[#184752215]
@peterhaochen47 peterhaochen47 marked this pull request as ready for review November 8, 2023 00:42
@peterhaochen47 peterhaochen47 changed the title [DRAFT] Add config to control whether to perform "OpenID Connect RP-Initiated Logout" when using an external OIDC provider Add config to control whether to perform "OpenID Connect RP-Initiated Logout" when using an external OIDC provider Nov 8, 2023
@peterhaochen47 peterhaochen47 added in_review The PR is currently in review and removed DO NOT MERGE Internal Test or WIP, please DO NOT MERGE labels Nov 8, 2023
@peterhaochen47 peterhaochen47 removed in_review The PR is currently in review unscheduled labels Nov 9, 2023
Copy link
Member

@strehle strehle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment

- based on Sonar scan suggestion

[#184752215]
type parameters)."

- based on Sonar scan suggestion

[#184752215]
@peterhaochen47 peterhaochen47 merged commit 602e19a into develop Nov 15, 2023
20 checks passed
@peterhaochen47 peterhaochen47 deleted the pr/develop/rp-initiated-logout-config branch November 15, 2023 23:50
peterhaochen47 added a commit to cloudfoundry/uaa-release that referenced this pull request Nov 17, 2023
- a new oidc/oauth provider config "performRpInitiatedLogout" is added
  in cloudfoundry/uaa#2590
- this repo only requires an addition in the example config provided in
  the spec file (since uaa-release passes through the oauth/oidc
  provider config to uaa server verbatim, so no new translation logic
  required when adding a new config on this layer)
- add the field to tests

[#184752215]
peterhaochen47 added a commit to cloudfoundry/uaa-release that referenced this pull request Nov 17, 2023
- a new oidc/oauth provider config "performRpInitiatedLogout" is added
  in cloudfoundry/uaa#2590
- this repo only requires an addition in the example config provided in
  the spec file (since uaa-release passes through the oauth/oidc
  provider config to uaa server verbatim, so no new translation logic
  required when adding a new config on this layer)
- add the field to tests

[#184752215]
peterhaochen47 added a commit to cloudfoundry/uaa-release that referenced this pull request Nov 20, 2023
- a new oidc/oauth provider config "performRpInitiatedLogout" is added
  in cloudfoundry/uaa#2590
- this repo only requires an addition in the example config provided in
  the spec file (since uaa-release passes through the oauth/oidc
  provider config to uaa server verbatim, so no new translation logic
  required when adding a new config on this layer)
- add the field to tests

[#184752215]
@cf-gitbot cf-gitbot added delivered accepted Accepted the issue and removed delivered labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Accepted the issue
Projects
Development

Successfully merging this pull request may close these issues.

No config to turn off "OpenID Connect RP-Initiated Logout" when using an external OIDC provider
5 participants