snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
135
apps/meteor/server/lib/oauth/updateOAuthServices.ts
Normal file
135
apps/meteor/server/lib/oauth/updateOAuthServices.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import type {
|
||||
FacebookOAuthConfiguration,
|
||||
ILoginServiceConfiguration,
|
||||
LinkedinOAuthConfiguration,
|
||||
OAuthConfiguration,
|
||||
TwitterOAuthConfiguration,
|
||||
} from '@rocket.chat/core-typings';
|
||||
import { LoginServiceConfiguration } from '@rocket.chat/models';
|
||||
|
||||
import { addPassportCustomOAuth } from './addPassportCustomOAuth';
|
||||
import { logger } from './logger';
|
||||
import { settings } from '../../settings/cached';
|
||||
import { CustomOAuth } from '../auth-providers/custom-oauth/custom_oauth_server';
|
||||
import { notifyOnLoginServiceConfigurationChanged, notifyOnLoginServiceConfigurationChangedByService } from '../notifyListener';
|
||||
|
||||
export async function updateOAuthServices(): Promise<void> {
|
||||
const services = settings.getByRegexp(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i);
|
||||
const filteredServices = services.filter(([, value]) => typeof value === 'boolean');
|
||||
for await (const [key, value] of filteredServices) {
|
||||
if (key === 'Accounts_OAuth_Use_Modern_Flow') {
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.debug({ oauth_updated: key });
|
||||
let serviceName = key.replace('Accounts_OAuth_', '');
|
||||
if (serviceName === 'Meteor') {
|
||||
serviceName = 'meteor-developer';
|
||||
}
|
||||
if (/Accounts_OAuth_Custom-/.test(key)) {
|
||||
serviceName = key.replace('Accounts_OAuth_Custom-', '');
|
||||
}
|
||||
|
||||
const serviceKey = serviceName.toLowerCase();
|
||||
|
||||
if (value === true) {
|
||||
const data: Partial<ILoginServiceConfiguration & Omit<OAuthConfiguration, '_id'>> = {
|
||||
clientId: settings.get(`${key}_id`),
|
||||
secret: settings.get(`${key}_secret`),
|
||||
};
|
||||
|
||||
if (/Accounts_OAuth_Custom-/.test(key)) {
|
||||
data.custom = true;
|
||||
data.clientId = settings.get(`${key}-id`);
|
||||
data.secret = settings.get(`${key}-secret`);
|
||||
data.serverURL = settings.get(`${key}-url`);
|
||||
data.tokenPath = settings.get(`${key}-token_path`);
|
||||
data.identityPath = settings.get(`${key}-identity_path`);
|
||||
data.authorizePath = settings.get(`${key}-authorize_path`);
|
||||
data.scope = settings.get(`${key}-scope`);
|
||||
data.accessTokenParam = settings.get(`${key}-access_token_param`);
|
||||
data.buttonLabelText = settings.get(`${key}-button_label_text`);
|
||||
data.buttonLabelColor = settings.get(`${key}-button_label_color`);
|
||||
data.loginStyle = settings.get(`${key}-login_style`);
|
||||
data.buttonColor = settings.get(`${key}-button_color`);
|
||||
data.tokenSentVia = settings.get(`${key}-token_sent_via`);
|
||||
data.identityTokenSentVia = settings.get(`${key}-identity_token_sent_via`);
|
||||
data.keyField = settings.get(`${key}-key_field`);
|
||||
data.usernameField = settings.get(`${key}-username_field`);
|
||||
data.emailField = settings.get(`${key}-email_field`);
|
||||
data.nameField = settings.get(`${key}-name_field`);
|
||||
data.avatarField = settings.get(`${key}-avatar_field`);
|
||||
data.rolesClaim = settings.get(`${key}-roles_claim`);
|
||||
data.groupsClaim = settings.get(`${key}-groups_claim`);
|
||||
data.channelsMap = settings.get(`${key}-groups_channel_map`);
|
||||
data.channelsAdmin = settings.get(`${key}-channels_admin`);
|
||||
data.mergeUsers = settings.get(`${key}-merge_users`);
|
||||
data.mergeUsersDistinctServices = settings.get(`${key}-merge_users_distinct_services`);
|
||||
data.mapChannels = settings.get(`${key}-map_channels`);
|
||||
data.mergeRoles = settings.get(`${key}-merge_roles`);
|
||||
data.rolesToSync = settings.get(`${key}-roles_to_sync`);
|
||||
data.showButton = settings.get(`${key}-show_button`);
|
||||
|
||||
const config = {
|
||||
serverURL: data.serverURL,
|
||||
tokenPath: data.tokenPath,
|
||||
identityPath: data.identityPath,
|
||||
authorizePath: data.authorizePath,
|
||||
scope: data.scope,
|
||||
loginStyle: data.loginStyle,
|
||||
tokenSentVia: data.tokenSentVia,
|
||||
identityTokenSentVia: data.identityTokenSentVia,
|
||||
keyField: data.keyField,
|
||||
usernameField: data.usernameField,
|
||||
emailField: data.emailField,
|
||||
nameField: data.nameField,
|
||||
avatarField: data.avatarField,
|
||||
rolesClaim: data.rolesClaim,
|
||||
groupsClaim: data.groupsClaim,
|
||||
mapChannels: data.mapChannels,
|
||||
channelsMap: data.channelsMap,
|
||||
channelsAdmin: data.channelsAdmin,
|
||||
mergeUsers: data.mergeUsers,
|
||||
mergeUsersDistinctServices: data.mergeUsersDistinctServices,
|
||||
mergeRoles: data.mergeRoles,
|
||||
rolesToSync: data.rolesToSync,
|
||||
accessTokenParam: data.accessTokenParam,
|
||||
showButton: data.showButton,
|
||||
clientSecret: data.secret,
|
||||
clientId: data.clientId,
|
||||
};
|
||||
|
||||
new CustomOAuth(serviceKey, config);
|
||||
addPassportCustomOAuth(serviceKey, config, true);
|
||||
}
|
||||
if (serviceName === 'Facebook') {
|
||||
(data as FacebookOAuthConfiguration).appId = data.clientId as string;
|
||||
delete data.clientId;
|
||||
}
|
||||
if (serviceName === 'Twitter') {
|
||||
(data as TwitterOAuthConfiguration).consumerKey = data.clientId as string;
|
||||
delete data.clientId;
|
||||
}
|
||||
|
||||
if (serviceName === 'Linkedin') {
|
||||
(data as LinkedinOAuthConfiguration).clientConfig = {
|
||||
requestPermissions: ['openid', 'email', 'profile'],
|
||||
};
|
||||
}
|
||||
|
||||
if (serviceName === 'Nextcloud') {
|
||||
data.buttonLabelText = settings.get('Accounts_OAuth_Nextcloud_button_label_text');
|
||||
data.buttonLabelColor = settings.get('Accounts_OAuth_Nextcloud_button_label_color');
|
||||
data.buttonColor = settings.get('Accounts_OAuth_Nextcloud_button_color');
|
||||
}
|
||||
|
||||
await LoginServiceConfiguration.createOrUpdateService(serviceKey, data);
|
||||
void notifyOnLoginServiceConfigurationChangedByService(serviceKey);
|
||||
} else {
|
||||
const service = await LoginServiceConfiguration.removeByService(serviceName);
|
||||
if (service) {
|
||||
void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user