我正在处理的应用程序已经有Spring Security来处理基于表单的身份验证.现在要求是如果在其中一个请求参数中找到令牌,则通过外部服务以编程方式登录用户.
换句话说,如果存在特定的请求参数,例如"令牌",则需要使用该令牌调用外部服务以验证它是否是有效令牌.如果是,那么用户将登录.
我无法弄清楚如何以及在何处"触发"或"挂钩"Spring Security来检查此参数并进行验证,然后在适当时对用户进行身份验证,因为没有登录表单.我认为Spring Security中应该有一些可以扩展或定制的东西来做到这一点?
我浏览了Spring Security文档,想知道AbstractPreAuthenticatedProcessingFilter是否是正确的开始?
我使用window.URL.createObjectURL来创建一个blob:http链接,用于预览img标签中的所选图像:
<img src=""{{itemPhoto}}"" />
Run Code Online (Sandbox Code Playgroud)
itemPhoto是在组件中定义的字段,在选择图像文件时分配:
selectPhoto(photos: any[]) {
if (photos[0]) {
this.itemPhoto = window.URL.createObjectURL(photos[0]);
}
}
Run Code Online (Sandbox Code Playgroud)
这适用于angular2 RC1但不再适用于2.0.0.
以下是进入src属性的内容:
unsafe:blob:http://localhost:5555/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
在阅读其他一些帖子后我尝试了以下内容:
this.itemPhoto = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(photos[0]));
Run Code Online (Sandbox Code Playgroud)
然后以下内容进入src属性:
unsafe:SafeValue must use [property]=binding: blob:http://localhost:5555/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxx (see http://g.co/ng/security#xss)
Run Code Online (Sandbox Code Playgroud)
有什么建议?
非常感谢
更新:好的,我真的不明白src里面的错误信息:"unsafe:SafeValue必须使用[property] = binding:..."
而不是src={{itemPhoto}},以下工作:
<img [src]="itemPhoto" />
Run Code Online (Sandbox Code Playgroud)
仍然不确定为什么.
反正有没有阻止或取消电子页面导航?
win.webContents.on('did-start-loading', function(event, url) {
if (event.sender.getURL().startsWith('http://xyz')) {
event.preventDefault();
}
})
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用,因为事件处理程序在页面继续导航时执行.
同样,我也想对事件'did-get-redirect-request'做同样的事情,以防止发生某些重定向.
非常感谢