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

feat: Only pass state if it was set #2183

Merged
merged 1 commit into from
Nov 19, 2020
Merged

feat: Only pass state if it was set #2183

merged 1 commit into from
Nov 19, 2020

Conversation

jaylinski
Copy link
Contributor

@jaylinski jaylinski commented Nov 18, 2020

Related issue

I didn't open an issue because I prefer to directly show the problem by submitting a PoC.

Proposed changes

Using state in the logout flow is optional, so state can be
empty. In order to avoid an ugly /post-logout-redirect-uri?state=
URI, the state should only be appended if it is not empty.

Relevant specification: https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout

Checklist

  • I have read the contributing guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security. vulnerability, I
    confirm that I got green light (please contact
    security@ory.sh) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further comments

If you are willing to accept this change, I'll add tests (and fix the typo in the commit).

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2020

CLA assistant check
All committers have signed the CLA.

@aeneasr
Copy link
Member

aeneasr commented Nov 18, 2020

Thank you for your contribution! Could you please provide a reference to the specification where this is defined?

@jaylinski jaylinski changed the title Only pass state if it was set consent: Only pass state if it was set Nov 18, 2020
@jaylinski
Copy link
Contributor Author

jaylinski commented Nov 18, 2020

Thank you for your contribution! Could you please provide a reference to the specification where this is defined?

@aeneasr It is specified here: https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout

@jaylinski jaylinski changed the title consent: Only pass state if it was set feat: Only pass state if it was set Nov 18, 2020
@aeneasr
Copy link
Member

aeneasr commented Nov 18, 2020

Looking good, thank you! Could you maybe also add a test to prevent regressions here?

Using `state` in the logout flow is optional, so `state` can be
empty. In order to avoid an ugly `/post-logout-redirect-uri?state=`
URI, the state should only be appended if it is not empty.
subject: "logout-subject-7",
expectBody: "redirected to default servercustom",
expectRequestURI: "/custom",
},
Copy link
Contributor Author

@jaylinski jaylinski Nov 18, 2020

Choose a reason for hiding this comment

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

An alternative would be to remove the state value from expectBody and instead add the expectRequestURI to all test-cases.


if tc.expectRequestURI != "" {
assert.EqualValues(t, tc.expectRequestURI, resp.Request.URL.RequestURI(), "%s\n%s", resp.Request.URL.String(), out)
}
Copy link
Contributor Author

@jaylinski jaylinski Nov 18, 2020

Choose a reason for hiding this comment

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

The if could be removed if expectRequestURI would be added to all test-cases.

@jaylinski
Copy link
Contributor Author

Looking good, thank you! Could you maybe also add a test to prevent regressions here?

@aeneasr I added a test case. Please review. :octocat:

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Awesome 🎉

Thank you for your contribution!

@aeneasr aeneasr merged commit 568434a into ory:master Nov 19, 2020
@jaylinski jaylinski deleted the patch-1 branch November 19, 2020 16:05
@jaylinski
Copy link
Contributor Author

@aeneasr Thanks for this nice piece of software! 🙌 Greetings from Linz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants