API Truy cập bộ nhớ (SAA) cho phép các iframe trên nhiều nguồn gốc yêu cầu quyền truy cập vào bộ nhớ khi quyền truy cập bị từ chối theo chế độ cài đặt trình duyệt.
Một số trang web có thể sử dụng cả FedCM để xác thực và SAA để cho phép các iframe trên nhiều nguồn gốc truy cập vào bộ nhớ bắt buộc. Ví dụ: nếu idp.example được nhúng trên rp.example và idp.example cần quyền truy cập vào bộ nhớ của cookie cấp cao nhất để hiển thị nội dung được cá nhân hoá.
Trong trường hợp này, người dùng cần phê duyệt hai lời nhắc khác nhau: một lời nhắc để xác thực và một lời nhắc để cấp quyền truy cập vào cookie, vì SAA sẽ kích hoạt một lời nhắc cấp quyền. FedCM đơn giản hoá quy trình API Truy cập bộ nhớ bằng cách đóng vai trò là tín hiệu tin cậy. Sau khi người dùng đăng nhập bằng FedCM, các yêu cầu truy cập bộ nhớ do IdP khởi tạo sẽ tự động được cấp, giúp người dùng không cần phải trả lời thêm lời nhắc SAA.
// In top-level rp.example:// Ensure FedCM permission has been granted.constcred=awaitnavigator.credentials.get({identity:{providers:[{configURL:'https://idp.example/fedcm.json',clientId:'123',}],}});// In an embedded IdP iframe:// Returns `true` if the user already has access to cookies, and `false` if// the user doesn't have access yet and needs to request it.consthasAccess=awaitdocument.hasStorageAccess()if(!hasAccess){// No user gesture is needed to approve storage access, and the call will be auto-granted.document.requestStorageAccess().then(e=>{//access cookies})}else{//the iframe already has access to third-party cookies}
Những người tham gia thử nghiệm Origin đã đưa ra ý kiến phản hồi tích cực, nêu bật trải nghiệm người dùng được cải thiện nhờ lời nhắc FedCM theo ngữ cảnh cụ thể so với lời nhắc API Truy cập bộ nhớ chung.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2024-11-15 UTC."],[[["Chrome now uses FedCM as a trust signal for the Storage Access API, streamlining cross-origin iframe storage access when users are logged in with FedCM."],["This integration eliminates the need for separate Storage Access API prompts, simplifying the user experience and reducing prompt fatigue."],["Websites using both FedCM and the Storage Access API benefit from this feature, as users only need to authenticate once with FedCM for both login and storage access."],["Developers can learn more about implementation and feedback channels through provided documentation and issue tracking links."],["Positive feedback from origin trial participants suggests that FedCM-based storage access improves user experience compared to generic prompts."]]],["Chrome 131 utilizes FedCM as a trust signal for the Storage Access API (SAA). When a user logs in via FedCM, storage access requests from Identity Providers (IdPs) are automatically granted, removing the need for additional SAA prompts. Websites using both FedCM and SAA see streamlined access. Without FedCM, the user needs to approve separate prompts for authentication and cookie access. `document.requestStorageAccess()` becomes auto-granted, and cookies will be available. If `navigator.credentials.preventSilentAccess()` is called, storage access is not granted until reauthentication.\n"]]