Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion apps/meteor/app/custom-oauth/server/customOAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CustomOAuthStrategy extends Strategy {
clientSecret: config.clientSecret,
callbackURL: `${settings.get<string>('Site_Url')}/oauth/${name}/callback`,
state: true,
pkce: true,
pkce: config.pkce ?? true,
scope: config.scope,
};

Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/linkedin/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './lib';
48 changes: 48 additions & 0 deletions apps/meteor/app/linkedin/server/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { OAuthConfiguration } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';
import passport from 'passport';

import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth';
import { settings } from '../../settings/server';

const config: Partial<OAuthConfiguration> = {
serverURL: 'https://www.linkedin.com',
authorizePath: '/oauth/v2/authorization',
tokenPath: '/oauth/v2/accessToken',
identityPath: 'https://api.linkedin.com/v2/userinfo',
scope: 'openid email profile',
tokenSentVia: 'header',
addAutopublishFields: {
forLoggedInUser: ['services.linkedin'],
forOtherUsers: ['services.linkedin.name'],
},
pkce: false,
emailField: 'email',
};

const serviceKey = 'linkedin';

const configureLinkedInOAuth = (): void => {
passport.unuse(serviceKey);

const enabled = settings.get<boolean>('Accounts_OAuth_Linkedin');
if (!enabled) {
return;
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
}

const clientId = settings.get<string>('Accounts_OAuth_Linkedin_id');
const clientSecret = settings.get<string>('Accounts_OAuth_Linkedin_secret');

if (!clientId || !clientSecret) {
return;
}

addPassportCustomOAuth(serviceKey, { ...config, clientId, clientSecret });
};

Meteor.startup(() => {
settings.watchMultiple(
['Accounts_OAuth_Linkedin', 'Accounts_OAuth_Linkedin_id', 'Accounts_OAuth_Linkedin_secret'],
configureLinkedInOAuth,
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
);
});
4 changes: 0 additions & 4 deletions apps/meteor/server/configuration/accounts_meld.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export async function configureAccounts() {
}
}

if (serviceName === 'linkedin') {
serviceData.email = serviceData.emailAddress;
}

if (serviceData.email) {
const user = await Users.findOneByEmailAddress(serviceData.email);
if (user != null && user.services?.[serviceName]?.id !== serviceData.id) {
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import '../app/importer-slack-users/server';
import '../app/integrations/server';
import '../app/irc/server';
import '../app/lib/server';
import '../app/linkedin/server';
import '../app/token-login/server';
import '../app/mailer/server/api';
import '../app/markdown/server';
Expand Down
1 change: 1 addition & 0 deletions packages/core-typings/src/ILoginServiceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type OAuthConfiguration = {
forLoggedInUser: string[];
forOtherUsers: string[];
};
pkce?: boolean;
};

export type FacebookOAuthConfiguration = Omit<Partial<OAuthConfiguration>, 'clientId'> & {
Expand Down
Loading