简体   繁体   English

WCF身份验证服务

[英]WCF authentication service

I am relatively new to the WCF world so my applogies for the newbie question. 我对WCF世界相对较新,所以我的新手问题的applogies。 I am currently designing a layer of WCF services. 我目前正在设计一层WCF服务。 One of them is an authentication service, so I came up with the following authentication mechanism: 其中一个是身份验证服务,所以我提出了以下身份验证机制:

IUserService.TryAuthenticateUser(string username, string password, out string key)

Basicly the user tries to authenticate and if successful - he/she receives a sessionkey/securitykey/whateverkey... the key is then required for every other "WCF action" eg 基本上,用户尝试进行身份验证,如果成功 - 他/她收到一个sessionkey / securitykey / whateverkey ......那么每个其他“WCF动作”都需要密钥,例如

IService.GiveMeMyFeatures(string key);
IService.Method1(string key);

This mechanism looks extremely intuitive for me and is also very easy to implement, so what bothers me is why I cant find similar WCF examples? 这个机制对我来说看起来非常直观,也很容易实现,所以困扰我的是为什么我找不到类似的WCF示例? This unique key (which is practically a session key with wcf-side expiration and all) can then by used from the various applications, according to the application's architecture: for ASP.NEt it can be stored in a cookie, for Winform/WPF/Mobile I guess it can be stored in the form-class in a field and so on... 根据应用程序的体系结构,这个唯一的密钥(实际上是一个具有wcf-side expiration的会话密钥和所有密钥)可以从各种应用程序中使用:对于ASP.NEt它可以存储在cookie中,用于Winform / WPF /移动我想它可以存储在字段中的表单类中等等......

So here comes question number 1: What do you think of this method? 所以这里有问题1:您如何看待这种方法?

I also read, that I can use the build-in ASP.NET Authentication Services (with membership providers etc... if I understood correctly). 我还读过,我可以使用内置的ASP.NET身份验证服务(使用成员资格提供程序等...如果我理解正确的话)。 From architecture point of view I dont really like this method, because when authenticating from an ASP.NET page the workflow will be like this: ASP.NET -> WCF -> ASP.NET Authentication Service -> Response 从架构的角度来看,我真的不喜欢这种方法,因为从ASP.NET页面进行身份验证时,工作流将是这样的:ASP.NET - > WCF - > ASP.NET身份验证服务 - >响应

In this scenario one could also bypass the WCF layer and call the auth. 在这种情况下,还可以绕过WCF层并调用auth。 service methods directly from the asp.net page. 服务方法直接来自asp.net页面。 I know that by going thru the WCF layer for every authentication request I will lose some performance, but it is important for me to have a nice, layered architecture... 我知道,通过WCF层获取每个身份验证请求,我将失去一些性能,但对我来说,拥有一个漂亮的分层架构非常重要......

And here is question number 2: What are the advantages/disadvantages of this method over the first one, and why is it so popular, when from architecture point of view it is kinda wrong? 这里是第2个问题:这个方法比第一个有什么优点/缺点,为什么它如此受欢迎,从架构的角度来看它有点不对?

I also read, that I can send user credentials for every WCF method call and use the built-in mechanism to authenticate and respond properly to the request. 我还读到,我可以为每个WCF方法调用发送用户凭据,并使用内置机制对请求进行身份验证和响应。

Q3: What do you think if this method? Q3:如果这种方法怎么看?

And to sum up - obviously there are many authentication methods, but which one do you think is best and most generic (considering that the WCF services will be called from asp.net/wpf/mobile/etc...)? 总而言之 - 显然有很多身份验证方法,但您认为哪一种最好也是最通用的(考虑到将从asp.net/wpf/mobile/etc调用WCF服务...)?

Thanks is advance :) 谢谢是提前:)

The reason you can't find examples it's not best practice - it's turning something that should be stateless, web services, into something stateful, and something that will not load balance well at all. 你找不到例子的原因并不是最佳实践 - 它将一些应该是无状态的,Web服务转变为有状态的东西,以及根本不能很好地平衡的东西。

As web services already have standard username and password facilities, supported by almost every SOAP stack (excluding Silverlight) that's the way to go. 由于Web服务已经具有标准的用户名和密码设施,几乎每个SOAP堆栈(不包括Silverlight)都支持这种方式。 You can use the standard .NET role based security model to protect your methods with this approach as well. 您也可以使用基于标准.NET角色的安全模型来使用此方法保护您的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM