-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Wolf-Rbac: Add new api change_pwd
and user_info
.
#1204
Conversation
|
||
local function success_response(message, init_values) | ||
local response = init_values or {} | ||
response.message = message |
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.
how about this name error_msg
?
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.
I see that the field in jwt-auth
is called "message". But the core module uses "error_msg". I chose to be consistent with jwt-auth
In the aspect of returning error information, I think the core module should provide a unified function to handle it. In this way, the structure of error/correct information returned by the whole system can be consistent. This is still important for API services. Otherwise, the client may have to handle several different information structures
lua/apisix/plugins/wolf-rbac.lua
Outdated
local url = ctx.var.uri | ||
local action = ctx.var.request_method | ||
local clientIP = core.request.get_ip(ctx) | ||
local permItem = {action = action, url = url, clientIP = clientIP} |
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.
This variable is only used to output the log, so it is better to place it near the output log.
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
local clientIP = core.request.get_ip(ctx) | ||
local permItem = {action = action, url = url, clientIP = clientIP} | ||
core.log.info("hit wolf-rbac change_password api") | ||
local rbac_token = fetch_rbac_token(ctx) |
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 can return an error message
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.
Is it not recommend to directly use core.response.exit
to return error information in the called function? When I thought about it at that time, all the calls would no longer need to be judged. The code would look simpler
@membphis please take a look |
Add new api
change_pwd
anduser_info
/apisix/plugin/wolf-rbac/change_pwd
used to change password/apisix/plugin/wolf-rbac/user_info
used to get user infoheader_prefix
to customize the prefix of the request/response header added bywolf-rbac