【发布时间】:2019-07-19 13:07:45
【问题描述】:
我正在尝试https://jsreport.net/learn/authentication:
....
"extensions": {
"authentication": {
"cookieSession": {
"secret": "<your strong secret here>"
},
"admin": {
"username": "admin",
"password": "password"
},
"enabled": true
},
......
我还阅读了以下内容:
在启用此扩展时,您需要在每个请求中添加标头。
授权:基本 QWxhZGRpbjpvcGVuIHNlc2FtZQ==
其中哈希基于用户名和密码:base64(username:password)
我尝试同时使用QWxhZGRpbjpvcGVuIHNlc2FtZQ== 和https://www.motobit.com/util/base64-decoder-encoder.asp 进行编码:admin:password 结果:YWRtaW46cGFzc3dvcmQ=。在尝试这两种方法时,我似乎无法访问我的 API。
(请注意,下面的键是我尝试过的上述任何一个)
我尝试过对 jsreport API 进行前端调用:return this.http.post(this.hosturl, parameter, { headers: 'Content-Type': 'application/json', 'Authorization': 'Basic ' + this.key }, responseType: 'blob' });
我也试过放在后端调用jsreport API:
var data = {
headers: {
"Authorization" : "Basic key"
},
template: { "shortid": shortid },
options: {
preview: preview
}
}
知道为什么它总是在前端(角度)返回未经授权并在后端(快速)提示登录吗?
PS:在后台 API 提示用户名:管理员和密码:密码由于某种原因不起作用。
我只设法使用用户名:admin 和密码:password 从 jsreport 工作室登录。
任何想法都值得赞赏。
【问题讨论】: