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: Possibly pass client in logout request #2483

Merged
merged 4 commits into from
May 14, 2021
Merged

Conversation

honzapatCZ
Copy link
Contributor

Related issue

#2468

Proposed changes

I haven't studied the api, but hopefully just extending the response model would work

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.

@CLAassistant
Copy link

CLAassistant commented Apr 22, 2021

CLA assistant check
All committers have signed the CLA.

@honzapatCZ honzapatCZ changed the title Possibly pass client in logout request feat: Possibly pass client in logout request Apr 22, 2021
@@ -22,6 +22,9 @@ type LogoutRequest struct {

// RPInitiated is set to true if the request was initiated by a Relying Party (RP), also known as an OAuth 2.0 Client.
RpInitiated bool `json:"rp_initiated,omitempty"`

// client, only set if rp_initiated
Client *OAuth2Client `json:"client,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

These files are auto-generated, you would need to add that to the actual type ( https://github.com/ory/hydra/blob/master/consent/types.go#L398 ) and of course it also needs to be set and stored!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These files are auto-generated, you would need to add that to the actual type ( https://github.com/ory/hydra/blob/master/consent/types.go#L398 ) and of course it also needs to be set and stored!

OK, the thing is, the client is actually passed, so ory hydra works with it, it just isnt represented in the json form, so I suppose with my latest commit it works now?

Copy link
Member

Choose a reason for hiding this comment

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

No, you still need to set the client somewhere. I suggest adding a test to see if it does what you want!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it already is set here

Client: cl,

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, my bad - these files are auto-generated! What you need to do is to change this line:

Client *client.Client `json:"-" db:"-"`

This will then update that file automatically! The we also need a test to check if the client is actually set in JSON. For example, by doing an assertion here:

require.NotEmpty(t, *v.Payload.RedirectTo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see, my bad - these files are auto-generated! What you need to do is to change this line:

Client *client.Client `json:"-" db:"-"`

This will then update that file automatically! The we also need a test to check if the client is actually set in JSON. For example, by doing an assertion here:

require.NotEmpty(t, *v.Payload.RedirectTo)

I already altered the types.go, but where should I put the test? There's also no test that epxects rp_inititated to be true, which is only case where client would be set.

Copy link
Member

Choose a reason for hiding this comment

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

This test is doing rp_initiated:

t.Run("case=should pass rp-initiated flows", func(t *testing.T) {

You can add the assertion there!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is doing rp_initiated:

t.Run("case=should pass rp-initiated flows", func(t *testing.T) {

You can add the assertion there!

Where exactly? I dont see an assert for rp_initiated, so Iam not sure.

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! 🎉 Your contribution makes Ory better :)

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.

Thank you! This looks better! Could you please add a test to confirm that this is working? The test also must check if client_secret is omitted :) Thank you!

@honzapatCZ
Copy link
Contributor Author

Thank you! This looks better! Could you please add a test to confirm that this is working? The test also must check if client_secret is omitted :) Thank you!

You know I did this change a week ago? Also where should I put the test, there is no test that actually checks for rp_initiated being true, so idk.

@aeneasr
Copy link
Member

aeneasr commented Apr 26, 2021

Not sure I understand? I linked the place where the tests needs to be added already, it is here:

t.Run("case=should pass rp-initiated flows", func(t *testing.T) {

That test is RP Initiated, the call here

body, res := makeLogoutRequest(t, browser, method, url.Values{

so this call

resp, err = hc.Get(publicTS.URL + "/oauth2/sessions/logout?" + values.Encode())

which ends up here

require.NotEmpty(t, *v.Payload.RedirectTo)

and there you have access to the client. I linked these lines of codes already in my comments:

Sorry, but without tests I can't merge things. This is security software and needs thorough testing and good code quality. I know this might be frustrating to keep working on this but it's just the way this repo needs to work to prevent security issues. For example, I suspect that your change would currently expose the client_secret, so we need to add a test.

Maybe I misunderstand but I believe the instructions to be correct and accurate.

@aeneasr aeneasr added the pending reply Awaiting reply of author or contributor. Issue will be closed on inactivity. label Apr 29, 2021
@honzapatCZ
Copy link
Contributor Author

Not sure I understand? I linked the place where the tests needs to be added already, it is here:

t.Run("case=should pass rp-initiated flows", func(t *testing.T) {

That test is RP Initiated, the call here

body, res := makeLogoutRequest(t, browser, method, url.Values{

so this call

resp, err = hc.Get(publicTS.URL + "/oauth2/sessions/logout?" + values.Encode())

which ends up here

require.NotEmpty(t, *v.Payload.RedirectTo)

and there you have access to the client. I linked these lines of codes already in my comments:

Sorry, but without tests I can't merge things. This is security software and needs thorough testing and good code quality. I know this might be frustrating to keep working on this but it's just the way this repo needs to work to prevent security issues. For example, I suspect that your change would currently expose the client_secret, so we need to add a test.

Maybe I misunderstand but I believe the instructions to be correct and accurate.

But that is for acceptLogoutRequest iam passing it in getLogoutRequest

@aeneasr
Copy link
Member

aeneasr commented May 13, 2021

@honzapatCZ I updated the code to unblock you and also help understand what I meant. Check out my commit here: 58ac49a

Hope this helps and sorry again for the frustrating contribution experience. But we got your feature merged! :) Thank you for the help

@aeneasr aeneasr removed the pending reply Awaiting reply of author or contributor. Issue will be closed on inactivity. label May 13, 2021
@honzapatCZ
Copy link
Contributor Author

So it's done and this can be closed?

@aeneasr
Copy link
Member

aeneasr commented May 13, 2021

No, it's not merged yet. CI is also failing. If you have appetite to look into it, I would appreciate it!

@aeneasr
Copy link
Member

aeneasr commented May 13, 2021

Found the issue I believe

@aeneasr aeneasr merged commit 43b391d into ory:master May 14, 2021
@aeneasr
Copy link
Member

aeneasr commented May 14, 2021

🎉 🥳

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