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

Add key id to header #159

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions token/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (j *RS256JWTStrategy) Generate(claims jwt.Claims, header Mapper) (string, s

token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
token.Header = assign(token.Header, header.ToMap())
// "public" is understood to be the most recent keyid
token.Header["kid"] = "public"
Copy link
Member

Choose a reason for hiding this comment

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

This is actually implicit knowledge from hydra, not all keys have a key id of "public". Instead, we should set the key in the header.

Copy link
Author

Choose a reason for hiding this comment

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

So its interesting because the RSA key that is passed into the factory https://github.com/ory/hydra/blob/master/cmd/server/handler_oauth2_factory.go#L66 doesn't have the notion of an ID. I think the token header needs to be added here because it needs to be there before its signed.

We would likely need to modify the https://github.com/ory/fosite/blob/master/compose/compose_strategy.go#L35 to accept a JWT rather than an RSA key, but that may have a cascading effect

Copy link
Member

Choose a reason for hiding this comment

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

It should be enough to add that header field in NewSession()


var sig, sstr string
var err error
Expand Down