Comments (4)
Can you please provide a failing test case as a PR?
from jwx.
@wvh thanks for the test!
I amended your tests to avoid races, and allowed iat == now (truncated up to seconds) on #41
Let me know if it works for you?
from jwx.
The check now != ttv
fails after serialisation and deserialisation.
clock.Now().Truncate(time.Second)
is in local time, and tv.Time.Truncate(time.Second)
is in UTC (because it was deserialised from epoch which is UTC so with nil time zone):
fmt.Printf("%d == %d: %t\n", now, ttv, now == ttv)
{0 63654631131 9201856} == {0 63654631131 0}: false
If you compare the struct fields directly, the timezone might be different. It can be fixed by adding a .UTC()
call toclock.Now().UTC().Truncate(time.Second)
, using time.Equal()
instead, or reversing the condition to use .Before()
instead of .Equal()
and .After()
.
It might be better not to depend on struct comparison as the Go developers might change the fields internally like they did with the monotonic time improvements.
PS: This is with Go 1.9.x and 1.10, I think the time struct in 1.8 still has sec
, nsec
and loc
struct fields instead of monotonic wall
, ext
and loc
.
from jwx.
Yeah, that's a total screw up on my part. I totally meant to use Equal/After, but I don't know what I was thinking. nice catch :)
from jwx.
Related Issues (20)
- Example of decrypting a JWT? HOT 1
- jwt.ParseInsecure return verification error HOT 4
- jws.UnregisterSigner does not remove the underlying signer from the global signers map HOT 4
- `WithInferAlgorithmFromKey` should cache inferences alas HOT 3
- Simple custom field on a JWT token HOT 5
- Update go version within go.mod
- Expose Registering new JWK types HOT 9
- [v3] Errors getting swallowed by JWK cache HOT 3
- OpaqueKeyDecrypter for JWE HOT 11
- Provide a way to shutdown http cache fetcher to avoid go-routine leaks. HOT 10
- Problem setting key_ops key value HOT 4
- When generating encrypted JWTs using jwt.Serializer, most `jwe.EncryptOption` are ineffective HOT 1
- Decoding a Microsoft OAuth token: use of "jku" field specified, but the field is empty HOT 8
- PR for JAdES Signatures HOT 2
- jwt.Parse silently fails if alg isn't included in JWK HOT 7
- x509 can't support secp256k1 when calling jwk.Pem HOT 4
- Outdated example for iterating through keyset in `v2/jwk` readme HOT 2
- Allow `jwk.Cache` to use a custom `HTTPClient` object. HOT 3
- Add support for ShangMi SM2 Public Key HOT 5
- jws.Sign() allows jwa.RS256 alg when using ECDSA key HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jwx.