简体   繁体   English

2向SSL身份验证和请求授权

[英]2-Way SSL authentication and request authorization

I am starting to develop a RESTful API (with WCF) which will be working in 2Way SSL authentication - client side certifications and server side certification. 我开始开发一个RESTful API(带有WCF),它将用于2Way SSL身份验证-客户端认证和服务器端认证。

As I understand, there will be no need for password/username because the client is already authenticated by the client-side certificate. 据我了解,由于客户端已经通过客户端证书进行了身份验证,因此不需要密码/用户名。

My problem is that some of the exposed methods should be restricted to specific clients only. 我的问题是,某些公开的方法应仅限于特定的客户端。

So, I also need some form of authorization. 因此,我还需要某种形式的授权。 I thought about using a secret key which will be supplied to clients which are authorized of specific functions, but then I realized that this clients will already be having client-side certificates which can possibly be used for authorization. 我考虑过使用将提供给具有特定功能授权的客户端的密钥,但是后来我意识到该客户端已经具有可以用于授权的客户端证书。

Is there any way to get the name of the currently used client-side certificate in a programmatic way and then authorize by the certificate name? 有什么方法可以通过编程方式获取当前使用的客户端证书的名称,然后通过证书名称进行授权?

somethine like this: 像这样的东西:

string clientCertificate = CertificateAuthority.GetCurrentCertificate;
if (Authorize(clientCertificate))
     doSomething()

Yes there are such methods, most noticeable the X509Certificate2.GetNameInfo Method . 是的,有这样的方法,最引人注目的是X509Certificate2.GetNameInfo方法
(BTW, Dominick Baier has an excellent fluent API extension for that) (顺便说一句, Dominick Baier为此提供了出色的流利API扩展

However, I think you should take a look at Claims-Based Identity which will give you a much simplified code architecture. 但是,我认为您应该看一下基于声明的身份 ,它将为您提供简化得多的代码体系结构。

The identity of the certificate holder is in the SubjectDN of the certificate. 证书持有者的身份在证书的SubjectDN中。

The remainder, the authorization part, is application-dependent and varies with your architecture too. 其余部分(授权部分)取决于应用程序,并且也随您的体系结构而变化。 For example, if you are using LDAP you would lookup that user's roles. 例如,如果您使用的是LDAP,则将查找该用户的角色。

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

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