Skip to content

Commit

Permalink
feat: enable hash cache for password authentication (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre committed Apr 3, 2021
1 parent 5995fbb commit 517f1b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/src/caddy/config/sites/get-auth-handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { scryptOptions } from '../../../entities/sites/hash-password';
import { base64Encode } from '../../../commons/utils/base64';
import { Password } from '../../../entities/sites/password';
import Authentication = Caddy.Http.Route.Handlers.Authentication;

export function getAuthHandler(password: Password) {
export function getAuthHandler(password: Password): Authentication {
return {
// https://caddyserver.com/docs/json/apps/http/servers/routes/handle/authentication/
handler: 'authentication',
Expand All @@ -17,6 +18,7 @@ export function getAuthHandler(password: Password) {
p: scryptOptions.p,
key_length: scryptOptions.keyLength,
},
hash_cache: {},
accounts: [{
username: 'user',
password: Buffer.from(password.hash, 'hex').toString('base64'),
Expand Down

0 comments on commit 517f1b1

Please sign in to comment.