-
Notifications
You must be signed in to change notification settings - Fork 2.7k
change(jwt-auth): when algorithm is not RS256 or ES256, require the user to fill in secret
#12611
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
change(jwt-auth): when algorithm is not RS256 or ES256, require the user to fill in secret
#12611
Conversation
… user to fill in secret
RS256 or ES256, require the user to fill in secretRS256 or ES256, require the user to fill in secret
|
|
||
| if conf.algorithm ~= "RS256" and conf.algorithm ~= "ES256" and not conf.secret then | ||
| conf.secret = ngx_encode_base64(resty_random.bytes(32, true)) | ||
| if (conf.algorithm == "HS256" or conf.algorithm == "HS512") and not conf.secret then |
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.
t/plugin/jwt-auth.t
Outdated
| if not ok then | ||
| ngx.say(err) | ||
| else | ||
| ngx.say("done") | ||
| end |
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.
Just a suggestion: using assert is enough.
assert(ok, "HS256 but secret is not required")
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.
done
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 this PR should be called change(jwt-auth): xxx 🤔
@bzp2010 This is not very common. I usually refer to https://github.com/TrigenSoftware/simple-release/blob/main/GUIDE.md Since this feature did not exist before, it should be |
|
If the |
RS256 or ES256, require the user to fill in secretRS256 or ES256, require the user to fill in secret
…he user to fill in `secret` (apache#12611)

Description
This PR is a part of #12603 and is separated out due to breaking changes.
Currently, the jwt-auth plugin generates a random value for
conf.secretin thecheck_schemafunction whenconf.algorithm ~= "RS256" and conf.algorithm ~= "ES256" and not conf.secret.Modifying the user-provided configuration can easily lead to user
confusion, which is clearly not best practice.
This also affects the diff logic in the adc that the apisix ingress
controller depends on.
I believe this generation behavior should be removed. To solve this problem, This PR removed the corresponding code and
instead return an error message, requiring users to fill in the
corresponding configuration themselves.
Which issue(s) this PR fixes:
Fixes #
Checklist