凭什么拒绝我的 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

目录
相关文章
|
API 索引 Python
Sonar分析项目时失败ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
Sonar分析项目时失败ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
Sonar分析项目时失败ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
shiro学习之错误 No realms have been configured! One or more realms must be present to execute an authori
shiro学习之错误 No realms have been configured! One or more realms must be present to execute an authori
|
4月前
|
Kubernetes 容器 Perl
k8s部署seata 报错 没有提供足够的身份验证信息 [ http-nio-7091-exec-2] [ty.JwtAuthenticationEntryPoint] [ commence] [] : Responding with unauthorized error. Message - Full authentication is required to access this resource
Kubernetes pod 在16:12时出现两次错误,错误信息显示需要完整认证才能访问资源。尽管有此错误,但页面可正常访问。附有yaml配置文件的图片。
334 2
|
12月前
【异常解决】postman请求提示Full authentication is required to access this resource
【异常解决】postman请求提示Full authentication is required to access this resource
234 0
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
|
NoSQL Java 程序员
记录:(error) NOAUTH Authentication required...【亲测有效】
记录:(error) NOAUTH Authentication required...【亲测有效】
694 0
|
XML 分布式计算 Hadoop
hiveserver2连接报错: User: root is not allowed to impersonate anonymous (state=08S01,code=0)
hiveserver2连接报错: User: root is not allowed to impersonate anonymous (state=08S01,code=0)
736 0
如何处理错误消息Query XXX is invalid or contains errors
如何处理错误消息Query XXX is invalid or contains errors
161 0
如何处理错误消息Query XXX is invalid or contains errors