750b7abcd5
- .claude/CLAUDE.md - .claude/agents/fn-recopilador/SKILL.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - bash/functions/infra/build_cpp_windows.sh - cpp/CMakeLists.txt - cpp/PATTERNS.md - cpp/framework/app_base.cpp - cpp/framework/app_base.h - dev/issues/README.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.9 KiB
1.9 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| bcrypt_htpasswd | function | go | infra | 1.0.0 | impure | func BcryptHtpasswd(user, password string, cost int) (string, error) | Genera una linea formato htpasswd para basicAuth de Traefik usando bcrypt. Si cost es 0 usa el default 10. Output: user:hash (sin escapado $$ — eso es solo para Docker labels en compose). Error si user o password vacios o cost fuera de [4,31]. |
|
false | error_go_core |
|
|
linea htpasswd con formato 'user:$2a$NN$...' lista para pegar en el file provider de Traefik o nginx | true |
|
functions/infra/bcrypt_htpasswd_test.go | functions/infra/bcrypt_htpasswd.go |
Ejemplo
line, err := BcryptHtpasswd("lucas", "s3cr3t", 10)
// line = "lucas:$2a$10$..."
// Pegar directamente en traefik-dynamic.yml bajo basicAuth.users
Notas
La funcion usa golang.org/x/crypto/bcrypt (ya en go.mod). El salt aleatorio hace que cada llamada genere un hash distinto — la funcion es impura. El output es para el file provider de Traefik (single $). Para Docker labels en compose se necesita escapar a $$, lo que NO hace esta funcion. Verificacion: bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)).