Is claims-based authorisation supported in Service Fabric stateless services?
Let's say that I have a web api that receives a JWT in the header. Can I pass the JWT or claims within to a Service fabric stateless service so that it can do some checking on the claims before performing sensitive operations?
I can see that we can pass in claims to a service by using ClaimsCredentials:
var serviceProxyFactory = new ServiceProxyFactory(
(callbackClient) => new FabricTransportServiceRemotingClientFactory(
new FabricTransportSettings
{
SecurityCredentials = new ClaimsCredentials
{
LocalClaims = "[JWT HERE? or just Claims JSON?]"
}
}));
IMyService service = serviceProxyFactory.CreateServiceProxy<IMyService>(new Uri("fabric:/MyThing/MyService"));
https://msdn.microsoft.com/en-us/library/azure/system.fabric.claimscredentials.localclaims.aspx says that LocalClaims is "the string representation of claims token acquired from STS (security token service)."
Also:
Is ClaimsCredentials actually the base64 encoded JWT, or just a JSON payload of claim key:value properties?
Is there any specific configuration or code needed to be done in the stateless service?
How do you get access to the claims from the stateless service?
At the moment, when I call the service, I get the following error, no matter what value I set LocalClaims to:
System.Fabric.FabricCannotConnectException: Error in Connection during ServiceCommunication
---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C4C\r\n
at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Common.NativeServiceCommunication.IFabricServiceCommunicationClient2.EndRequest(IFabricAsyncOperationContext context)\r\n
at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Client.NativeServiceCommunicationClient.EndRequest(IFabricAsyncOperationContext context)\r\n at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously)\r\n --- End of inner exception stack trace ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Client.NativeServiceCommunicationClient.<RequestResponseAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__7`1.MoveNext()
Thanks!