受限使用的访问令牌
使用受限的访问令牌可防范请求仿冒和重放攻击,确保操作是由收到消息的用户执行的操作。可通过向请求参数添加唯一的令牌参数并在调用操作时验证该参数来实现。
token 参数应作为只能用于特定操作和特定用户的键生成。在执行请求的操作之前,您应检查令牌是否有效,且与您为用户生成的令牌是否一致。如果令牌匹配,则可以执行操作,然后令牌会在日后发出的请求中失效。
访问令牌应作为 HttpActionHandler 的 url
属性的一部分发送给用户。例如,如果您的应用在 http://www.example.com/approve?requestId=123
处理审批请求,则应考虑为其添加额外的 accessToken
参数,并监听发送到 http://www.example.com/approve?requestId=123&accessToken=xyz
的请求。
您必须提前生成组合 requestId=123
和 accessToken=xyz
,以确保无法根据 requestId
推断出 accessToken
。任何包含 requestId=123
但不含 accessToken
或 accessToken
不等于 xyz
的审批请求都应该被拒绝。此请求通过后,日后任何具有相同 ID 和访问令牌的请求也应被拒绝。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-03。
[null,null,["最后更新时间 (UTC):2024-09-03。"],[[["Limited-Use Access Tokens enhance security by mitigating request spoofing and replay attacks, ensuring actions are performed by the intended user."],["These tokens function as unique keys, valid for a specific action and user, verified before the action is executed and invalidated afterward."],["Access tokens are transmitted via the `url` property of the `HttpActionHandler`, requiring developers to include an `accessToken` parameter for verification."],["To ensure security, a unique combination of `requestId` and `accessToken` should be pre-generated, with any request lacking the correct token being rejected."],["Upon successful execution of a request with a valid token, subsequent requests using the same token should be denied to prevent replay attacks."]]],["The core concept is using Limited-Use Access Tokens to secure user actions. A unique token, tied to a specific action and user, is added to request parameters (e.g., in a URL). Before an action executes, the system verifies the token's validity and user association. Valid tokens are then invalidated to prevent reuse. The system should generate the access token, ensuring it's unpredictable from the request ID and reject requests with missing or invalid tokens.\n"]]