mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-10 01:20:58 +01:00
This commit fixes the UNIQUE constraint on the pre_auth_keys.prefix column to allow multiple legacy keys (with NULL or empty prefix) while still enforcing uniqueness for new bcrypt-based keys. Changes: - Modified migration to create partial unique index with WHERE clause - Updated schema.sql to match migration - Added comprehensive test (TestMultipleLegacyKeysAllowed) to verify: * Multiple legacy keys with empty prefix can coexist * New bcrypt keys have unique prefixes * Duplicate non-empty prefixes are rejected - Fixed lint issues (errcheck, intrange) - Fixed hardening: position-based parsing instead of separator-based - Added validation for empty string, length, separator, and character set The partial index uses: WHERE prefix IS NOT NULL AND prefix != '' This allows unlimited legacy keys (backward compatibility) while preventing duplicate prefixes for new keys (security). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| assets | ||
| capver | ||
| db | ||
| derp | ||
| dns | ||
| mapper | ||
| policy | ||
| routes | ||
| state | ||
| templates | ||
| types | ||
| util | ||
| app.go | ||
| auth_test.go | ||
| auth.go | ||
| debug.go | ||
| grpcv1_test.go | ||
| grpcv1.go | ||
| handlers.go | ||
| metrics.go | ||
| noise.go | ||
| oidc.go | ||
| platform_config.go | ||
| poll.go | ||
| suite_test.go | ||
| tailsql.go | ||