feat(auth): implementa logica de recuperacao e mudanca de senha
This commit is contained in:
@@ -5,10 +5,12 @@ export interface AuthRuntimeConfig {
|
||||
audience: string
|
||||
accessTtlSec: number
|
||||
refreshTtlSec: number
|
||||
passwordResetTtlSec: number
|
||||
privateKeyPem: string
|
||||
publicKeyPem: string
|
||||
kid: string
|
||||
refreshTokenPepper: string
|
||||
passwordResetTokenPepper: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +60,7 @@ function normalizePem(rawValue: string, label: string): string {
|
||||
* Lê e valida todas as configurações obrigatórias de autenticação.
|
||||
*
|
||||
* @param event Evento da requisição (opcional), usado para acessar runtime config.
|
||||
* @returns Objeto com configurações de JWT e refresh token já validadas.
|
||||
* @returns Objeto com configurações de JWT, refresh token e recuperação de senha já validadas.
|
||||
* @throws {H3Error} Quando algum campo obrigatório estiver ausente ou inválido.
|
||||
*/
|
||||
export function getAuthRuntimeConfig(event?: H3Event): AuthRuntimeConfig {
|
||||
@@ -80,14 +82,20 @@ export function getAuthRuntimeConfig(event?: H3Event): AuthRuntimeConfig {
|
||||
throw createError({ statusCode: 500, statusMessage: 'JWT kid is required' })
|
||||
}
|
||||
|
||||
const refreshTokenPepper = String(runtimeConfig.refreshTokenPepper ?? '').trim()
|
||||
const passwordResetTokenPepper =
|
||||
String(runtimeConfig.passwordResetTokenPepper ?? '').trim() || refreshTokenPepper
|
||||
|
||||
return {
|
||||
issuer,
|
||||
audience,
|
||||
kid,
|
||||
accessTtlSec: parsePositiveInt(String(runtimeConfig.jwtAccessTtlSec), 'JWT access TTL'),
|
||||
refreshTtlSec: parsePositiveInt(String(runtimeConfig.jwtRefreshTtlSec), 'JWT refresh TTL'),
|
||||
passwordResetTtlSec: parsePositiveInt(String(runtimeConfig.passwordResetTtlSec), 'Password reset TTL'),
|
||||
privateKeyPem: normalizePem(String(runtimeConfig.jwtPrivateKeyPem ?? ''), 'JWT private key'),
|
||||
publicKeyPem: normalizePem(String(runtimeConfig.jwtPublicKeyPem ?? ''), 'JWT public key'),
|
||||
refreshTokenPepper: String(runtimeConfig.refreshTokenPepper ?? '')
|
||||
refreshTokenPepper,
|
||||
passwordResetTokenPepper
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user