fix openldap init script paas user token saving,
add config file with BASE_DN, add async wrapper class for ldap client, implement addUser getUser delUser, add and implement addGroup delGroup methods
This commit is contained in:
49
src/main.js
49
src/main.js
@@ -2,29 +2,56 @@ import express from "express";
|
||||
import bodyParser from "body-parser";
|
||||
import cookieParser from "cookie-parser";
|
||||
import morgan from "morgan";
|
||||
import LDAP from "ldap.js";
|
||||
|
||||
import LDAP from "./ldap.js";
|
||||
import _config from "./config.js";
|
||||
import _package from "./package.js";
|
||||
|
||||
import parseArgs from "minimist";
|
||||
|
||||
global.argv = parseArgs(process.argv.slice(2), {
|
||||
default: {
|
||||
package: "package.json",
|
||||
listenPort: 8082,
|
||||
ldapURL: "ldap://localhost",
|
||||
configPath: "config/config.json"
|
||||
}
|
||||
});
|
||||
|
||||
global.package = _package(global.argv.package);
|
||||
global.config = _config(global.argv.configPath);
|
||||
|
||||
const ldap = new LDAP(global.argv.ldapURL, global.config.basedn);
|
||||
|
||||
/* import { readFileSync } from "fs";
|
||||
const paas = {
|
||||
dn: `uid=paas,ou=people,${global.config.basedn}`,
|
||||
password: readFileSync("paas.token").toString()
|
||||
};
|
||||
console.log(await ldap.addUser(paas, "testuser", { cn: "test", sn: "test", userPassword: "test" }));
|
||||
console.log((await ldap.getUser(paas, "testuser")).entries[0].attributes);
|
||||
console.log(await ldap.delUser(paas, "testuser"));
|
||||
console.log(await ldap.addGroup(paas, "testgroup"));
|
||||
console.log(await ldap.delGroup(paas, "testgroup"));
|
||||
exit(0); */
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(cookieParser());
|
||||
app.use(morgan("combined"));
|
||||
|
||||
app.listen(global.db.listenPort, () => {
|
||||
console.log(`proxmoxaas-api v${global.api.version} listening on port ${global.db.listenPort}`);
|
||||
app.listen(global.argv.listenPort, () => {
|
||||
console.log(`proxmoxaas-ldap v${global.package.version} listening on port ${global.argv.listenPort}`);
|
||||
});
|
||||
|
||||
app.get("/:user", (req, res) => {
|
||||
|
||||
app.get("/:user", async (req, res) => {
|
||||
});
|
||||
|
||||
app.post("/:user", (req, res) => {
|
||||
|
||||
app.post("/:user", async (req, res) => {
|
||||
});
|
||||
|
||||
app.delete("/:user", (req, res) => {
|
||||
|
||||
app.delete("/:user", async (req, res) => {
|
||||
});
|
||||
|
||||
app.post("/:user/password", (req, res) => {
|
||||
|
||||
app.post("/:user/password", async (req, res) => {
|
||||
});
|
||||
|
Reference in New Issue
Block a user