feat: jwt_generate, jwt_validate, password_hash, password_verify

Fase 2 del issue 0010 — auth core:
- jwt_generate/validate: HS256 manual con crypto/hmac + crypto/sha256
- password_hash/verify: wrappers de golang.org/x/crypto/bcrypt (cost 12 default)
- JWT rechaza alg != HS256 para mitigar ataque 'alg=none'
- hmac.Equal para comparacion constant-time de firmas
This commit is contained in:
2026-04-18 17:39:00 +02:00
parent 4bc6d1bced
commit 07341aa89f
14 changed files with 517 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
package infra
import "golang.org/x/crypto/bcrypt"
// PasswordVerify compara un password en texto plano contra un hash bcrypt.
// Retorna nil si hacen match, error si no.
func PasswordVerify(password string, hash string) error {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
}