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()
謝謝!