Skip to content

Conversation

dmitrizagidulin
Copy link
Contributor

No description provided.

@dmitrizagidulin dmitrizagidulin changed the title Fix passing delay option, add diagnostic debug statements Save incoming returnToUrl from query string in session May 5, 2018
@dmitrizagidulin
Copy link
Contributor Author

Addresses issue #17

@dmitrizagidulin
Copy link
Contributor Author

Ready for review.

@RubenVerborgh
Copy link
Contributor

Thanks so much, will look at this ASAP (but have some backlog after a week of Solid).

Copy link
Contributor

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

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

Thanks! Tested and works, but a couple of minor concerns on the code itself.

static extractReturnToUrl (session) {
const returnToUrl = session.returnToUrl

return returnToUrl ? decodeURIComponent(returnToUrl) : null
Copy link
Contributor

Choose a reason for hiding this comment

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

What if it's null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand your question correctly -- if this function returns null, then it'll be set to the default / in the AuthCallbackRequest constructor.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

let host = { serverUri: 'https://example.com' }
let session = { returnToUrl: 'https://example.com/resource' }
let returnToUrl = 'https://example.com/resource#hash'
let session = { returnToUrl: encodeURIComponent(returnToUrl) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why encoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am assuming (based on what I saw the 401 error handler doing in solid-server) that the returnToUrl is being url-encoded before being stuffed in a query parameter. (So, I'm simulating that in this unit test). Is that not the right assumption?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, because it needs to be URL-encoded as an URL parameter. However, decoding is part of URL query string parsing, so it should be fine (and in any case, the session should have the unencoded value).


it('should return a url-decoded returnToUrl from session', () => {
let returnToUrl = 'https://example.com/resource#hash'
let session = { returnToUrl: encodeURIComponent(returnToUrl) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why encoded?

webId,
oidcManager,
serverUri,
returnToUrl: query.returnToUrl,
Copy link
Contributor

Choose a reason for hiding this comment

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

This one should normally already be decoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it automatically decoded by Express?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, query is the parsed query string, which includes decoding.

@dmitrizagidulin
Copy link
Contributor Author

@RubenVerborgh - I removed the encoding & decoding of returnToUrl, per your suggestions.

Let me know if there's anything else.

@RubenVerborgh
Copy link
Contributor

Thanks, retested and works!

Could you do a release after you merge?
However, I see npm complains about vulnerabilities in dependencies, would be good to fix those first. I'll do that and submit a PR.

@dmitrizagidulin
Copy link
Contributor Author

@RubenVerborgh sure thing, re release.

(Are you talking about the base64url vulnerability? I'm in the process of fixing that upstream -- there's like half a dozen libraries that need to be changed.)

@RubenVerborgh
Copy link
Contributor

No, lots of vulnerabilities in random npm packages. Mostly an update to package-lock.json. Pull request coming in a couple of minutes.

@dmitrizagidulin
Copy link
Contributor Author

@RubenVerborgh ok cool! :) What should I do with this PR - merge it, or wait for yours?

@RubenVerborgh
Copy link
Contributor

You can merge this one, just wait for mine to release please :-)

@dmitrizagidulin
Copy link
Contributor Author

Thanks, got it.

@dmitrizagidulin dmitrizagidulin merged commit 8188da8 into master May 23, 2018
@dmitrizagidulin dmitrizagidulin deleted the dz-returnToUrl branch May 23, 2018 15:54
@RubenVerborgh
Copy link
Contributor

PR in #21

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.

2 participants