You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/03/04 14:19:40 UTC

[GitHub] [incubator-apisix] iGeeky opened a new pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

iGeeky opened a new pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204
 
 
   ### 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`
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r387992672
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -77,6 +81,18 @@ local function create_rbac_token(appid, wolf_token)
     return token_version .. "#" .. appid .. "#" .. wolf_token
 end
 
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+local function success_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
 
 Review comment:
   how about this name `error_msg` ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r388321642
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -351,71 +359,154 @@ local function login()
     local consumer = consumers[appid]
     if not consumer then
         core.log.info("request appid [", appid, "] not found")
-        return core.response.exit(400,
-                {message = "appid [" .. tostring(appid) .. "] not found"}
-               )
+        core.response.exit(400,
+                fail_response("appid [" .. tostring(appid) .. "] not found")
+            )
     end
+    return consumer
+end
 
-    core.log.info("consumer: ", core.json.delay_encode(consumer))
-
-    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
-    local headers = new_headers()
+local function request_to_wolf_server(method, uri, headers, body)
     headers["Content-Type"] = "application/json; charset=utf-8"
     local timeout = 1000 * 5
     local request_debug = core.json.delay_encode(
         {
-            method = 'POST', uri = uri, body = args,
+            method = method, uri = uri, body = body,
             headers = headers,timeout = timeout
         }
     )
 
-    core.log.info("login request [", request_debug, "] ....")
-    local res, err = http_post(uri, core.json.encode(args), headers, timeout)
+    core.log.info("request [", request_debug, "] ....")
+    local res, err = http_req(method, uri, core.json.encode(body), headers, timeout)
     if err or not res then
-        core.log.error("login request [", request_debug, "] failed! err: ", err)
+        core.log.error("request [", request_debug, "] failed! err: ", err)
         return core.response.exit(500,
-                {message = "request to wolf-server failed! " .. tostring(err)})
+            fail_response("request to wolf-server failed! " .. tostring(err))
+        )
     end
-    core.log.info("login request [", request_debug, "] status: ", res.status,
+    core.log.info("request [", request_debug, "] status: ", res.status,
                   ", body: ", res.body)
 
     if res.status ~= 200 then
-        core.log.error("login request [", request_debug, "] failed! status: ",
-                       res.status)
+        core.log.error("request [", request_debug, "] failed! status: ",
+                        res.status)
         return core.response.exit(500,
-            {
-                message = "request to wolf-server failed! status:"
-                          .. tostring(res.status)
-            }
+        fail_response("request to wolf-server failed! status:"
+                          .. tostring(res.status))
         )
     end
     local body, err = json.decode(res.body)
     if err or not body then
-        core.log.error("login request [", request_debug, "] failed! err:", err)
-        return core.response.exit(500, {message = "request to wolf-server failed!"})
+        core.log.error("request [", request_debug, "] failed! err:", err)
+        return core.response.exit(500, fail_response("request to wolf-server failed!"))
     end
     if not body.ok then
-        core.log.error("user login [", request_debug, "] failed! response body:",
+        core.log.error("request [", request_debug, "] failed! response body:",
                        core.json.delay_encode(body))
-        return core.response.exit(200, {message = body.reason})
+        return core.response.exit(200, fail_response(body.reason))
     end
-    core.log.info("user login [", request_debug, "] success! response body:",
+
+    core.log.info("request [", request_debug, "] success! response body:",
                   core.json.delay_encode(body))
+    return body
+end
+
+local function wolf_rbac_login()
+    local args = get_args()
+    if not args then
+        return core.response.exit(400, fail_response("invalid request"))
+    end
+    if not args.appid then
+        return core.response.exit(400, fail_response("appid is missing"))
+    end
+
+    local appid = args.appid
+    local consumer = get_consumer(appid)
+    core.log.info("consumer: ", core.json.delay_encode(consumer))
+
+    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
+    local headers = new_headers()
+    local body = request_to_wolf_server('POST', uri, headers, args)
 
     local userInfo = body.data.userInfo
     local wolf_token = body.data.token
 
     local rbac_token = create_rbac_token(appid, wolf_token)
-    core.response.exit(200, {rbac_token = rbac_token, user_info = userInfo})
+    core.response.exit(200, success_response(nil, {rbac_token = rbac_token, user_info = userInfo}))
+end
+
+local function get_wolf_token(ctx)
+    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}
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis merged pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
membphis merged pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r387994640
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -351,71 +359,154 @@ local function login()
     local consumer = consumers[appid]
     if not consumer then
         core.log.info("request appid [", appid, "] not found")
-        return core.response.exit(400,
-                {message = "appid [" .. tostring(appid) .. "] not found"}
-               )
+        core.response.exit(400,
+                fail_response("appid [" .. tostring(appid) .. "] not found")
+            )
     end
+    return consumer
+end
 
-    core.log.info("consumer: ", core.json.delay_encode(consumer))
-
-    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
-    local headers = new_headers()
+local function request_to_wolf_server(method, uri, headers, body)
     headers["Content-Type"] = "application/json; charset=utf-8"
     local timeout = 1000 * 5
     local request_debug = core.json.delay_encode(
         {
-            method = 'POST', uri = uri, body = args,
+            method = method, uri = uri, body = body,
             headers = headers,timeout = timeout
         }
     )
 
-    core.log.info("login request [", request_debug, "] ....")
-    local res, err = http_post(uri, core.json.encode(args), headers, timeout)
+    core.log.info("request [", request_debug, "] ....")
+    local res, err = http_req(method, uri, core.json.encode(body), headers, timeout)
     if err or not res then
-        core.log.error("login request [", request_debug, "] failed! err: ", err)
+        core.log.error("request [", request_debug, "] failed! err: ", err)
         return core.response.exit(500,
-                {message = "request to wolf-server failed! " .. tostring(err)})
+            fail_response("request to wolf-server failed! " .. tostring(err))
+        )
     end
-    core.log.info("login request [", request_debug, "] status: ", res.status,
+    core.log.info("request [", request_debug, "] status: ", res.status,
                   ", body: ", res.body)
 
     if res.status ~= 200 then
-        core.log.error("login request [", request_debug, "] failed! status: ",
-                       res.status)
+        core.log.error("request [", request_debug, "] failed! status: ",
+                        res.status)
         return core.response.exit(500,
-            {
-                message = "request to wolf-server failed! status:"
-                          .. tostring(res.status)
-            }
+        fail_response("request to wolf-server failed! status:"
+                          .. tostring(res.status))
         )
     end
     local body, err = json.decode(res.body)
     if err or not body then
-        core.log.error("login request [", request_debug, "] failed! err:", err)
-        return core.response.exit(500, {message = "request to wolf-server failed!"})
+        core.log.error("request [", request_debug, "] failed! err:", err)
+        return core.response.exit(500, fail_response("request to wolf-server failed!"))
     end
     if not body.ok then
-        core.log.error("user login [", request_debug, "] failed! response body:",
+        core.log.error("request [", request_debug, "] failed! response body:",
                        core.json.delay_encode(body))
-        return core.response.exit(200, {message = body.reason})
+        return core.response.exit(200, fail_response(body.reason))
     end
-    core.log.info("user login [", request_debug, "] success! response body:",
+
+    core.log.info("request [", request_debug, "] success! response body:",
                   core.json.delay_encode(body))
+    return body
+end
+
+local function wolf_rbac_login()
+    local args = get_args()
+    if not args then
+        return core.response.exit(400, fail_response("invalid request"))
+    end
+    if not args.appid then
+        return core.response.exit(400, fail_response("appid is missing"))
+    end
+
+    local appid = args.appid
+    local consumer = get_consumer(appid)
+    core.log.info("consumer: ", core.json.delay_encode(consumer))
+
+    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
+    local headers = new_headers()
+    local body = request_to_wolf_server('POST', uri, headers, args)
 
     local userInfo = body.data.userInfo
     local wolf_token = body.data.token
 
     local rbac_token = create_rbac_token(appid, wolf_token)
-    core.response.exit(200, {rbac_token = rbac_token, user_info = userInfo})
+    core.response.exit(200, success_response(nil, {rbac_token = rbac_token, user_info = userInfo}))
+end
+
+local function get_wolf_token(ctx)
+    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}
 
 Review comment:
   This variable is only used to output the log, so it is better to place it near the output log.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] moonming commented on issue #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
moonming commented on issue #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#issuecomment-602994912
 
 
   @membphis please take a look

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r388026003
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -77,6 +81,18 @@ local function create_rbac_token(appid, wolf_token)
     return token_version .. "#" .. appid .. "#" .. wolf_token
 end
 
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+local function success_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
 
 Review comment:
   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

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r387994968
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -351,71 +359,154 @@ local function login()
     local consumer = consumers[appid]
     if not consumer then
         core.log.info("request appid [", appid, "] not found")
-        return core.response.exit(400,
-                {message = "appid [" .. tostring(appid) .. "] not found"}
-               )
+        core.response.exit(400,
+                fail_response("appid [" .. tostring(appid) .. "] not found")
+            )
     end
+    return consumer
+end
 
-    core.log.info("consumer: ", core.json.delay_encode(consumer))
-
-    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
-    local headers = new_headers()
+local function request_to_wolf_server(method, uri, headers, body)
     headers["Content-Type"] = "application/json; charset=utf-8"
     local timeout = 1000 * 5
     local request_debug = core.json.delay_encode(
         {
-            method = 'POST', uri = uri, body = args,
+            method = method, uri = uri, body = body,
             headers = headers,timeout = timeout
         }
     )
 
-    core.log.info("login request [", request_debug, "] ....")
-    local res, err = http_post(uri, core.json.encode(args), headers, timeout)
+    core.log.info("request [", request_debug, "] ....")
+    local res, err = http_req(method, uri, core.json.encode(body), headers, timeout)
     if err or not res then
-        core.log.error("login request [", request_debug, "] failed! err: ", err)
+        core.log.error("request [", request_debug, "] failed! err: ", err)
         return core.response.exit(500,
-                {message = "request to wolf-server failed! " .. tostring(err)})
+            fail_response("request to wolf-server failed! " .. tostring(err))
+        )
     end
-    core.log.info("login request [", request_debug, "] status: ", res.status,
+    core.log.info("request [", request_debug, "] status: ", res.status,
                   ", body: ", res.body)
 
     if res.status ~= 200 then
-        core.log.error("login request [", request_debug, "] failed! status: ",
-                       res.status)
+        core.log.error("request [", request_debug, "] failed! status: ",
+                        res.status)
         return core.response.exit(500,
-            {
-                message = "request to wolf-server failed! status:"
-                          .. tostring(res.status)
-            }
+        fail_response("request to wolf-server failed! status:"
+                          .. tostring(res.status))
         )
     end
     local body, err = json.decode(res.body)
     if err or not body then
-        core.log.error("login request [", request_debug, "] failed! err:", err)
-        return core.response.exit(500, {message = "request to wolf-server failed!"})
+        core.log.error("request [", request_debug, "] failed! err:", err)
+        return core.response.exit(500, fail_response("request to wolf-server failed!"))
     end
     if not body.ok then
-        core.log.error("user login [", request_debug, "] failed! response body:",
+        core.log.error("request [", request_debug, "] failed! response body:",
                        core.json.delay_encode(body))
-        return core.response.exit(200, {message = body.reason})
+        return core.response.exit(200, fail_response(body.reason))
     end
-    core.log.info("user login [", request_debug, "] success! response body:",
+
+    core.log.info("request [", request_debug, "] success! response body:",
                   core.json.delay_encode(body))
+    return body
+end
+
+local function wolf_rbac_login()
+    local args = get_args()
+    if not args then
+        return core.response.exit(400, fail_response("invalid request"))
+    end
+    if not args.appid then
+        return core.response.exit(400, fail_response("appid is missing"))
+    end
+
+    local appid = args.appid
+    local consumer = get_consumer(appid)
+    core.log.info("consumer: ", core.json.delay_encode(consumer))
+
+    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
+    local headers = new_headers()
+    local body = request_to_wolf_server('POST', uri, headers, args)
 
     local userInfo = body.data.userInfo
     local wolf_token = body.data.token
 
     local rbac_token = create_rbac_token(appid, wolf_token)
-    core.response.exit(200, {rbac_token = rbac_token, user_info = userInfo})
+    core.response.exit(200, success_response(nil, {rbac_token = rbac_token, user_info = userInfo}))
+end
+
+local function get_wolf_token(ctx)
+    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}
+    core.log.info("hit wolf-rbac change_password api")
+    local rbac_token = fetch_rbac_token(ctx)
 
 Review comment:
   we can return an error message

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r388029992
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -351,71 +359,154 @@ local function login()
     local consumer = consumers[appid]
     if not consumer then
         core.log.info("request appid [", appid, "] not found")
-        return core.response.exit(400,
-                {message = "appid [" .. tostring(appid) .. "] not found"}
-               )
+        core.response.exit(400,
+                fail_response("appid [" .. tostring(appid) .. "] not found")
+            )
     end
+    return consumer
+end
 
-    core.log.info("consumer: ", core.json.delay_encode(consumer))
-
-    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
-    local headers = new_headers()
+local function request_to_wolf_server(method, uri, headers, body)
     headers["Content-Type"] = "application/json; charset=utf-8"
     local timeout = 1000 * 5
     local request_debug = core.json.delay_encode(
         {
-            method = 'POST', uri = uri, body = args,
+            method = method, uri = uri, body = body,
             headers = headers,timeout = timeout
         }
     )
 
-    core.log.info("login request [", request_debug, "] ....")
-    local res, err = http_post(uri, core.json.encode(args), headers, timeout)
+    core.log.info("request [", request_debug, "] ....")
+    local res, err = http_req(method, uri, core.json.encode(body), headers, timeout)
     if err or not res then
-        core.log.error("login request [", request_debug, "] failed! err: ", err)
+        core.log.error("request [", request_debug, "] failed! err: ", err)
         return core.response.exit(500,
-                {message = "request to wolf-server failed! " .. tostring(err)})
+            fail_response("request to wolf-server failed! " .. tostring(err))
+        )
     end
-    core.log.info("login request [", request_debug, "] status: ", res.status,
+    core.log.info("request [", request_debug, "] status: ", res.status,
                   ", body: ", res.body)
 
     if res.status ~= 200 then
-        core.log.error("login request [", request_debug, "] failed! status: ",
-                       res.status)
+        core.log.error("request [", request_debug, "] failed! status: ",
+                        res.status)
         return core.response.exit(500,
-            {
-                message = "request to wolf-server failed! status:"
-                          .. tostring(res.status)
-            }
+        fail_response("request to wolf-server failed! status:"
+                          .. tostring(res.status))
         )
     end
     local body, err = json.decode(res.body)
     if err or not body then
-        core.log.error("login request [", request_debug, "] failed! err:", err)
-        return core.response.exit(500, {message = "request to wolf-server failed!"})
+        core.log.error("request [", request_debug, "] failed! err:", err)
+        return core.response.exit(500, fail_response("request to wolf-server failed!"))
     end
     if not body.ok then
-        core.log.error("user login [", request_debug, "] failed! response body:",
+        core.log.error("request [", request_debug, "] failed! response body:",
                        core.json.delay_encode(body))
-        return core.response.exit(200, {message = body.reason})
+        return core.response.exit(200, fail_response(body.reason))
     end
-    core.log.info("user login [", request_debug, "] success! response body:",
+
+    core.log.info("request [", request_debug, "] success! response body:",
                   core.json.delay_encode(body))
+    return body
+end
+
+local function wolf_rbac_login()
+    local args = get_args()
+    if not args then
+        return core.response.exit(400, fail_response("invalid request"))
+    end
+    if not args.appid then
+        return core.response.exit(400, fail_response("appid is missing"))
+    end
+
+    local appid = args.appid
+    local consumer = get_consumer(appid)
+    core.log.info("consumer: ", core.json.delay_encode(consumer))
+
+    local uri = consumer.auth_conf.server .. '/wolf/rbac/login.rest'
+    local headers = new_headers()
+    local body = request_to_wolf_server('POST', uri, headers, args)
 
     local userInfo = body.data.userInfo
     local wolf_token = body.data.token
 
     local rbac_token = create_rbac_token(appid, wolf_token)
-    core.response.exit(200, {rbac_token = rbac_token, user_info = userInfo})
+    core.response.exit(200, success_response(nil, {rbac_token = rbac_token, user_info = userInfo}))
+end
+
+local function get_wolf_token(ctx)
+    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}
+    core.log.info("hit wolf-rbac change_password api")
+    local rbac_token = fetch_rbac_token(ctx)
 
 Review comment:
   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

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.

Posted by GitBox <gi...@apache.org>.
iGeeky commented on a change in pull request #1204: Wolf-Rbac: Add new api `change_pwd` and `user_info`.
URL: https://github.com/apache/incubator-apisix/pull/1204#discussion_r388026003
 
 

 ##########
 File path: lua/apisix/plugins/wolf-rbac.lua
 ##########
 @@ -77,6 +81,18 @@ local function create_rbac_token(appid, wolf_token)
     return token_version .. "#" .. appid .. "#" .. wolf_token
 end
 
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+local function success_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
 
 Review comment:
   I see that the field in `jwt-auch` is called "message". But the core module uses "error_msg". I chose to be consistent with `jwt-auch`
   
   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

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services