微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Sharepoint MS-WOPI 客户端在编辑时拒绝框架到 iframe,但它允许在预览时框架

如何解决Sharepoint MS-WOPI 客户端在编辑时拒绝框架到 iframe,但它允许在预览时框架

我在 Sharepoint 中有一个 MS-WOPI 客户端,它可以正确接受 URL 请求以打开 Word 文档,例如:

https://myCompany.sharepoint.com/:w:/r/teams/Test-EZ-CO-LON/Test-CO-L1227/_layouts/15/WopiFrame.aspx?sourcedoc=%7BCDE12345-ABC1-4A5F-9097-008E876E4E66%7D&action=interactivepreview

通过直接在浏览器中打开 URL 或将其设置为 iframe 中的源,效果相当好,如下所示:

<iframe _ngcontent-ryg-c10="" frameborder="0" height="750" width="100%" src="https://myCompany.sharepoint.com/:w:/r/teams/Test-EZ-CO-LON/Test-CO-L1227/_layouts/15/WopiFrame.aspx?sourcedoc=%7BCDE12345-ABC1-4A5F-9097-008E876E4E66%7D&action=interactivepreview"></iframe>

因此,该网址对于直接打开和在 iframe 中使用都非常有效。

问题是,如果将 WOPI action value 从“interactivepreview”更改为“edit”之类的编辑操作值,例如,如下所示:

https://myCompany.sharepoint.com/:w:/r/teams/Test-EZ-CO-LON/Test-CO-L1227/_layouts/15/WopiFrame.aspx?sourcedoc=%7BCDE12345-ABC1-4A5F-9097-008E876E4E66%7D&action=edit

直接在 Web 浏览器中打开该 URL 仍然可以正确打开,但是如果在 iframe 中使用这个新 URL,则如下所示:

<iframe _ngcontent-ryg-c10="" frameborder="0" height="750" width="100%" src="https://myCompany.sharepoint.com/:w:/r/teams/Test-EZ-CO-LON/Test-CO-L1227/_layouts/15/WopiFrame.aspx?sourcedoc=%7BCDE12345-ABC1-4A5F-9097-008E876E4E66%7D&action=edit"></iframe>

然后 Sharepoint 拒绝帧,发送此 content security policy 错误消息:

拒绝构建“https://myCompany.sharepoint.com/”,因为祖先违反了以下内容安全策略指令:“frame-ancestors 'self'teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com ”。

所以,总结一下:
  • 对于不可编辑的 WOPI 操作(例如“interactivepreview”),该网址适用于所有场景(在 iframe 和非 iframe 中)。
  • 对于可编辑的 WOPI 操作(例如“编辑”),该网址仅在直接使用(非 iframe)时才有效。
  • 对于可编辑的 WOPI 操作,由于上述错误,该 URL 在 iframe 中使用时不起作用。

这是 WOPI 配置错误、Sharepoint 配置错误、客户端(浏览器)请求配置错误还是其他原因?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。