简体   繁体   English

WCF服务登录和操作权限

[英]WCF service login and operation permissions

For a WCF service host implementation, I need to roll my own authentication & authorization procedure, but I can't find any information about how WCF supports this. 对于WCF服务主机实现,我需要滚动自己的身份验证和授权过程,但找不到有关WCF如何支持此功能的任何信息。 The system should be pretty straight forward using Username , Password for authentication and Role to check for operation permissions. 使用UsernamePassword进行身份验证和Role来检查操作权限,系统应该非常简单。

In WPF documentations and tutorials, all I found is authentication using WinLogon, IIS login or security certificate and permissions using ASP.Net roles and security realms. 在WPF文档和教程中,我发现的只是使用WinLogon进行身份验证,IIS登录或安全证书以及使用ASP.Net角色和安全领域的权限。 What I would like to have is (pseudo example): 我想拥有的是(伪示例):

myChannelFactory.Username = "myuser";
myChannelFactory.Password = "mypass";
myChannelFactory.CreateChannel();

and for operation contracts 和运营合同

[OperationContract(Permission = MySecurityRoles.Administrator)]
public bool Reboot();

There are many possibilities how you could achieve this. 如何实现此目标有很多可能性。

You could use sessions and authenticate in the first call by passing username and password to the server. 您可以通过将用户名和密码传递给服务器来使用会话并在第一个调用中进行身份验证。

http://www.codeproject.com/Articles/188749/WCF-Sessions-Brief-Introduction http://www.codeproject.com/Articles/188749/WCF-Sessions-Brief-Introduction

Or you could (as you do in the example code) use the existing features and create a custom Username and Password validator on the server. 或者,您可以(如示例代码中所做的那样)使用现有功能并在服务器上创建自定义的用户名和密码验证器。 This example is quite nice: 这个例子很好:

http://msdn.microsoft.com/en-us/library/aa702565.aspx http://msdn.microsoft.com/en-us/library/aa702565.aspx

You can then check the role in the actual implementation. 然后,您可以检查实际实施中的角色。

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

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