Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get Servicestack Authentication to work in an Umbraco installtion
    primarykey
    data
    text
    <p>I can't get SS authentication to work together with an Umbraco installation. Whenever I access a DTO or service with the Authenticate attribute, I get redirected to an umbraco login. To reproduce: I've created a new project, and installed Umbraco from Nuget (tried 4.7.1, 4.8.1 and 4.9.0 with same result), and SS from Nuget. I setup SS to run under the /api path in the web.config:</p> <pre><code> &lt;location path="api"&gt; &lt;system.web&gt; &lt;httpHandlers&gt; &lt;add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" /&gt; &lt;/httpHandlers&gt; &lt;/system.web&gt; &lt;!-- Required for IIS 7.0 --&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true" /&gt; &lt;validation validateIntegratedModeConfiguration="false" /&gt; &lt;handlers&gt; &lt;add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /&gt; &lt;/handlers&gt; &lt;/system.webServer&gt; &lt;/location&gt; </code></pre> <p>and added /api to reserved paths to avoid Umbraco handling this:</p> <pre><code>&lt;add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/api" /&gt; </code></pre> <p>And in the AppHost.cs I've changed the EndpointHostConfig and enabled authentication:</p> <pre><code> SetConfig(new EndpointHostConfig { DebugMode = true, //Show StackTraces when developing ServiceStackHandlerFactoryPath = "api" }); //Enable Authentication ConfigureAuth(container); </code></pre> <p>And I've changed the connectionstring in ConfigureAuth to use the Umbraco database:</p> <pre><code> var connectionString = ConfigurationManager.AppSettings["umbracoDbDSN"]; </code></pre> <p>Finally I set the attribute on HelloWorldService:</p> <pre><code>[Authenticate] public class HelloService : ServiceBase&lt;Hello&gt; { protected override object Run(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } </code></pre> <p>I then access the HelloWorldService through REST Uri:</p> <pre><code>http://localhost:56835/api/hello </code></pre> <p>and right away I'm redirected to:</p> <pre><code>http://localhost:56835/apilogin?redirect=http%3a%2f%2flocalhost%3a56835%2fapi%2fhello </code></pre> <p>and presented with the default Umbraco 404 page, which means that SS suddenly makes Umbraco handle the authentication. If I remove the Authenticate attribute, SS handles the request perfectly.</p> <p>What am I missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload