Skip to content

Commit

Permalink
fix(wolf-rbac): other plugin not effective when consumer used wolf-rb…
Browse files Browse the repository at this point in the history
…ac (#9287)
  • Loading branch information
lingliy committed Apr 13, 2023
1 parent c49ef09 commit bfd5311
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apisix/plugins/wolf-rbac.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ function _M.rewrite(conf, ctx)
create_consume_cache, consumer_conf)

core.log.info("------ consumers: ", core.json.delay_encode(consumers))
local consumer = consumers[appid]
if not consumer then
local cur_consumer = consumers[appid]
if not cur_consumer then
core.log.error("consumer [", appid, "] not found")
return 401, fail_response("Invalid appid in rbac token")
end
core.log.info("consumer: ", core.json.delay_encode(consumer))
local server = consumer.auth_conf.server
core.log.info("consumer: ", core.json.delay_encode(cur_consumer))
local server = cur_consumer.auth_conf.server

local res = check_url_permission(server, appid, action, url,
client_ip, wolf_token)
Expand All @@ -310,7 +310,7 @@ function _M.rewrite(conf, ctx)
local userId = userInfo.id
username = userInfo.username
nickname = userInfo.nickname or userInfo.username
local prefix = consumer.auth_conf.header_prefix or ''
local prefix = cur_consumer.auth_conf.header_prefix or ''
core.response.set_header(prefix .. "UserId", userId)
core.response.set_header(prefix .. "Username", username)
core.response.set_header(prefix .. "Nickname", ngx.escape_uri(nickname))
Expand All @@ -328,6 +328,7 @@ function _M.rewrite(conf, ctx)
{ username = username, nickname = nickname }
)
end
consumer.attach_consumer(ctx, cur_consumer, consumer_conf)
core.log.info("wolf-rbac check permission passed")
end

Expand Down

0 comments on commit bfd5311

Please sign in to comment.