forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert CAS integration code to typescript (RocketChat#31492)
- Loading branch information
1 parent
4c2771f
commit 4ff8bb9
Showing
16 changed files
with
386 additions
and
324 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.