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

ExpiredException throws 500 error #7

Closed
btaens opened this issue Jul 8, 2015 · 6 comments
Closed

ExpiredException throws 500 error #7

btaens opened this issue Jul 8, 2015 · 6 comments

Comments

@btaens
Copy link

btaens commented Jul 8, 2015

Hello, great plugin, very useful.

The plugin uses firebase JWT to authenticate based on the given token.
However, if the token is expired, firebase throws an ExpiredException, which results in a generic 500 error code.

This can make things problematic when trying to connect the backend with a client-side frontend, as RESTful apps generally check for a 401 error to know they need a new login. A 500 error can mean anything. Yes, a good client-side program can just know when it needs to throw away the token, but with RESTful APIs it is assumed it will serve a wide variety of client-side apps.

@bravo-kernel
Copy link
Contributor

FWIW I remember having tested token expiration using this plugin and it responded with the correct error code (I believe it was 419) and not a 500 error. Are you sure you are testing the right way?

@btaens
Copy link
Author

btaens commented Jul 8, 2015

Positive. I am looking at it right now.
The client side program does make a .json extension request though.
Perhaps it handles mapped resources differently?

@ADmad
Copy link
Owner

ADmad commented Jul 8, 2015

Are you checking with debug on or off?

@ADmad
Copy link
Owner

ADmad commented Jul 8, 2015

With debug on the authenticate class throws the same exception which Jwt lib throws (for which cake most likely returns 500 status).

With debug off you will get UnauthorizedException with 401 status (if JwtAuthenticate is the last authenticate class in list provided for authenticate config of AuthComponent.

@ADmad ADmad added the on hold label Jul 8, 2015
@btaens
Copy link
Author

btaens commented Jul 8, 2015

Yup, you're right.
Works correctly with debug off.
Is there a way around this, though? Makes testing pretty difficult.

@ADmad
Copy link
Owner

ADmad commented Jul 8, 2015

You can provide a patch to make this behavior configurable. Here's where you will need to add extra check.

@ADmad ADmad added works for me and removed on hold labels Jul 8, 2015
@ADmad ADmad closed this as completed Jul 8, 2015
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

3 participants