我已设置 Azure 移动服务和 AD 以进行身份验证。
通过移动应用程序可以完美地注销和登录。
AD申请回复网址为https://test.azure-mobile.net/signin-aad
client = new MobileServiceClient (applicationURL, applicationKey);
var authResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
var data = await client.InvokeApiAsync("testAPI", HttpMethod.Get, null); //Works
client.Logout(); // LOGOUT
var data = await client.InvokeApiAsync("testAPI", HttpMethod.Get, null); //Unauthorized Error at mobile side. Request not going to API
这个工作很完美。
但是如果我在注销后从 authResult 复制 token ,我可以使用相同的 token 从 postman 调用 API。
Header: X-ZUMO-AUTH → token
如何验证 token ? Azure 移动服务端需要进行任何设置来验证和防止这种情况吗?
最佳答案
当您在客户端上注销时,身份验证 token 将从客户端中删除,但不会向服务器传达任何内容以表明该 token 现在无效。因此,如果 token 存储在其他地方并重新使用,它在过期之前仍然有效。
我不确定有什么好的方法可以做到这一点。您可以重置网站的主 key ,但这会使所有其他 token 无效,因此这并不是一个真正可行的选择。您可以在服务器上存储无效 token 的列表,并在每个请求中检查它们,但这会为每个请求添加一个查找。
这是另一个具有类似答案和其他几个链接的问题:Logout/invalidate a JWT
关于c# - Azure 移动服务 Active Directory 身份验证 X-ZUMO-AUTH token 在注销后在 postman 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34744454/