Closed DenisCarriere closed 10 months ago
Replacement for AuthKey logic using Bun.password
Bun.password
MNEMONIC
AUTH_KEY
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
argon2
https://bun.sh/guides/util/hash-a-password
// https://bun.sh/guides/util/hash-a-password import { config } from "../config.js"; import { InvalidRequest, NoAuthorization, Unauthorized, getBearer } from "./bearerAuth.js"; export function beforeHandle(request: Request) { if ( !config.AUTH_KEY ) return; const bearer = getBearer(request); if (!bearer) return NoAuthorization; try { const verify = Bun.password.verifySync(config.AUTH_KEY, bearer); if ( !verify ) return Unauthorized; } catch (e) { return InvalidRequest; } }
Argon2 is one of the safest cryptographic algorithm for password encryption https://www.boldare.com/blog/how-to-improve-user-password-security-with-argon2/
StreamingFast (previously EOS Canada) had used this for their command line wallet https://github.com/eoscanada/eosc
Implemented in #58
Replacement for AuthKey logic using
Bun.password
MNEMONIC
to config (BIP39 - Mnemonic Code Words) to config (used to replaceAUTH_KEY
)~AUTH_KEY
argon2
authentication (ex:Bun.password
)Reference
Argon2 is one of the safest cryptographic algorithm for password encryption https://www.boldare.com/blog/how-to-improve-user-password-security-with-argon2/
StreamingFast (previously EOS Canada) had used this for their command line wallet https://github.com/eoscanada/eosc