【问题标题】:How to prevent WWW-Authenticate header in response with authenticateBasicAsync directive?如何防止 WWW-Authenticate 标头响应 authenticateBasicAsync 指令?
【发布时间】:2017-01-27 01:33:37
【问题描述】:

在使用 authenticateBasicAsync 时,如何省略 WWW-Authenticate 响应头?

问题是 Javascript api (ajax) 正在调用 akka-http 服务,并且当身份验证失败时浏览器正在显示登录窗口。

谢谢!

【问题讨论】:

    标签: akka spray akka-http


    【解决方案1】:

    想通了。创建一个自定义拒绝处理程序以对响应进行较低级别的控制:

    def customRejectionHandler = RejectionHandler.newBuilder()
    .handle { 
        case AuthenticationFailedRejection(cause, challenge) => 
        complete(HttpResponse(StatusCodes.Unauthorized)) 
    }
    .result()
    

    然后传递给一个handleRejections 指令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      • 2016-06-02
      • 2018-10-19
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 2021-06-07
      相关资源
      最近更新 更多