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

Wolf-Rbac: Add new api change_pwd and user_info. #1204

Merged
merged 3 commits into from
Mar 31, 2020
Merged

Wolf-Rbac: Add new api change_pwd and user_info. #1204

merged 3 commits into from
Mar 31, 2020

Conversation

iGeeky
Copy link
Contributor

@iGeeky iGeeky commented Mar 4, 2020

Add new api change_pwd and user_info

  • Add api /apisix/plugin/wolf-rbac/change_pwd used to change password
  • Add api /apisix/plugin/wolf-rbac/user_info used to get user info
  • Add attribute header_prefix to customize the prefix of the request/response header added by wolf-rbac


local function success_response(message, init_values)
local response = init_values or {}
response.message = message
Copy link
Member

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 ?

Copy link
Contributor Author

@iGeeky iGeeky Mar 5, 2020

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

Comment on lines 439 to 442
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}
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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

@moonming
Copy link
Member

@membphis please take a look

@membphis membphis merged commit 8470726 into apache:master Mar 31, 2020
SaberMaster pushed a commit to SaberMaster/incubator-apisix that referenced this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants