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

tryLoginCodeFlow with HashLocationStrategy #594

Closed
bigozzi-inspect opened this issue Aug 1, 2019 · 10 comments · Fixed by #634
Closed

tryLoginCodeFlow with HashLocationStrategy #594

bigozzi-inspect opened this issue Aug 1, 2019 · 10 comments · Fixed by #634
Labels
bug For tagging faulty or unexpected behavior. future-version Will be considered, but for a future version. pr-welcome We'd welcome a PR to solve the issue.

Comments

@bigozzi-inspect
Copy link

bigozzi-inspect commented Aug 1, 2019

image

The screen shows like this line of code this.parseQueryString(window.location.search) can't work with HashLocationStrategy because query string is inside windows.location.hash rather than window.location.search.

Thanks you for this nice lib!

@bigozzi-inspect
Copy link
Author

bigozzi-inspect commented Aug 1, 2019

This is a ugly fix:

public tryLoginCodeFlow(): Promise<void> {

    const parts = this.parseQueryString(window.location.search ||
        window.location.hash.split('?').pop())
    [...]
}

In this file: https://github.com/manfredsteyer/angular-oauth2-oidc/blob/master/projects/lib/src/oauth-service.ts
Line: 1400

@jeroenheijmans
Copy link
Collaborator

Thx for sharing! But your issue is really rather hard to follow. Could you please elaborate, (is it a bug? a question? could you create a minimal repro? what is the expected vs actual outcome after a set of steps to reproduce?).

@bigozzi-inspect bigozzi-inspect changed the title tryLoginCodeFlow with HashLocationStrategy [BUG] tryLoginCodeFlow with HashLocationStrategy Aug 1, 2019
@bigozzi-inspect
Copy link
Author

Thx for sharing! But your issue is really rather hard to follow. Could you please elaborate, (is it a bug? a question? could you create a minimal repro? what is the expected vs actual outcome after a set of steps to reproduce?).

Hi @jeroenheijmans, i have edited bug description and fix comment, i hope now it's more comprensible!

@manfredsteyer
Copy link
Owner

Thx for this info. According to the specs, code flow transports the code in the querystring. However, there is this additonal spec, that allows us to vary the the response_mode to hash:

https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html

I guess, we should look into it for the next version.

@manfredsteyer manfredsteyer added the future-version Will be considered, but for a future version. label Aug 3, 2019
@manfredsteyer
Copy link
Owner

Btw: Could be a nice PR ...

@manfredsteyer manfredsteyer added the pr-welcome We'd welcome a PR to solve the issue. label Aug 3, 2019
@jeroenheijmans jeroenheijmans changed the title [BUG] tryLoginCodeFlow with HashLocationStrategy tryLoginCodeFlow with HashLocationStrategy Aug 4, 2019
@jeroenheijmans jeroenheijmans added the feature-request Improvements and additions to the library. label Aug 4, 2019
@gingters
Copy link
Contributor

gingters commented Sep 23, 2019

@jeroenheijmans With all due respect, but I consider this a bug, and not a feature request.

This is an oidc library for angular applications, and while not being the default, angular provides the hash location strategy out of the box and it is commonly used. So every developer of an angular lib should be very aware that query strings in an angular application can come after a hash.

+++
Edit Additional info:
That has nothing to do with the response type. You'd simply set the redirect uri on the IDP to https://domain/app/#/login-callback-component and then the idp will simply append the code to the query string after this url and will call back into the angular app using hash location strategy. In this case the library isn't capable of reading the code from the url and do it's thing at all.
+++

A more angular-like approach would be to have the ActivatedRoute injected in the OAuthService and use this.route.snapshot.paramMap.get('paramName') to access the query parameters in a unique fashion regardless of the configured location strategy.

@jeroenheijmans jeroenheijmans added bug For tagging faulty or unexpected behavior. and removed feature-request Improvements and additions to the library. labels Sep 23, 2019
@jeroenheijmans
Copy link
Collaborator

Something has to be changed in a PR to make a specific scenario work, I'm not too fussed whether we label it a 'bug' or a 'feature' 😄 - I've changed the label.

@gingters
Copy link
Contributor

Hehe, I mean, there is a claim on the readme stating that its tested with hash location strategy ;)
I will try to get something done here.

@jeroenheijmans
Copy link
Collaborator

Hah fair point :)

I think the readme is from some time ago, and the Code Flow was integrated via community-provided PRs that omitted this part.

Would be nice if you could add a PR. (Note that while I try to keep an eye on GH issues, it's Manfred who typically takes some time every few months to merge PRs and create a new release. So could take a bit before anything gets integrated.)

@gingters
Copy link
Contributor

I will ping Manfred. Hope he can get a bugfix release out a tad faster ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For tagging faulty or unexpected behavior. future-version Will be considered, but for a future version. pr-welcome We'd welcome a PR to solve the issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants