在 Office 加载项中检测浏览器 iframe 与本机应用程序
Detecting browser iframe vs native app in Office add-in
我目前正在编写一个 Outlook 加载项,并通过在用户完成加载项中的潜在危险操作之前向用户显示一个确认弹出窗口 window 来实现 clickjacking protection。
当我的加载项在浏览器之外 运行 时,似乎没有必要显示这些弹出窗口(例如在 Mac 的 Outlook 或 Outlook 2016 中)。
有没有办法检测我的加载项在浏览器中是 运行 还是在本机应用程序中是 运行?我考虑过检查用户代理,但这似乎有点脆弱。
编辑:这与 Trusted way to get the host origin of an Office add-in because this question is about whether the add-in is being iframed at all, whereas being iframed is one of the starting assumptions in Trusted way to get the host origin of an Office add-in 不同。
您可以使用 OfficeJsHelpers
检测平台信息(在线与 PC 与 Mac 等),如 In Excel Online, OfficeJS API is not passing the host_Info_ parameter anymore to Excel Add-In
中所述
也就是说,如果您担心的是恶意主机,他们也可以伪造这种行为 return 浏览器实际上是 PC 上的加载项 运行 Office 版本。
https://dev.outlook.com/reference/add-ins/Office.context.mailbox.diagnostics.html#hostName
主机名应该是:Outlook、MacOutlook、OutlookIOS 或 OutlookWebApp
我只是检查 window.self === window.top
来决定是否应该显示点击劫持保护弹出窗口。
我目前正在编写一个 Outlook 加载项,并通过在用户完成加载项中的潜在危险操作之前向用户显示一个确认弹出窗口 window 来实现 clickjacking protection。
当我的加载项在浏览器之外 运行 时,似乎没有必要显示这些弹出窗口(例如在 Mac 的 Outlook 或 Outlook 2016 中)。
有没有办法检测我的加载项在浏览器中是 运行 还是在本机应用程序中是 运行?我考虑过检查用户代理,但这似乎有点脆弱。
编辑:这与 Trusted way to get the host origin of an Office add-in because this question is about whether the add-in is being iframed at all, whereas being iframed is one of the starting assumptions in Trusted way to get the host origin of an Office add-in 不同。
您可以使用 OfficeJsHelpers
检测平台信息(在线与 PC 与 Mac 等),如 In Excel Online, OfficeJS API is not passing the host_Info_ parameter anymore to Excel Add-In
也就是说,如果您担心的是恶意主机,他们也可以伪造这种行为 return 浏览器实际上是 PC 上的加载项 运行 Office 版本。
https://dev.outlook.com/reference/add-ins/Office.context.mailbox.diagnostics.html#hostName
主机名应该是:Outlook、MacOutlook、OutlookIOS 或 OutlookWebApp
我只是检查 window.self === window.top
来决定是否应该显示点击劫持保护弹出窗口。