凭什么拒绝我的 permissions.query?

简介: 关于 navigator.permission 的一点记录。

最近开发新的剪贴板功能时,发现嵌入在 iframe 内调用 navigator.permission.query 时,state 会直接返回 denied,而独立页面不会有此问题,控制台有没有发现有提示和报错。

尝试 iframe 下通过 top 来调用,有了报错信息:

The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.

完整链接:https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-permissions-in-cross-origin-iframes

发现是因为父子页面存在跨域问题,浏览器会默认拒绝所有权限。

想要解决,有两种方案:

  1. 父子页面变成同域,目前文档存在 docs.dingtalk.com  和 alidocs.dingtalk.com 两套域名,需要尽可能收口和统一
  2. 在 iframe 中添加 allow 属性,注明子 iframe 可以使用的权限类型

关于可用的权限类型:https://developer.mozilla.org/en-US/docs/Web/HTTP/Feature_Policy

https://stackoverflow.com/questions/61401384/can-text-within-an-iframe-be-copied-to-clipboard

目录
相关文章
|
6月前
|
Java 关系型数据库 MySQL
记录解决一个小错误:Establishing SSL connection without server‘s identity verification is not recommended
本文记录了解决Spring Boot连接MySQL时出现的SSL连接警告问题的步骤,通过在数据源配置中添加`useSSL=false`来禁用SSL连接。
EnvironmentNotWritableError: The current user does not have write permissions to the targe...
EnvironmentNotWritableError: The current user does not have write permissions to the targe...
1967 0
【异常解决】postman请求提示Full authentication is required to access this resource
【异常解决】postman请求提示Full authentication is required to access this resource
706 0
|
SQL 监控 关系型数据库
问题整理:ZABBIX4.0登录界面出现错误 SQL statement execution has failed “INSERT INTO sessions (sessionid,userid,..
问题整理:ZABBIX4.0登录界面出现错误 SQL statement execution has failed “INSERT INTO sessions (sessionid,userid,..
487 0
问题整理:ZABBIX4.0登录界面出现错误 SQL statement execution has failed “INSERT INTO sessions (sessionid,userid,..
|
Java Go
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
|
Oracle 关系型数据库 数据库
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
|
NoSQL Java 程序员
记录:(error) NOAUTH Authentication required...【亲测有效】
记录:(error) NOAUTH Authentication required...【亲测有效】
756 0
|
关系型数据库 MySQL 数据安全/隐私保护
Could not obtain connection to query metadata : Public Key Retrieval is not allowed
Could not obtain connection to query metadata : Public Key Retrieval is not allowed
599 0