限定用途的存取權杖
限定存取存取憑證可以防範要求假冒和重播攻擊,確保動作是由使用者寄出。如要獲得保護措施,請在要求參數中加入專屬權杖參數,並在叫用動作時驗證該參數。
符記參數只能用於特定動作以及特定使用者的金鑰。在執行要求的動作之前,您應檢查憑證是否有效,且與您為使用者產生的憑證相符。如果權杖相符,就能執行該動作,而且日後請求將失效。
存取存取憑證應做為 HttpActionHandler 的 url
屬性的一部分傳送給使用者。例如,如果您的應用程式在 http://www.example.com/approve?requestId=123
處理核准要求,請考慮在其中加入額外的 accessToken
參數,並監聽傳送至 http://www.example.com/approve?requestId=123&accessToken=xyz
的要求。
您必須事先產生 requestId=123
和 accessToken=xyz
組合,以確保 accessToken
不會與 requestId
合併。任何含有 requestId=123
且無 accessToken
或 accessToken
不等於 xyz
的核准要求都應遭到拒絕。這項要求處理完畢後,日後也應拒絕所有具有相同 ID 和存取憑證的請求。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-03 (世界標準時間)。
[null,null,["上次更新時間: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"]]