Skip to content

Commit cb6633f

Browse files
committed
feat: register ldap strategy in passport and auth routes
Add ldap module to passport strategy registry and include it in the list of username/password login strategies. Signed-off-by: Kwangjin Ko <kyet@me.com>
1 parent ade173d commit cb6633f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/service/passport/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import passport, { type PassportStatic } from 'passport';
1818
import * as local from './local';
1919
import * as activeDirectory from './activeDirectory';
20+
import * as ldap from './ldap';
2021
import * as oidc from './oidc';
2122
import * as config from '../../config';
2223
import { AuthenticationElement } from '../../config/generated/config';
@@ -30,6 +31,7 @@ type StrategyModule = {
3031
export const authStrategies: Record<string, StrategyModule> = {
3132
local,
3233
activedirectory: activeDirectory,
34+
ldap,
3335
openidconnect: oidc,
3436
};
3537

src/service/routes/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { getAuthMethods } from '../../config';
2121
import * as db from '../../db';
2222
import * as passportLocal from '../passport/local';
2323
import * as passportAD from '../passport/activeDirectory';
24+
import * as passportLdap from '../passport/ldap';
2425

2526
import { User } from '../../db/types';
2627
import { AuthenticationElement } from '../../config/generated/config';
@@ -52,7 +53,7 @@ router.get('/', (_req: Request, res: Response) => {
5253
});
5354

5455
// login strategies that will work with /login e.g. take username and password
55-
const appropriateLoginStrategies = [passportLocal.type, passportAD.type];
56+
const appropriateLoginStrategies = [passportLocal.type, passportAD.type, passportLdap.type];
5657
// getLoginStrategy fetches the enabled auth methods and identifies if there's an appropriate
5758
// auth method for username and password login. If there isn't it returns null, if there is it
5859
// returns the first.

0 commit comments

Comments
 (0)