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

Error when handling callback #5

Closed
christiansyoung opened this issue Jul 20, 2016 · 13 comments
Closed

Error when handling callback #5

christiansyoung opened this issue Jul 20, 2016 · 13 comments

Comments

@christiansyoung
Copy link

I am trying out the lib and based my code on the redux-oidc-example app with Google auth.

I get the following error when returning to the callback:

redux-oidc.js:1Uncaught (in promise) Error: Error handling redirect callback: signature validation failed

I was also wondering how I could turn on logging on the oidc-client lib to further investigate? I tried doing ìmport Oidc from 'oidc-client'; Oidc.Log.logger = console;` both in my Root React component and in my express server, but nothing shows.

@maxmantz
Copy link
Owner

maxmantz commented Jul 20, 2016

Make sure you are using https instead of http when making the request. When you're using the HTTP version (http://redux-oidc-example.herokuapp.com/) it won't work but with SSL it works.

I haven't yet tried logging in oidc-client. I'll have a look and see what I can come up with. I'll post what I can find here.

@christiansyoung
Copy link
Author

I see, is it Google that enforces the request to come from HTTPS? So I need to use HTTPS in my Express server when developing as well?

@maxmantz
Copy link
Owner

Yes. Google requires a callback URI with SSL enabled.

@christiansyoung
Copy link
Author

Made Express use https now, but I get the same error :(

Here is what I do when logged out of Google in incognito with empty localStorage:

  • Trigger login
  • Get redirected to Google's concent screen -> Allow
  • Get redirected to this (jwt obscured) https://localhost:8000/callback#state=862de4e1f9c24a7d9917653604f3d650&access_token=ya29.Ci8mA082OaSl1NaJOFFeLz<SNIP>OPWMUEdXayiGm0J3H8X--Ztdym60SBFA03KoA&token_type=Bearer&expires_in=3600&id_token=<SNIP>&authuser=0&session_state=d5350fbc4fdd649aef77caf4b16dcee33385e28e..edc9&prompt=consent
  • CallbackComponent triggers
  • CallbackComponent fails with the following again:
    redux-oidc.js:1 Uncaught (in promise) Error: Error handling redirect callback: signature validation failed

This time I also got:
Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources. SecurityError

Thank you for helping out!

@maxmantz
Copy link
Owner

maxmantz commented Jul 20, 2016

I've just tried this with the example app but couldn't reproduce the issue. Have you tried clearing the cache and refreshing (Shift + F5)? From what I've researched this could be the reason for the second error message you've received.

@maxmantz
Copy link
Owner

I can also see that your localhost port (8000) is not matching the example app's port (8080). If you're using my client_id this won't work because it requires https://localhost:8080 as the base URL. But I guess you're using your own client_id registered with Google...

@christiansyoung
Copy link
Author

I am using my own client_id from a OAuth 2.0 client ID. I tried creating a new app, but that didn't help. Maybe if I could figure out how to log oidc-client, I could read the raw exception from https://github.com/IdentityModel/oidc-client-js/blob/178d19f279bfeb39915db9fc443623605130da33/src/JoseUtil.js#L111 (if that is the code that triggers it).

I tried a hard clear of cache, hard refresh and using incognito mode. Doesn't work. I can try changing to port 8080 and using your client_id to eliminate that problem.

@christiansyoung
Copy link
Author

Changing to your client_idyields the same error.

@maxmantz
Copy link
Owner

If you're using Google you will have to use your client_id otherwise Google would mistake your app for my example app. It is hard to pinpoint the exact reason why the JWT validation fails. Maybe @brockallen can help with this?

@christiansyoung
Copy link
Author

I disabled all my security like CORS/CSP, headers etc., and I got through. I will try to figure out exactly what triggered it.

Btw: In your wikipage https://github.com/maxmantz/redux-oidc/wiki/2.-Configuration, you give the following example of a successCallback. I used this initially, but the user.state object is undefined for me. I only use react-router, so I changed it to router.push('/'); (from this.context.router)

successCallback = (user) => {
    // the user object gets the browser's URL before 
    // redirection was triggered passed into its state
    const urlBeforeRedirection = user.state.redirectUrl;
    this.props.dispatch(push(urlBeforeRedirection));
  };

@maxmantz
Copy link
Owner

maxmantz commented Jul 20, 2016

This is an error in the wiki. Thank you for pointing this out. The redirectUri will only get passed if you're using the automatic redirection with the middleware. If not, in your custom behavior, you will have to pass in the current URL yourself by doing this:

userManager.siginRedirect({ 
  data: {
    redirectUrl: window.location.href
  }
});

Then you can access the redirectUrl in the CallbackComponent.
Will update the wiki ASAP.

@christiansyoung
Copy link
Author

Thanks, that worked.
It was not my security that triggered the signature error, it was me trying to log oidc-client. When commenting out security related code, I also commented out the logging code without thinking about it.

@maxmantz
Copy link
Owner

Glad I could help.

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

No branches or pull requests

2 participants