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

feat: adds payload to exceptions #292

Closed
wants to merge 4 commits into from
Closed

feat: adds payload to exceptions #292

wants to merge 4 commits into from

Conversation

DanteMarshal
Copy link

@DanteMarshal DanteMarshal commented Apr 20, 2020

  • Add payload to following exceptions :
    • ExpiredException
    • Signature Exception
  • Add and Run Tests

* Add payload to following exceptions :
    - ExpiredException
	- Signature Exception
+ Add and Run Tests

Note : I have run the tests using Php 7.2.24
Someone please run the tests using Php 5.3
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@DanteMarshal
Copy link
Author

DanteMarshal commented Apr 20, 2020

Travis failing on checkstyle with nothing but this information :

---------- begin diff ----------

--- Original

+++ New

@@ @@

 }

+

----------- end diff -----------

Can someone help please ? I don't know what I should do here.

@Krisell
Copy link

Krisell commented Apr 20, 2020

Can someone help please ? I don't know what I should do here.

I think you're missing a newline at the end of the file, i.e. an empty line 13.

@bendoh
Copy link

bendoh commented Apr 21, 2020

Awesome, thanks for the PR!!

I’m a bit uncertain about attaching the payload to a SignatureInvalidException : is the payload even meaningful if it was never cryptographically valid? My intuition says no: the token isn’t valid and shouldn’t be parsed in any way.

@DanteMarshal
Copy link
Author

Yes, As mentioned by @Krisell in #291 ...

One could argue that decoding and returning the data is "processing", thus not complying with the standard.

But maybe someone needs to access the data in payload in order to process the exception, or perhaps for logging reasons. I believe Processing means using the payload in calculations for returning a response; which does not include logging on the server-side and inner exception handling stuff. At least for me, that was the reason I required it, because I needed to see a part of the payload after after it was expired to use it for future logging.

@bendoh
Copy link

bendoh commented May 19, 2020

Picking this back up cuz I really want this feature. My earlier point is that if the token is not cryptographically valid (its signature doesn't match its payload) then the whole token is invalid, payload and all, and should just be flatly rejected. There's no guarantee that the payload is even valid JSON here, unlike in the expired case, where the payload JSON is necessarily valid since it had to be decoded in order to determine the expiration time.

@DanteMarshal
Copy link
Author

Well the developer already knows it's invalid, cuz it's inside an exception; Why would anyone use that to process responses ?
But still won't hurt to keep it in case someone needs that.

Btw @bendoh, just a sidenote; If you're really in a hurry you can just make a copy of the library, make the changes you need and put it inside your project's files. I did that cuz I wasn't gonna wait for this to be merged.

@Dwarfex
Copy link

Dwarfex commented Aug 7, 2020

Only because the token is expired, doesn't mean, all its values are invalid.

You are right, when you say the token (as a whole) should not be processed.
Nevertheless i would expect my software that builds upon this library to decide.

I for example would like to access a refresh token stored within an expired token - that is by your definition invalid and MUST NOT be processed by the (low-level) php-jwt library.

Thus my highlevel logic doesn't work anymore.

In my opinion the library should mark the token as invalid and let the highlevel logic decide wheater to discard the "invalid" token.

btw - just for the lulz: https://youtu.be/4HJ-Y8YTo8Q

@edervishaj
Copy link

Any specific reason why this is not being merged?

@bshaffer
Copy link
Collaborator

bshaffer commented Nov 3, 2021

I don't think we want this feature. I'm not convinced it's useful.

@bshaffer bshaffer closed this Nov 3, 2021
@bshaffer
Copy link
Collaborator

After reading the linked issue and seeing the amount of traffic, I don't see any reason why we can't reopen and merge this. I will create a new PR and add some changes.

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

Successfully merging this pull request may close these issues.

None yet

7 participants