我想创建一个网络管理面板。为此,我编写了一个后端控制器来帮助我提供所需的数据......但是,有一些合理的数据,因此,我实现了 HTTP 摘要身份验证。如果您在浏览器中访问该站点,您只需在浏览器生成的登录屏幕(标准浏览器身份验证框)中输入您的用户名和密码,如果用户名/密码正确,则数据显示为 JSON(或其他指定格式 - 这是一个 RESTful API ).
我已经尝试了好几天在 Angular 中实现它,但它不起作用...... - 我找到了一些带有说明的博客文章,但只有 HTTP 基本身份验证 - 我不想使用基本授权。
我尝试向指定的 Url 发送 Get 请求以获取领域/随机数等等,但这不起作用 - 每次我收到标题“WWW-Authenticate”但出现错误消息(401 未授权) (当然 ^^ - 这对我来说很清楚^^)) - 但我无法读出标题以将其用于进一步的步骤(md5(用户名:领域:密码)。这不起作用......我想读出 WWW-Authenticate 标头(使用 X-headername 也不起作用)
sendCredentials()
{
console.log("Send cred");
this.http.get(this.targetUrl, {observe: 'response'}).subscribe(res => {
console.log(res.headers.get('WWW-Authenticate'));
}) //Normally i want to set the nonce here and then i
//want to generate my md5 Value to send this in the next step with a new http get request)
}
我不知道如何解决这个问题 - 谷歌在这种情况下对我没有帮助......
希望有人能帮帮我^^