实现通过OAuth和单页应用程序Web API [英] Implement Web API with OAuth and a Single Page Application

查看:178
本文介绍了实现通过OAuth和单页应用程序Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个API和一个单页的应用程序(也就是它更可能的未来的消费者之一)。

We're developing an API and a single page application (that is one of more possible future consumers of it).

我们已经开始在网络上的API,并基本落实非常类似的系统之一约翰爸爸在他的pluralsight当然,名为大厦单页应用(SPA)与HTML5,的ASP.NET Web API,淘汰赛和制作jQuery的。

We already started on the web API, and basically implemented a system very similar to the one John Papa made in his course on pluralsight, named "Building Single Page Apps (SPA) with HTML5, ASP.NET Web API, Knockout and jQuery".

我们现在需要实现认证和用户在该应用程序管理,需要寻找出最简单的方式来实现这个在短短的时间尽可能我们在赶时间。

We now need to implement authentication and user managing in this application and need to find the easy way out to implement this in as little time as possible as we are in a hurry.

我们实现了包含在ASP.NET更新SPA模板有非常相似的功能,我们的需求,但我们不知道什么是最好的方法,在我们现有的code实现类似的功能。

We realized the SPA template included in the ASP.NET update had very similar features to our needs, but we wonder what the best approach to implement a similar feature in our existing code.

我们都是新手的开发人员,你可能身影。

We are novice developers, as you might figure.

是否有可能nstall一些软件包使用包管理器,瞧,一个简单的会员和OAuth身份验证选项是现成的?

Is it possible nstall some packages using the package manager, and voila, a simple membership and OAuth auth option be readily available?

我们的使用情况是,我们需要根据角色来保护我们的API一些资源,这应该能够登录使用的用户名和密码,还要登录使用那些Facebook,谷歌或Twitter帐户。

Our use case is that we need to protect some resources on our API based on roles, and that one should be able to log in using a username and password, but also log in using ones facebook, google, or twitter account.

推荐答案

我们最终与SPA模板去了,对API(单独MVC一部分)做认证。
然后该API将产生唯一令牌和用户重定向到前端与网址参数令牌

We eventually went with the SPA template, doing authentication on the API (separate MVC part). Then the API would generate a unique token and redirect the user to the front-end with the token in url parameters.

前端则需要发送此令牌上的每个后续请求。

The front-end then needs to send this token on every subsequent request.

这篇关于实现通过OAuth和单页应用程序Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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