-
Notifications
You must be signed in to change notification settings - Fork 487
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
[oidc-discovery-provider] Fix keys url #5690
base: main
Are you sure you want to change the base?
Conversation
When jwt_issuer is specified, it is overriding the jwks key url in addition to the issuer property. This may cause the subsequent key retrieval to hit the wrong server, or fail if that server doesn't actually exist. Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Good catch, @kfox1111. This looks like an appropriate fix to me. |
I think that @kfox1111 nailed it in this comment: #5657 (comment) The fix proposed in this PR would solve some of the issues but Maybe we could revert the code in handler.go to version 1.11.0 and only change the way var issuerURL *url.URL
if h.jwtIssuer != "" {
issuerURL, _ = url.Parse(h.jwtIssuer)
} else {
issuerURL = &url.URL{
Scheme: urlScheme,
Host: r.Host,
}
} This should take care of the custom issuer case and maintain the old behavior for the JWKS URI. |
Hmm.... I think this is another reason the In some cases you may actually want it http, and in others, you may always want it to be https (when lb fronted https -> http)... So that too needs to be configurable. In the non specified case though, I think I fixed the issue. Thanks for bringing it up. Please have another look to see if I addressed it properly. |
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Just determining what the maintainers preferences are on naming (namings always hard). If you prefer server_path_prefix and jwks_uri, I'm good with that. I'll fix up the patch asap with that, and then I think we're good to go. |
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
if c.JWKSURI != "" { | ||
jwksURI, err := url.Parse(c.JWKSURI) | ||
if err != nil || jwksURI.Scheme == "" || jwksURI.Host == "" { | ||
return nil, errors.New("the jwks_uri setting could not be parsed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we follow the more verbose error checking done for JWTIssuer? It gives a bit more detail about the way the uri is invalid..
Host: r.Host, | ||
Path: keysPath, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to simplify this a bit. I'm thinking something like:
var issuerURL url.URL
if h.jwtIssuer != "" {
...
issuerURL = ...
} else {
...
issuerURL = ...
}
var jwksURL url.URL
if h.jwksURL != "" {
...
jwksURL = ...
} else {
...
jwksURL = ...
}
Minimizes dependencies between the parts of the two URLs and makes it a bit easier to read, at least in my opinion.
jwtIssuer string | ||
jwksURI string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could store these 2 at start up as *url.URL to avoid parsing at runtime.
} | ||
keysPath, err := url.JoinPath(h.serverPathPrefix, "keys") | ||
if err != nil { | ||
http.Error(w, err.Error(), http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe StatusInternalServerError
would be better suited for such errors?
When jwt_issuer is specified, it is overriding the jwks key url in addition to the issuer property. This may cause the subsequent key retrieval to hit the wrong server, or fail if that server doesn't actually exist.