Security 什么机制可以阻止用户修改Angular2应用程序代码?
我正在使用Angular2编写一个应用程序,当涉及到保护应用程序的一些管理部分时,我计划遵循Angular2网站中建议的方法: 因此,我将以这样一个类结束:Security 什么机制可以阻止用户修改Angular2应用程序代码?,security,angular,Security,Angular,我正在使用Angular2编写一个应用程序,当涉及到保护应用程序的一些管理部分时,我计划遵循Angular2网站中建议的方法: 因此,我将以这样一个类结束: @Injectable() export class AuthGuard implements CanActivate, CanActivateChild { constructor(private authService: AuthService, private router: Router) {} canActivate(r
@Injectable()
export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private authService: AuthService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
// Use my service to determine if user is logged in and has credentials
return this.authService.canHaveAccess();
}
}
一旦转换成JS代码并在我的用户浏览器上执行,什么会阻止用户重新定义canActivate
方法,从而绕过对canHaveAccess
的调用,而总是返回true
?无
如果你依赖用户浏览器中的代码来保证你的应用程序的安全,你就注定要失败
需要在服务器上实施安全性。在浏览器中,防护装置仅为方便用户,不显示与用户无关的选项和表单,但此类措施与安全性无关