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

401 Unauthorized without further information on OIDC login #17

Closed
TBG-FR opened this issue Mar 9, 2022 · 5 comments
Closed

401 Unauthorized without further information on OIDC login #17

TBG-FR opened this issue Mar 9, 2022 · 5 comments

Comments

@TBG-FR
Copy link

TBG-FR commented Mar 9, 2022

Hello there !

Some time ago I followed your (awesome) article, to implement OIDC authentication in a NestJS app, but sometimes when I log myself in, I get on a {"statusCode":401,"message":"Unauthorized"} page. Nothing appears in NestJS logs, nothing else on the web page.

I'm hence creating this issue, so we can (hopefully) find the cause and solve it, all together 😄

I tried adding log lines in your code to find where it was stopping, and the last one appears before

const result = (await super.canActivate(context)) as boolean;
, that's the only clue I have for now

@sdoxsee
Copy link
Owner

sdoxsee commented Mar 9, 2022

Thanks for the issue. I haven't experienced this myself so please keep this updated as you learn more. Thanks!

@TBG-FR
Copy link
Author

TBG-FR commented Mar 9, 2022

Something I found really strange, is that it doesn't happen when I use https://oidctest.wsweet.org/ but very frequently with another private provider... I'll keep digging !

@TBG-FR
Copy link
Author

TBG-FR commented Mar 10, 2022

As I was suspecting it, the issue comes from the provider side (I managed to get more info by modifying some lib code, see nestjs/passport#841 )

Do you have any idea on how we could improve the error management (modifying your example code and/or lib code) ? Not displaying the { "statusCode": 401, "message": "Unauthorized ..." } page but redirecting to a page of our choice ? This would be a great improvement 😄

@TBG-FR
Copy link
Author

TBG-FR commented Mar 13, 2022

As I was suspecting it, the issue comes from the provider side (I managed to get more info by modifying some lib code, see nestjs/passport#841 )

Do you have any idea on how we could improve the error management (modifying your example code and/or lib code) ? Not displaying the { "statusCode": 401, "message": "Unauthorized ..." } page but redirecting to a page of our choice ? This would be a great improvement 😄

The right way to do it seems to be Exception Filters ! Closing this issue then ;)

@TBG-FR TBG-FR closed this as completed Mar 13, 2022
@sdoxsee
Copy link
Owner

sdoxsee commented Mar 13, 2022

Thanks for the updates @TBG-FR

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

No branches or pull requests

2 participants