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

Don't touch authentication cookie on skipped logins #1564

Merged
merged 2 commits into from
Oct 3, 2019

Conversation

doubliez
Copy link
Contributor

Related issue

This will fix #1557

Proposed changes

When login was skipped, return the session and don't touch the existing authentication cookie (which would alter its expiry date).

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 necessary documentation within the code base (if appropriate)
  • I have documented my changes in the developer guide (if appropriate)

Further comments

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2019

CLA assistant check
All committers have signed the CLA.

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.

This looks good! Could you also add a test please? If you need guidance let me know

@aeneasr
Copy link
Member

aeneasr commented Sep 18, 2019

Oh and please sign the CLA :)

@aeneasr
Copy link
Member

aeneasr commented Sep 23, 2019

Ping :)

@doubliez
Copy link
Contributor Author

I signed the CLA. I'll try to add a test this week. I assume there was no test for this specific case then? ;)

@aeneasr
Copy link
Member

aeneasr commented Sep 23, 2019

Perfect - yes exactly ;)

@doubliez
Copy link
Contributor Author

@aeneasr I updated the docs regarding RememberFor value for login.

Regarding the tests I was thinking of retrieving the auth cookie from the cookie jar and making sure the Expires value is set correctly, but it seems the net/http/cookiejar package doesn't allow inspecting those values. When retrieving cookies with cookiejar.Cookies(u) it returns only the Name and Value attributes for the cookies: https://github.com/golang/go/blob/master/src/net/http/cookiejar/jar.go#L219

for _, e := range selected {
	cookies = append(cookies, &http.Cookie{Name: e.Name, Value: e.Value})
}

So I'm not sure how to properly test this.

@aeneasr
Copy link
Member

aeneasr commented Oct 2, 2019

Ah, I see - I think that's why the tests didn't catch it, because the Cookie Jar doesn't really concern itself with sessions like the browser does.

I think the only way to get the cookie value is to somehow use the gorilla session decoder to get it (I've tried before but failed but it should in theory be possible IMO) or write a small endpoint and add it to the test server that simply echoes the cookie values as e.g. a json string.

@doubliez
Copy link
Contributor Author

doubliez commented Oct 2, 2019

@aeneasr Since I'm not too familiar with Go and don't have much time to work on this, can you take it from there?

@aeneasr
Copy link
Member

aeneasr commented Oct 3, 2019

SGTM - thank you for your contribution!

@aeneasr aeneasr merged commit 31752ab into ory:master Oct 3, 2019
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.

Potential bug in remember logic for login when login is skipped
3 participants