I’m calling from an integration test based on AppHostBase, with the following plugins added for auth:
plugins.Add(new AuthFeature(() =>
new AuthUserSession(),
new IAuthProvider[] {
new CredentialsAuthProvider {SkipPasswordVerificationForInProcessRequests = true}
})
The SkipPassword… thing is something I tried to see if it helped, but it didn’t.
Then there’s more:
container.Register(new ServiceStack.Caching.MemoryCacheClient());
var userRep = new InMemoryAuthRepository(); userRep.Clear();
container.Register<IAuthRepository>(userRep);
and some CreateUser calls based off examples in the docs.
Finally this:
plugins.Add(new ServiceStack.Validation.ValidationFeature()); // needed for the DTO auth attributes to work
Service A has the Authenticate attribute on top like this:
[Authenticate]
public class ProcessInstanceServices : Service
and nothing on the DTO (just Route).
It uses the Gateway
object inside.
Service B is very much the same:
[Authenticate]
public class TeamServices : Service, ITeamServices
and nothing on the DTO except for the regular:
[Route("/teams/candidate","GET")]
public class GetTeamMemberCandidate : IReturn<GetTeamMemberCandidateResponse>, IGet
Side note: The Gateway object is passed down from the service into a static function, just because I didn’t want all that code in the service, but that shouldn’t matter.
The call to the gateway is straight forward (lowercase gateway, because I passed it as a param to a static function as myfunc(IServiceGateway gateway):
var response = gateway.Send(new GetTeamMemberCandidate
{
TeamName = teamName
});
Stack trace:
Stack Trace:
ServiceClientBase.ThrowWebServiceException[TResponse](Exception ex, String requestUri) line 910
ServiceClientBase.ThrowResponseTypeException[TResponse](Object request, Exception ex, String requestUri) line 846
ServiceClientBase.HandleResponseException[TResponse](Exception ex, Object request, String requestUri, Func`1 createWebRequest, Func`2 getResponse, TResponse& response) line 797
ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request) line 1404
ServiceClientBase.Post[TResponse](IReturn`1 requestDto) line 1557
FullProcess_IntegrationTests.HeadsUpTest() line 533
Standard Output:
[18:53:10 ERR] WebException
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at ServiceStack.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/ServiceClientBase.cs:line 1392
```