Same endpoint for anonymous and authenticated users

*爱你&永不变心* 提交于 2019-12-23 13:15:45

问题


I want to add this endpoint /graphql in kong for both anonymous and authenticated users :

  • if the apikey is provided consider it as authenticated
  • othwerwise consider it as anonymous

回答1:


Try the config.anonymous field in the key-auth plugin I think by:

  1. creating a consumer that you can call ‘anoynmous’ with and id 0 for example

  2. use the kong id of that consumer in anonymous field

  3. update your custom code (KongAuthentication) and check if HTTP_X_CONSUMER_CUSTOM_ID = 0 then return AnonymousUser (django.contrib.auth.models.AnonymousUser)



来源:https://stackoverflow.com/questions/51242617/same-endpoint-for-anonymous-and-authenticated-users

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!