gpt4 book ai didi

c# - ServiceStack 凭据 auth 端点给出 404

转载 作者:行者123 更新时间:2023-11-30 16:22:37 25 4
gpt4 key购买 nike

我在 IIS 7.5 上运行一个 ServiceStack 应用程序,在 /auth/credentials 服务一个自定义的 CredentialsAuthProvider。

它在 Visual Studio 中运行良好,但当我将它安装在生产服务器(也是 IIS 7.5)上时,它对所有对 /auth/credentials 的请求响应 404。为 REST 端点提供服务没有任何问题,如果我将提供者的父类(super class)更改为 BasicAuthProvider,身份验证就可以工作,但我想使用表单而不是基本身份验证。我怎样才能让它正确地为身份验证端点提供服务?

这是我的 Web.config 的样子:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
<location path="auth">
<system.web>
<customErrors mode="Off"/>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
</location>
<location path="rest">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>

<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>

<!-- Required for MONO -->
<system.web>
<httpHandlers>
<add path="rest*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
<add path="auth*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" prefixLanguageFilePath="" path="https://nearme.solarcity.com" responseMode="Redirect" />
</httpErrors>
<!--<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>-->
<!--uncomment this to stop IIS 7.5 from blocking PUT and DELETE-->
</system.webServer>
</configuration>

最佳答案

您在配置中做出了错误的假设。

您只能将 ServiceStack 托管在单一路径,该路径位于根路径 * 或通常按照惯例为 /api 的自定义路径/servicestack 但可以是您选择的任何名称。 HelloWorld 教程 shows an example configuration for both supported options .

通过使用 [Authenticate] 属性装饰 Request DTO 或 Service 来强制执行身份验证。如果您愿意,您还可以将属性添加到自定义基类,例如AuthenticatedServiceBase 这将确保所有子类也需要身份验证。

关于c# - ServiceStack 凭据 auth 端点给出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12311675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com