WIP: Criação da autenticação pelo LDAP.
All checks were successful
Deploy Dev / deploy (push) Successful in 15s

This commit is contained in:
Gabriel Amancio 2026-05-08 09:20:21 -03:00
parent 46024bcf6d
commit 6edfd62a47
4 changed files with 1116 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/node_modules
.env*

1078
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,11 +8,14 @@
},
"dependencies": {
"dotenv": "^16.4.5",
"ldapjs": "^3.0.7",
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0"
},
"devDependencies": {
"@types/node": "^25.6.0",
"cross-env": "^7.0.3",
"nodemon": "^3.1.0"
"nodemon": "^3.1.0",
"typescript": "^6.0.3"
}
}

View File

@ -0,0 +1,32 @@
import * as ldap from 'ldapjs';
// import { validateUser } from './repository';
interface LoginData {
username: string;
password: string;
}
function authenticateUserAD(loginData: LoginData): Promise<{ message: string }> {
return new Promise((resolve, reject) => {
try {
const userDN = `${loginData.username}@sothis.com.br`;
const client = ldap.createClient({
url: 'ldap://kratos.sothistelecom.com',
});
client.bind(userDN, loginData.password, (err) => {
if (err) {
reject(new Error('Autenticação falhou: ' + err.message));
} else {
resolve({ message: 'Autenticação bem-sucedida' });
}
client.unbind();
});
} catch (error) {
reject(error);
}
});
}
export { authenticateUserAD };