โทเค็นเพื่อการเข้าถึงแบบจำกัด
โทเค็นเพื่อการเข้าถึงแบบจํากัดจะช่วยป้องกันการปลอมแปลงคําขอและการโจมตีแบบเล่นซ้ําเพื่อให้มั่นใจว่าจะมีการดําเนินการโดยผู้ใช้เมื่อมีการส่งข้อความ คุณจะได้รับการป้องกันโดยการเพิ่มพารามิเตอร์โทเค็นที่ไม่ซ้ํากันลงในพารามิเตอร์คําขอและยืนยันเมื่อมีการเรียกใช้การทํางาน
คุณควรสร้างพารามิเตอร์โทเค็นเป็นคีย์ที่ใช้ได้เฉพาะกับการกระทําบางอย่างและผู้ใช้บางรายเท่านั้น ก่อนดําเนินการตามที่ขอ คุณควรตรวจสอบว่าโทเค็นถูกต้องและตรงกับโทเค็นที่คุณสร้างขึ้นสําหรับผู้ใช้ หากโทเค็นตรงกัน ก็จะดําเนินการและโทเค็นไม่ถูกต้องสําหรับคําขอในอนาคต
ควรส่งโทเค็นเพื่อการเข้าถึงให้กับผู้ใช้ที่เป็นส่วนหนึ่งของพร็อพเพอร์ตี้ url
ของ HttpActionHandler เช่น หากแอปพลิเคชันจัดการคําขออนุมัติที่ 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
ควรถูกปฏิเสธ เมื่อดําเนินการตามคําขอแล้ว ระบบจะปฏิเสธคําขอในอนาคตที่มีรหัสและโทเค็นการเข้าถึงเดียวกันด้วย
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-09-03 UTC
[null,null,["อัปเดตล่าสุด 2024-09-03 UTC"],[[["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"]]