mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 05:19:49 +00:00
Add orgId to reuse login1/login2 logic for LDAP 2nd step login
This commit is contained in:
@@ -130,10 +130,14 @@ export const authLoginServiceFactory = ({ userDAL, tokenService, smtpService }:
|
||||
*/
|
||||
const loginGenServerPublicKey = async ({
|
||||
email,
|
||||
userOrgId,
|
||||
providerAuthToken,
|
||||
clientPublicKey
|
||||
}: TLoginGenServerPublicKeyDTO) => {
|
||||
const userEnc = await userDAL.findUserEncKeyByUsername(email);
|
||||
const userEnc = await userDAL.findUserEncKeyByUsername({
|
||||
username: email,
|
||||
orgId: userOrgId
|
||||
});
|
||||
if (!userEnc || (userEnc && !userEnc.isAccepted)) {
|
||||
throw new Error("Failed to find user");
|
||||
}
|
||||
@@ -155,12 +159,16 @@ export const authLoginServiceFactory = ({ userDAL, tokenService, smtpService }:
|
||||
*/
|
||||
const loginExchangeClientProof = async ({
|
||||
email,
|
||||
userOrgId,
|
||||
clientProof,
|
||||
providerAuthToken,
|
||||
ip,
|
||||
userAgent
|
||||
}: TLoginClientProofDTO) => {
|
||||
const userEnc = await userDAL.findUserEncKeyByUsername(email);
|
||||
const userEnc = await userDAL.findUserEncKeyByUsername({
|
||||
username: email,
|
||||
orgId: userOrgId
|
||||
});
|
||||
if (!userEnc) throw new Error("Failed to find user");
|
||||
const cfg = getConfig();
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@ import { AuthMethod } from "./auth-type";
|
||||
|
||||
export type TLoginGenServerPublicKeyDTO = {
|
||||
email: string;
|
||||
userOrgId?: string;
|
||||
clientPublicKey: string;
|
||||
providerAuthToken?: string;
|
||||
};
|
||||
|
||||
export type TLoginClientProofDTO = {
|
||||
email: string;
|
||||
userOrgId?: string;
|
||||
clientProof: string;
|
||||
providerAuthToken?: string;
|
||||
ip: string;
|
||||
|
||||
@@ -20,10 +20,14 @@ export const userDALFactory = (db: TDbClient) => {
|
||||
|
||||
// USER ENCRYPTION FUNCTIONS
|
||||
// -------------------------
|
||||
const findUserEncKeyByUsername = async (username: string) => {
|
||||
const findUserEncKeyByUsername = async ({ username, orgId }: { username: string; orgId?: string }) => {
|
||||
try {
|
||||
return await db(TableName.Users)
|
||||
.where({ username, isGhost: false })
|
||||
.where({
|
||||
username,
|
||||
...(orgId ? { orgId } : { orgId: null }),
|
||||
isGhost: false
|
||||
})
|
||||
.join(TableName.UserEncryptionKey, `${TableName.Users}.id`, `${TableName.UserEncryptionKey}.userId`)
|
||||
.first();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user