GithubHelp home page GithubHelp logo

Header decode compatibility issue about jwt HOT 9 CLOSED

kataras avatar kataras commented on June 15, 2024
Header decode compatibility issue

from jwt.

Comments (9)

kataras avatar kataras commented on June 15, 2024

Hello @duclm2609, for known algorithms (like RS256) the fixedHeaders are used (for performance boost), we can just add the typ:..., alg:.. forms too :) There is no need to support custom header/map at the moment (although it's not hard to do it).

EDIT: I think your issue with the java libray is that it accepts the golang one, but this golang jwt library does not accept the java's one because the order is different, right? If that's the case, then the issue is not on the createHeaderRaw itself but it's on the decodeToken (which calls the createHeaderRaw, we should modify that part to be able to understand the opossite form too). Note that, normally, this is the "correct" JWT specification form, that our kataras/jwt library uses.

from jwt.

geordee avatar geordee commented on June 15, 2024

On the header decode compatibility issue, the typ header is optional as per the specs.

I have a provider which creates JWT without the typ header, and some additional parameters (JWS). Is it possible to make the call to compareHeader optional using a flag?

from jwt.

cfeeling avatar cfeeling commented on June 15, 2024

I also met this issue when verifying the JWT token which was created by some library in other language. They added some additional keys in that header, and I must not modify the implementation in that library.

On my side, I would like to use my custom function to compare header of token, which is done by build-in compareHeader (

jwt/token.go

Line 159 in 9f23c50

func compareHeader(alg string, headerDecoded []byte) bool {
) right now, if it is possible.

Thanks for your work, it already makes my work more easier!

from jwt.

kataras avatar kataras commented on June 15, 2024

Sorry for the delay @cfeeling, @geordee. I've just pushed a commit and a new tag 0.0.9 which exports the CompareHeader so you can modify it globally.

Merry Christmas πŸŽ„ πŸŽ…πŸ½ 🀢🏽

from jwt.

cfeeling avatar cfeeling commented on June 15, 2024

Sorry for the delay @cfeeling, @geordee. I've just pushed a commit and a new tag 0.0.9 which exports the CompareHeader so you can modify it globally.

Merry Christmas πŸŽ…πŸ½ 🀢🏽

Thanks, it is one of nice things in this holiday!

I could use it as resetting the public variable CompareHeader right now, thats great!

Happy New Year, dear @kataras @geordee

from jwt.

kataras avatar kataras commented on June 15, 2024

Thanks @cfeeling, exactly! Happy new year πŸ˜ŠπŸ™ŒπŸ₯³

from jwt.

kataras avatar kataras commented on June 15, 2024

Hello @duclm2609 and @cfeeling.

I've just pushed v0.1.0, get it with:

$ go get -u github.com/kataras/jwt@latest

which contains new more methods: SignWithHeader and VerifyWithHeaderValidator to support custom headers and public key validation per-token (e.g jwt key ids/amazon and e.t.c.). Please take a look at the complete example at: https://github.com/kataras/jwt/blob/main/_examples/custom-header/main.go

from jwt.

cfeeling avatar cfeeling commented on June 15, 2024

Hello @duclm2609 and @cfeeling.

I've just pushed v0.1.0, get it with:

$ go get -u github.com/kataras/jwt@latest

which contains new more methods: SignWithHeader and VerifyWithHeaderValidator to support custom headers and public key validation per-token (e.g jwt key ids/amazon and e.t.c.). Please take a look at the complete example at: https://github.com/kataras/jwt/blob/main/_examples/custom-header/main.go

Hi @kataras , I received your message now, but I'm busy recently. I will be back and response ASAP when I was free, thanks for your work.

from jwt.

kataras avatar kataras commented on June 15, 2024

Hi @cfeeling no worries, take your time.

from jwt.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.