问题标签 [angular2-security]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
14073 浏览

angular -
在 angular2 html 中注入

<div [innerHTML]="html"></div>当 html 包含 iframe 时不起作用。我试图用 做一些安全绕过this.sanitizer.bypassSecurityTrustResourceUrl(...,但它仍然不起作用。

这是angular2 未正确注入的演示。

0 投票
1 回答
4393 浏览

angular - Angular2 CanActivate 防护不起作用

我正在使用Observable<boolean>退货canActivate()。为测试设置了以下功能,它正确解析,组件显示。

但是,实际代码的行为是,尽管控制台输出指示应该激活路由,但我仍停留在登录组件上。与上述测试的唯一真正区别是我调用的是服务this.auth.isAdmin()而不是使用Observable.from. 的结果this.auth.isAdmin()Observable<boolean>一个值为真。

这是路由:

这是我的控制台输出:

如果感兴趣,这里是 isAdmin() 函数:

0 投票
2 回答
569 浏览

angular - Angular 2 ngStyle with browser prefixes

This is not working:

Is there any workaround to avoid Sanitizer? I found a Pipe to bypass the value, but not the property name.

Any ideas to use this property?

0 投票
1 回答
186 浏览

spring-boot - 我们如何使用angular2从springboot服务器访问oauth2访问令牌

我已将授权服务器配置为 public void configure(ClientDetailsS​​erviceConfigurer clients) throws Exception {

那么,基于这个配置,我怎样才能从 angular2 应用程序中获取 access_token 呢?

0 投票
2 回答
10444 浏览

angular - bypassSecurityTrustResourceUrl 和 bypassSecurityTrustUrl 有什么区别

我浏览了这两个功能的角度文档

bypassSecurityTrustUrl

绕过安全性并相信给定的值是一个安全样式的 URL,即可以在超链接或<img src>

bypassSecurityTrustResourceUrl其中说

绕过安全性并相信给定的值是一个安全的资源 URL,即一个可用于加载可执行代码的位置,如<script src><iframe src>

以上两者都用于绕过安全和信任。

我绕过了blob url <img src>,所以在浏览文档之前,我的IDE(vscode)提供了上述两个函数,我使用bypassSecurityTrustResourceUrl了,我的代码就像......这个。

组件.ts

组件.html

根据文档bypassSecurityTrustUrl应该可以工作。但我使用了'bypassSecurityTrustResourceUrl'

它实际上正在工作!!!!

所以我的问题是这两个功能有什么区别。如果可以使用其中任何一个,为什么要使用两个不同的功能?