简体   繁体   English

具有承载令牌的Asp.Net身份IUserSecurityStampStore

[英]Asp.Net Identity IUserSecurityStampStore with Bearer Tokens

I'm in the process of building up a ASP.Net WEB API 2 project and I'm using Bearer Tokens for security via OWIN middleware. 我正在建立一个ASP.Net WEB API 2项目,并且正在使用Bearer Tokens通过OWIN中间件实现安全性。

Scenario: 场景:

  • A user via a mobile app authenticates with the web API, receives and access token that is valid for up to 15 days, before the client app has to re-visit the token endpoint. 用户通过移动应用程序通过Web API进行身份验证,接收并访问有效期长达15天的令牌,然后客户端应用程序必须重新访问令牌端点。

  • The logged in user changes there password via the client app. 登录的用户通过客户端应用程序更改密码。 Problem here is that the user's current access token now has the incorrect password, and they still have access. 这里的问题是用户的当前访问令牌现在具有错误的密码,并且他们仍然具有访问权限。

The first question I'd like an answer on :- 我想回答的第一个问题是:-

Is this actually a problem? 这真的有问题吗? or bad.. I'm not sure it is. 还是不好。我不确定是不是。

I know that with cookie authentication you can implement the IUserSecurityStampStore interface and examine the database for changes occurring in the users Identity, which then invalidates the users cookie and a new cookie is required. 我知道使用Cookie身份验证可以实现IUserSecurityStampStore接口,并检查数据库中用户标识中发生的更改,然后使用户cookie无效,并且需要一个新的cookie。

Am I correct in believing this implementation doesn't work with Bearer Tokens? 我是否认为此实现不适用于Bearer Token,是否正确?

Is this something that i need to concern myself with when using Bearer Tokens? 使用Bearer令牌时,我是否需要考虑这一点?

This is part of the fun with access tokens, they're hard to revoke/invalidate. 这是访问令牌带来的乐趣的一部分,它们很难撤消/失效。

It is possible to check and see if the password has changed if you don't mind hitting your identity database each request. 如果您不介意访问每个请求的身份数据库,则可以检查密码是否已更改。 Maybe store the security stamp in the token as a claim and compare this to the up to date stamp? 也许将安全邮票存储在令牌中作为索赔,并将其与最新的邮票进行比较?

But is this actually an issue? 但这实际上是一个问题吗? Depends how important revocation is to you. 取决于撤销对您的重要性。 In most use cases, if you've kept your access token lifetimes short, allowed scopes minimal and don't abuse refresh tokens, you should be good to go. 在大多数使用情况下,如果您使访问令牌的生命周期较短,允许的作用域最小并且不滥用刷新令牌,那么您应该一切顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core 2.0 IAuthorizationService和过期的承载令牌 - ASP.NET Core 2.0 IAuthorizationService And Expired Bearer Tokens ASP.NET 核心 API 使用 JWT 不记名令牌进行身份验证 - ASP.NET Core API authenticate using JWT bearer tokens ASP.NET标识承载令牌。 它坚持不懈? - ASP.NET Identity bearer token. is it persistent? ASP.NET Identity + Bearer Token + Multi-Tenant - ASP.NET Identity + Bearer Token + Multi-Tenant 在ASP.net身份中向Asp.Net Web API 2承载令牌添加声明? - Add Claims to Asp.Net Web API 2 Bearer Token in ASP.net Identity? ASP.NET身份-令牌始终有效吗? (如果是这样,它们如何安全?) - ASP.NET Identity - Are tokens always valid? (If so, how are they safe?) 在ASP.NET Identity 2中哪里可以找到生成的PasswordReset标记? - Where to find Generated PasswordReset Tokens in ASP.NET Identity 2? 使用ASP.NET Core Identity将令牌保存在Cookie中 - Save tokens in Cookie with ASP.NET Core Identity ASP.NET Identity,在 UserTokens 表中存储刷新令牌 - ASP.NET Identity, storing refresh tokens in the UserTokens table 使用Microsoft Graph令牌通过Jwt Bearer令牌保护ASP.NET Core Web API - Using Microsoft Graph token to secure ASP.NET Core Web API with Jwt Bearer tokens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM