Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Auth banner for EE #23091

Merged
merged 9 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/startup/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,5 @@ import './v228';
import './v229';
import './v230';
import './v231';
import './v232';
import './xrun';
4 changes: 3 additions & 1 deletion server/startup/migrations/v231.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BannerPlatform } from '../../../definition/IBanner';
import { Banner } from '../../sdk';
import { settings } from '../../../app/settings/server';
import { Settings } from '../../../app/models/server';
import { isEnterprise } from '../../../ee/app/license/server';

Migrations.add({
version: 231,
Expand All @@ -21,7 +22,8 @@ Migrations.add({

const isAuthServiceEnabled = LDAPEnabled || SAMLEnabled || CustomOauthEnabled;

if (!isAuthServiceEnabled) {
const isEE = isEnterprise();
if (!isAuthServiceEnabled || isEE) {
return;
}

Expand Down
40 changes: 40 additions & 0 deletions server/startup/migrations/v232.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Migrations } from '../../../app/migrations/server';
import { isEnterprise } from '../../../ee/app/license/server';
import { Users, Settings } from '../../../app/models/server/raw';
import { Banner } from '../../sdk';
import { BannerPlatform } from '../../../definition/IBanner';
import { IUser } from '../../../definition/IUser';
import { settings } from '../../../app/settings/server';

Migrations.add({
version: 232,
up() {
const query = {
_id: { $in: [/^Accounts_OAuth_Custom-?([^-_]+)$/] },
value: true,
};

const isCustomOAuthEnabled = !!Promise.await(Settings.findOne(query));
const LDAPEnabled = settings.get('LDAP_Enable');
const SAMLEnabled = settings.get('SAML_Custom_Default');

const isEE = isEnterprise();

if (!isEE && (isCustomOAuthEnabled || LDAPEnabled || SAMLEnabled)) {
return;
}

const admins = Promise.await(Users.find<IUser>({ roles: 'admin' }, {}).toArray());

const banners = admins.map((a) => Promise.await(Banner.getNewBannersForUser(a._id, BannerPlatform.Web))).flat();
const msg = 'Please notice that after the next release (4.0) advanced functionalities of LDAP, SAML, and Custom Oauth will be available only in Enterprise Edition and Gold plan. Check the official announcement for more info: https://go.rocket.chat/i/authentication-changes';
// @ts-ignore
const authBanner = banners.find((b) => b.view.blocks[0].text.text === msg);

if (!authBanner) {
return;
}

admins.map((a) => Banner.dismiss(a._id, authBanner._id));
},
});