Minor LDAP patches, docs for JumpCloud LDAP

This commit is contained in:
Tuan Dang
2024-02-26 17:04:01 -08:00
parent 9ba4b939a4
commit 91068229bf
12 changed files with 121 additions and 15 deletions
@@ -17,8 +17,8 @@ export async function up(knex: Knex): Promise<void> {
t.string("encryptedBindPass");
t.string("bindPassIV");
t.string("bindPassTag");
t.text("searchBase").notNullable();
t.string("encryptedCACert");
t.string("searchBase").notNullable();
t.text("encryptedCACert");
t.string("caCertIV");
t.string("caCertTag");
t.timestamps(true, true, true);
@@ -43,7 +43,7 @@ export async function down(knex: Knex): Promise<void> {
await knex.schema.alterTable(TableName.Users, (t) => {
t.dropColumn("username");
t.dropColumn("orgId");
t.string("email").notNullable().alter();
// t.string("email").notNullable().alter();
});
await dropOnUpdateTrigger(knex, TableName.LdapConfig);
}
+4 -4
View File
@@ -42,7 +42,7 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
return cb(null, { isUserCompleted, providerAuthToken });
} catch (err) {
logger.error(err);
return cb(null, false);
return cb(err, false);
}
}
)
@@ -57,9 +57,9 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
})
},
preValidation: passport.authenticate("ldapauth", {
session: false,
failureFlash: true,
failureRedirect: "/login/provider/error"
session: false
// failureFlash: true,
// failureRedirect: "/login/provider/error"
// this is due to zod type difference
}) as any,
handler: (req, res) => {
@@ -34,6 +34,12 @@ export const userServiceFactory = ({ userDAL }: TUserServiceFactoryDep) => {
const user = await userDAL.findById(userId);
if (!user) throw new BadRequestError({ name: "Update auth methods" });
if (user.authMethods?.includes(AuthMethod.LDAP))
throw new BadRequestError({ message: "LDAP auth method cannot be updated", name: "Update auth methods" });
if (authMethods.includes(AuthMethod.LDAP))
throw new BadRequestError({ message: "LDAP auth method cannot be updated", name: "Update auth methods" });
const updatedUser = await userDAL.updateById(userId, { authMethods });
return updatedUser;
};