Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

claims.go: Fixed some superfluous code. Added leeway. #86

Closed
wants to merge 7 commits into from
Closed

claims.go: Fixed some superfluous code. Added leeway. #86

wants to merge 7 commits into from

Conversation

ericlagergren
Copy link

@dgrijalva
Copy link
Owner

Lots of stuff in here. I'll need to spend a bit more time looking over it, but it looks fine.

@@ -28,19 +28,19 @@ func (c StandardClaims) Valid() error {
vErr := new(ValidationError)
now := TimeFunc().Unix()

// The claims below are optional, by default, so if they are set to the
// By default he claims below are, optional, so if they are set to the
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the" claims?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Typo. I have fat-finger syndrome :)

@dgrijalva
Copy link
Owner

I don't agree that what you've removed is 'superfluous'. While == false does the same thing as the ! prefix, and is more characters, fewer characters isn't always better. Projects like this have a lot of complexity and the cost of making logic mistakes is very high. Being explicit and clear, at the expense of a few extra characters feels like the right choice.

To strengthen my argument, there are a few places in this PR where the logic is unintentionally inverted, introducing vulnerabilities. The fact that the tests pass indicates we need to add some tests around this area before 3.0 is ready.

The addition of leeway, if presented without all these other changes, looks fine. If you want to open a PR with those changes, I'll review again. Otherwise, I can come through and cherry-pick when I have time.

@dgrijalva dgrijalva closed this Nov 16, 2015
@dgrijalva dgrijalva mentioned this pull request Apr 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants