Skip to content

Commit

Permalink
chore: convert CAS integration code to typescript (RocketChat#31492)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc authored Jan 22, 2024
1 parent 4c2771f commit 4ff8bb9
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 324 deletions.
43 changes: 0 additions & 43 deletions apps/meteor/app/cas/server/cas_rocketchat.js

This file was deleted.

272 changes: 0 additions & 272 deletions apps/meteor/app/cas/server/cas_server.js

This file was deleted.

2 changes: 0 additions & 2 deletions apps/meteor/app/cas/server/index.ts

This file was deleted.

35 changes: 35 additions & 0 deletions apps/meteor/server/configuration/cas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Awaited } from '@rocket.chat/core-typings';
import debounce from 'lodash.debounce';
import { RoutePolicy } from 'meteor/routepolicy';
import { WebApp } from 'meteor/webapp';

import { settings } from '../../app/settings/server/cached';
import { loginHandlerCAS } from '../lib/cas/loginHandler';
import { middlewareCAS } from '../lib/cas/middleware';
import { updateCasServices } from '../lib/cas/updateCasService';

const _updateCasServices = debounce(updateCasServices, 2000);

settings.watchByRegex(/^CAS_.+/, async () => {
await _updateCasServices();
});

RoutePolicy.declare('/_cas/', 'network');

// Listen to incoming OAuth http requests
WebApp.connectHandlers.use((req, res, next) => {
middlewareCAS(req, res, next);
});

/*
* Register a server-side login handler.
* It is called after Accounts.callLoginMethod() is called from client.
*
*/
Accounts.registerLoginHandler('cas', (options) => {
const promise = loginHandlerCAS(options);

// Pretend the promise has been awaited so the types will match -
// #TODO: Fix registerLoginHandler's type definitions (it accepts promises)
return promise as unknown as Awaited<typeof promise>;
});
1 change: 0 additions & 1 deletion apps/meteor/server/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../app/assets/server';
import '../app/authorization/server';
import '../app/autotranslate/server';
import '../app/bot-helpers/server';
import '../app/cas/server';
import '../app/channel-settings/server';
import '../app/cloud/server';
import '../app/crowd/server';
Expand Down
Loading

0 comments on commit 4ff8bb9

Please sign in to comment.