Service Fabric无状态服务支持基于声明的授权吗?如何将声明/ JWT传递给Service Fabric无状态服务?
比方说,我有一个网页api接收标题中的智威汤逊。我可以将JWT或索赔转交给服务架构无状态服务,以便在执行敏感操作之前可以对索赔进行一些检查吗?
我可以看到,我们可以通过使用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说LocalClaims是“索赔的字符串表示令牌从STS(安全令牌服务)获得的。”
另外:
是ClaimsCredentials实际编码智威汤逊中的Base64,或者只是要求关键的JSON有效载荷:值属性?
是否需要在无状态服务中完成特定的配置或代码?
您如何获得无状态服务的索赔?
此刻,当我打电话的服务,我得到以下错误,不管什么样的价值没有我设置LocalClaims到:
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()
谢谢!