Salt and hash passwords
This commit is contained in:
1 parent
88ad9451e2
commit
d5b194b9e8
13 files changed
+410
-83
No files matched your search
@@ -12,6 +12,7 @@ import Authorizer from "./common/authorizer";
|
||||
import * as logger from "./logger";
|
||||
import * as localCache from "./local-cache";
|
||||
import { PermissionSet } from "./types";
|
||||
import { authSimple } from "./ui/api-functions";
|
||||
|
||||
declare module "koa" {
|
||||
interface Request {
|
||||
@@ -33,14 +34,6 @@ function getPermissionSets(ctx): PermissionSet[] {
|
||||
return permissionSets;
|
||||
}
|
||||
|
||||
function authSimple(ctx, username, password): Promise<string[]> {
|
||||
const users = localCache.getUsers(ctx.state.configSnapshot);
|
||||
const user = users[username];
|
||||
if (user && user.password === password) return Promise.resolve(user.roles);
|
||||
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
koa.on("error", async err => {
|
||||
throw err;
|
||||
});
|
||||
@@ -100,7 +93,7 @@ router.post("/login", async ctx => {
|
||||
logger.accessWarn(log);
|
||||
}
|
||||
|
||||
const roles = await authSimple(ctx, username, password);
|
||||
const roles = await authSimple(ctx.state.configSnapshot, username, password);
|
||||
|
||||
if (roles) return void success(roles, "simple");
|
||||
|
||||
|
||||
Reference in new issue
Block a user