MM-53147 Support for embedding Mattermost in an MSTeams iframe (#23776)

* add teams to allowed frame-ancestors

* fix unit tests

* set SameSite attribute for session cookie

* further restrict ancestors

* skip landing page if in iframe

* Only set cookie SameSite=None if embedded in iframe

* don't set MMEMBED cookie on landing page (check only)

* fully parse MMEMBED cookie

* add comment

* more comments

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Doug Lauder
2023-07-12 17:55:13 -04:00
коммит произвёл GitHub
родитель cc6de45bde
Коммит a8244e9d10
7 изменённых файлов: 48 добавлений и 8 удалений

Просмотреть файл

@@ -79,6 +79,20 @@ export default class LinkingLandingPage extends PureComponent<Props, State> {
return landingPreference && landingPreference === LandingPreferenceTypes.BROWSER;
};
isEmbedded = () => {
// this cookie is set by any plugin that facilitates iframe embedding (e.g. mattermost-plugin-msteams-sync).
const cookieName = 'MMEMBED';
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.startsWith(cookieName + '=')) {
const value = cookie.substring(cookieName.length + 1);
return decodeURIComponent(value) === '1';
}
}
return false;
};
checkLandingPreferenceApp = () => {
const landingPreference = BrowserStore.getLandingPreference(this.props.siteUrl);
return landingPreference && landingPreference === LandingPreferenceTypes.MATTERMOSTAPP;
@@ -435,7 +449,7 @@ export default class LinkingLandingPage extends PureComponent<Props, State> {
render() {
const isMobile = UserAgent.isMobile();
if (this.checkLandingPreferenceBrowser()) {
if (this.checkLandingPreferenceBrowser() || this.isEmbedded()) {
this.openInBrowser();
return null;
}