如何保护我的AngularJS和Web API应用 [英] How to secure my AngularJS and Web Api application

查看:150
本文介绍了如何保护我的AngularJS和Web API应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用与ASP.NET的Web API服务器端AngularJS。在我看来,就像认证现已成为一件轻而易举的事?或者这是太好了,是真的吗?

I am using AngularJS with ASP.NET Web Api server side. Seems to me like authentication has now become a breeze? Or is this too good to be true?

所以我想用网页API的个人用户帐户身份验证。而我想这是所有我需要的。只要每一个请求进行身份验证并没有人可以得到任何数据,他们不应该我应该不需要做太多的吧?

So I'm thinking of using the Web Api's "Individual User Accounts" authentication. And I am thinking that is all I need. As long as every request is authenticated and noone can get any data they shouldn't I shouldn't need to do much more right?

还是我失去了一些关键的安全基础知识?

Or am I missing some key security fundamentals?

推荐答案

当谈到确保您有两种主要方法的API

When it comes to securing the API you have two main approaches


  1. 基于Cookie的做法。这是传统的方式,在您使用标准形式来验证用户,然后设置窗体身份验证cookie。所有未经授权的请求采取用户登录页面。如果您的API总是由UI支持前做到底登录此方法的工作。

  2. 其次,使用在所述请求的首部的授权令牌。一旦用户通过验证,他得到一个身份验证令牌,他有附加在授权HTTP头每个后续请求。了解更多关于它在这里的ASP.NET Web API 个人帐户。这里的好处是,你可以暴露你的API,而无需登录页面。

但如果使用第二种方法时,请记住,身份验证令牌有所有后续请求需要此令牌被存储在客户端。看看这个博客帖子饼干VS令牌。获取正确的权威性与Angular.JS ,以了解如何与令牌工作。

But remember when using the second approach, the auth token has to be stored on the client side as all subsequent request require this token. Look at this blog post Cookies vs Tokens. Getting auth right with Angular.JS to understand how to work with token.

希望它帮助。

这篇关于如何保护我的AngularJS和Web API应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆