Skip to content

Commit

Permalink
docs: update password hashing parameters (#1560)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gomah authored May 1, 2024
1 parent 30b2264 commit ba7438a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 42 deletions.
12 changes: 6 additions & 6 deletions docs/pages/guides/email-and-password/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ app.post("/signup", async (request: Request) => {

const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
const userId = generateIdFromEntropySize(10); // 16 characters long
Expand Down Expand Up @@ -172,9 +172,9 @@ app.post("/login", async (request: Request) => {
}

const validPassword = await verify(user.password_hash, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/guides/email-and-password/password-reset.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ app.post("/reset-password/:token", async () => {
await lucia.invalidateUserSessions(token.user_id);
const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
await db.table("user").where("id", "=", token.user_id).update({
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/tutorials/username-and-password/astro.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export async function POST(context: APIContext): Promise<Response> {
const userId = generateIdFromEntropySize(10); // 16 characters long
const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});

Expand Down Expand Up @@ -205,9 +205,9 @@ export async function POST(context: APIContext): Promise<Response> {
}

const validPassword = await verify(existingUser.password, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/tutorials/username-and-password/nextjs-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ async function signup(_: any, formData: FormData): Promise<ActionResult> {

const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
const userId = generateIdFromEntropySize(10); // 16 characters long
Expand Down Expand Up @@ -243,9 +243,9 @@ async function login(_: any, formData: FormData): Promise<ActionResult> {
}

const validPassword = await verify(existingUser.password, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/tutorials/username-and-password/nextjs-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)

const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
const userId = generateIdFromEntropySize(10); // 16 characters long
Expand Down Expand Up @@ -266,9 +266,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}

const validPassword = await verify(existingUser.password, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/tutorials/username-and-password/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export default eventHandler(async (event) => {

const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
const userId = generateIdFromEntropySize(10); // 16 characters long
Expand Down Expand Up @@ -222,9 +222,9 @@ export default eventHandler(async (event) => {
}

const validPassword = await verify(existingUser.password, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/tutorials/username-and-password/sveltekit.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export const actions: Actions = {
const userId = generateIdFromEntropySize(10); // 16 characters long
const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});

Expand Down Expand Up @@ -217,9 +217,9 @@ export const actions: Actions = {
}

const validPassword = await verify(existingUser.password_hash, password, {
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
if (!validPassword) {
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/upgrade-v3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ For a simple password-based auth, the password can just be stored in the user ta
```ts
const passwordHash = await hash(password, {
// recommended minimum parameters
memorySize: 19456,
iterations: 2,
tagLength: 32,
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1
});
const userId = generateIdFromEntropySize(10); // 16 characters long
Expand Down

0 comments on commit ba7438a

Please sign in to comment.