authentication - 从 jwt 身份验证中的身份验证 api 获取自定义标头
问题描述
我正在使用 JWT 身份验证,并且我使用了 Authenticate 方法,如下所示:
class ModelBackendCustom(ModelBackend):
"""
This backend is to be used when the server is handling authentication
from an LDAP or Active Directory service.
By default, the ``authenticate`` method creates ``User`` objects for
usernames that don't already exist in the database. Subclasses can disable
this behavior by setting the ``create_unknown_user`` attribute to
``False``.
"""
def authenticate(self, request, username=None, password=None, **kwargs):
logger.info("Trying to authenticate the user %s against the database" % subject_dn)
user = super(ModelBackendCustom, self).authenticate(request, username, password, **kwargs)
# Check DB groups against mapping
if user:
if user.is_authenticated:
logger.info("Authenticate the user %s against the database with success" % subject_dn)
user = self.configure_user(request, user)
return user
else:
logger.info("Authenticate the user %s against the database failed by giving a non authenticated user" % subject_dn)
else:
logger.info("Authenticate the user %s against the database failed" % subject_dn)
return None
当我只在我的请求中使用用户名密码并且我通常会收到我的令牌时,我已经完成了这一切。我现在想从身份验证请求中使用标头,但请求始终为 None 。谁有一个想法,如何解决这个问题或一种方法来覆盖身份验证方法以获得标题。谢谢
解决方案
推荐阅读
- java - org.hibernate.hql.internal.ast.QuerySyntaxException:实体未映射
- php - 如何在 PHP 数组/JSON 对象中打印第 n 个元素?
- php - Symfony3:每 24 小时执行一次代码
- typescript - 使用 angular-cdk 的 coerceBooleanProperty() 为布尔属性输入定义 getter 和 setter 时,使用 Type 的首选方法是什么?
- yaml - 如何引用相对于启动文件的 Yaml 文件?
- javascript - 组件中缺少历史记录
- actions-on-google - dialogflow-fulfillment-nodejs 不支持哪些 Actions on Google 功能?
- ibm-cloud-infrastructure - 无法使用 Softlayer 映像订购暂停计费的 IBM Cloud 虚拟服务器
- javascript - nodejs中未调用Angular 5 http post方法
- java - 将文本字段中的特定字段值与固定一个值的 mysql 列值进行比较