apisix icon indicating copy to clipboard operation
apisix copied to clipboard

request help: Custom authentication logic and response #4823

Open zou8944 opened this issue 4 years ago • 6 comments

Issue description

你好,两个问题,请帮忙解答我应该如何使用。

  1. 我需要的场景类似key-auth,但是我还需要在插件获取到自定义key时去调用自定的验证服务进行验证。即,key是变化的,而不是不变的。类似nginx的auth.url功能。
  2. 验证key后,需要根据验证结果返回自定义的响应body,类似下面。而不是apisix自定义的响应消息体。
{
  "code": "TokenOutOfDate",
  "msg": "token已过期",
  "data": null
}

zou8944 avatar Aug 15 '21 03:08 zou8944

Please use English on public channel.

  1. 但是我还需要在插件获取到自定义key时去调用自定的验证服务进行验证。

you can use "resty.http" to do this, Reference: https://github.com/apache/apisix/blob/master/apisix/plugins/wolf-rbac.lua

  1. 需要根据验证结果返回自定义的响应body

use core.response.exit()

tzssangglass avatar Aug 15 '21 10:08 tzssangglass

ok, thanks. I will try it later

zou8944 avatar Aug 16 '21 05:08 zou8944

wait, you mean than I need use "resty.http" to custom authentication logic ? Is there any existing plugin that I can use to do it ?

zou8944 avatar Aug 18 '21 04:08 zou8944

you mean than I need use "resty.http" to custom authentication logic

yes, you said to verify with a custom verification service.

Is there any existing plugin that I can use to do it

I don't know which plugin is suitable for your scenario, you can look at the documentation and code and pick the right one yourself.

tzssangglass avatar Aug 18 '21 05:08 tzssangglass

ok, thanks, I will continue exploring.

zou8944 avatar Aug 18 '21 05:08 zou8944

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Aug 03 '22 10:08 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Aug 17 '22 10:08 github-actions[bot]