外面的WebAPI在WebApi.Owin燮pressDefaultHostAuthentication也燮pressing认证 [英] SuppressDefaultHostAuthentication in WebApi.Owin also suppressing authentication outside webapi

查看:208
本文介绍了外面的WebAPI在WebApi.Owin燮pressDefaultHostAuthentication也燮pressing认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我曾经从Visual Studio SPA模板部件具有账户控制器中的WebAPI与OAuth认证的解决方案。

I am running into a problem with a solution where I used parts from the Visual Studio SPA template for having the Account Controller in WebApi with Oauth Authentication.

  app.UseOAuthBearerTokens(OAuthOptions);

然后我在owin的WebAPI登记做

Then I in the owin webapi registration is doing

config.SuppressDefaultHostAuthentication(); 

但是这也肃presses的的WebAPI环境之外默认的Cookie认证。这是意图。如果是这样,我怎么能的WebAPI设置为苏preSS Cookie身份验证,但它仍然活跃翻过其他请求环境?

but this also supresses the default cookie authentication outside the webapi environment. Is this the intention. If so, how can I set up WebApi to supress cookie authentication but its still active accross the environment for other requests?

推荐答案

这似乎是一个很好的做法,尤其是当你与混合的OWIN托管的应用程序,并在同一个IIS目录定期的,设置的WebAPI app.Map。

It seems that it is a good practice, especially when you mix an OWIN-hosted app and a regular one on the same IIS dir, to setup WebApi with the app.Map.

    public void Configuration(IAppBuilder app)
    {
        var configuration = WebApiConfiguration.HttpConfiguration;
        app.Map("/api", inner =>
        {
            inner.UseWebApi(configuration);
        });
    }

我有我的所有控制器与APIpreFIX路线配置,并且我刚搬到那到地图函数。现在的WebAPI运行孤立,它的工作原理与我的应用程序的其余部分。感谢@PinpointTownes指着我这个方向发展。

I had all my controllers configured with a "api" prefix route, and I just moved that to the map function instead. Now webapi is running isolated and it works out with the rest of my application. Thanks @PinpointTownes for pointing me in this direction.

这篇关于外面的WebAPI在WebApi.Owin燮pressDefaultHostAuthentication也燮pressing认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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