【发布时间】:2016-04-28 12:12:15
【问题描述】:
我正在使用 Node.js 和 AngularJS 构建一个项目。 我项目中的一些视图和操作需要授权。
在 ASP.NET 中,当用户的凭据正确时,我曾经简单地将用户 ID 或用户对象保存在 Session 中,然后在每个页面和操作中,我会检查用户是否有权限,如果没有,我会使用响应。重定向。这么简单!
现在我使用 Node.js 和 AngularJS,这可能是当今构建网站时最流行的组合,我希望有一种非常简单快捷的方式(甚至是第三方)来实现授权,就像在 ASP 中一样。网。
不幸的是,我只找到了一堆包含无数代码行的实现示例,并将我变成了一个了解令牌等知识的信息安全专家。以下是我找到的一些文章:
Best practices for authentication and authorization in Angular without breaking RESTful principles?
http://frederiknakstad.com/2013/01/21/authentication-in-single-page-applications-with-angular-js/
https://www.theodo.fr/blog/2015/08/handling-basic-route-authorization-in-angularjs/
http://code.tutsplus.com/tutorials/token-based-authentication-with-angularjs-nodejs--cms-22543
http://www.kdelemme.com/2014/03/09/authentication-with-angularjs-and-a-node-js-rest-api/
有没有什么简单的方法可以实现认证+授权+路由到未经授权的页面,而不需要写那么多行代码?
任何帮助将不胜感激!
【问题讨论】:
-
MeteorJS 是一个基于节点的框架,具有非常容易设置的身份验证和前端对角度的支持。 www.meteor.com
-
@Julian Mann 谢谢。我读过关于 Meteor 的文章,它似乎可以完成这项工作。由于我还没有得到更好的解决方案,请将其重写为答案,我会将其标记为正确答案。
标签: angularjs node.js authentication authorization restful-authentication