如何实现在servicestack.net认证 [英] How do you implement authentication in servicestack.net

查看:119
本文介绍了如何实现在servicestack.net认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调查servicestack.net - 但它的例子和文章似乎并不涵盖认证 - 这是由一些处理servicestack.net - ?如果是的话如何

在我特别有兴趣在实施支持:


  • 的OAuth(所以能够检查原始请求,并验证它/前向它传递到servicestack.net处理检索相关的用户信息和准与请求)。

  • 会话/基于Cookie的身份验证(以便允许Ajax客户端已经具备使用该认证,而无需进行显式传递用户名和密码信息,以获得合适的会话令牌与后续请求提交有效的ASP.Net会话)。

有人能指出我的文档/使用ServiceStack.Net框架时表现出的认证/安全实例的方向。


解决方案

编辑:
现在有一个新的<一个href=\"https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization\">Authentication在ServiceStack提供者模型具有以下内置提供商:


  • 证书 - 对于带有用户名/密码进行身份验证凭据。例如形式验证

  • 基本验证 - 允许用户使用基本身份验证验证

  • 的Twitter的OAuth - 允许用户注册,并与Twitter进行身份验证

  • 的Facebook的OAuth - 允许用户注册,并与Facebook验证

新的身份验证提供者模型是完全可选的,是建立在ServiceStack现有的请求/响应过滤器顶部的用户级库。

有关如何创建自己的支票本线程在ServiceStack身份验证选项的详细信息。

<一个href=\"https://groups.google.com/d/topic/servicestack/U3XH9h7T4K0/discussion\">https://groups.google.com/d/topic/servicestack/U3XH9h7T4K0/discussion

基本上,你可以使用请求过滤器拦截请求或基类来添加通用验证逻辑。线程包含这两个选项的例子。

另外,您可以用另一个ASP.NET Web框架共同主办ServiceStack所以你可以使用其内置的身份验证提供者,只是使用请求过滤器和饼干验证在ServiceStack一个有效的用户会话。<​​/ P>

下面是<一个例子href=\"https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.WebHost.Endpoints.Tests/RequestFiltersTests.cs\">implementing HTTP基本认证与请求过滤器

I'm investigating servicestack.net - but it's examples and articles don't seem to cover authentication - is this something handled by servicestack.net - and if so how?

In particular I'm interested in implementing support for:

  • OAuth (So being able to inspect the raw request and validate it/retrieve the associated user info and associate with the request prior to passing it onto servicestack.net for processing).
  • Session/cookie based authentication (so allowing for Ajax clients which already have a valid ASP.Net session to use that for authentication, instead of needing to explicitly pass login and password details to obtain a session token suitable for submitting with subsequent requests).

Could someone point me in the direction of documentation/examples that demonstrate authentication/security when using the ServiceStack.Net framework.

解决方案

Edit: There is now a new Authentication provider model in ServiceStack with the following built-in providers:

  • Credentials - For authenticating with username/password credentials. e.g. Form Auth
  • Basic Auth - Allowing users to authenticate with Basic Authentication
  • Twitter OAuth - Allow users to Register and Authenticate with Twitter
  • Facebook OAuth - Allow users to Register and Authenticate with Facebook

The new auth provider model is entirely optional and is a user-level library built on top of ServiceStack's existing Request / Response filters.

For more info on how to create your own check this thread for authentication options in ServiceStack.

https://groups.google.com/d/topic/servicestack/U3XH9h7T4K0/discussion

Basically you can use Request filters to intercept the request or a base class to add generic validation logic. The thread contains examples of both options.

Alternatively you can host ServiceStack together with another ASP.NET web framework so you can use its built-in auth provider, and just validate a valid user session in ServiceStack using Request Filters and cookies.

Here's an example of implementing HTTP Basic Auth with Request filters

这篇关于如何实现在servicestack.net认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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