简体   繁体   English

WCF或Web API中的身份验证形式?

[英]Forms Like Authentication in WCF or Web API?

I currently have a MVC application that is using Forms Authentication. 我目前有一个使用窗体身份验证的MVC应用程序。 I realize that you cannot self host a MVC application. 我意识到您不能自行托管MVC应用程序。 Business requirements dictate that my application has to be self hosted. 业务需求表明我的应用程序必须是自托管的。 I was thinking of creating either a WCF or Web API application that is self hosted, where I can expose various endpoints. 我当时正在考虑创建一个自托管的WCF或Web API应用程序,在这里我可以公开各种端点。 However, the problem I am facing has to do with authentication. 但是,我面临的问题与身份验证有关。 In my MVC, I used Forms Auth, and allowed the user to use a form to enter credentials. 在我的MVC中,我使用了Forms Auth,并允许用户使用表单输入凭据。 How can I do something similar in WCF or Web API. 如何在WCF或Web API中执行类似的操作。 I know how to render the HTML for the login page, etc, but the part that I am not familiar with is how to code up the smarts that anyone who tries to access one of my endpoints needs to be redirected to another service, so that I can do my thing to authenticate them. 我知道如何呈现登录页面等的HTML,但是我不熟悉的部分是如何编写聪明的代码,任何试图访问我的端点之一的人都需要重定向到另一服务,以便我可以做我的事情来验证它们。

I guess I'm trying to do something similar to the Forms Authentication redirect, but, within the context of WCF or Web API. 我想我正在尝试执行类似于“表单身份验证”重定向的操作,但是在WCF或Web API的上下文中。 I started looking into message interceptors and route filters, but, still need to do some research. 我开始研究消息拦截器和路由过滤器,但仍然需要做一些研究。

Any ideas to point me in the right direction ? 有什么想法可以指示我正确的方向吗?

Forms Authentication Control Flow is explained here . 在此说明表单身份验证控制流程。 This is what you need to implement using a DelegatingHandler for ASP.NET Web API. 这是使用DelegatingHandler for ASP.NET Web API来实现的。

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

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