【问题标题】:MobileFirst 8: get client data ( IP address, request data ) in UserAuthenticationSecurityCheckMobileFirst 8:在 UserAuthenticationSecurityCheck 中获取客户端数据(IP 地址、请求数据)
【发布时间】:2020-10-15 15:52:58
【问题描述】:

我正在尝试在 UserAuthenticationSecurityCheck.validateCredentials 方法中获取一些客户端数据。

IP 地址对它来说是最重要的。

在其他适配器中,我使用的是 HttpServletRequest:

@Context
protected HttpServletRequest request;

但是这个请求对象在 UserAuthenticationSecurityCheck 中始终为空。

如何在此类中获取客户端数据(IP 地址或标头)?

【问题讨论】:

    标签: ibm-mobilefirst mobilefirst-adapters mobilefirst-server


    【解决方案1】:

    您不能将 HttpServletRequest 注入安全检查对象(按设计 - 不是错误)。用户通过身份验证后,您可以进行另一个适配器调用,从中可以获取所需的详细信息。不幸的是,这在任何地方都没有记录(至少据我所知)。

    here 所述,我遇到了与 AdapterAPI 类类似的问题。

    【讨论】:

      【解决方案2】:

      您可以在安全适配器中获取请求,但不能从@Context 获取。 只需覆盖授权方法:

      @Override
      public void authorize(Set<String> scope, Map<String, Object> credentials, HttpServletRequest request, AuthorizationResponse response) {
          //TODO use request object 
          super.authorize(scope, credentials, request, response);
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-19
        • 1970-01-01
        • 1970-01-01
        • 2020-03-17
        • 2018-08-21
        • 2013-03-31
        • 2019-01-14
        相关资源
        最近更新 更多