[deckhouse-cli] Add d8 tools htpasswd (self-contained Apache htpasswd analog) + d8 mirror bundle-layout docs - #446
Merged
Merged
Conversation
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
d8 tools htpasswd (self-contained Apache htpasswd analog) + d8 mirror bundle-layout docs
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new
d8 tools htpasswdcommand (registered ininternal/tools/tools.go) that reimplements Apache htpasswd in pure Go.Algorithms
-B$2y$)-m$apr1$)-2$5$)-5$6$)-d-s{SHA})-pEach crypt-family algorithm is implemented from the canonical spec (PHK md5crypt, Drepper SHA-crypt, traditional DES crypt(3) with the 12-bit salt twist) and the shared
crypt64alphabet. bcrypt usesgolang.org/x/crypto/bcrypt, rewritten to the$2y$identifier Apache emits for byte-level parity.CLI surface
Full Apache htpasswd flag surface, including shorthand bundling (
-nbB,-BinC 10 ""):-c -n -b -i -m -B -d -s -p -D -v -C. d8 adds three extensions Apache htpasswd does not have: the SHA-crypt algorithms-2/-5and the-r(rounds) flag.Operations: add/update,
-Ddelete,-vverify, and-nprint-to-stdout. Password files are written atomically (temp file + rename) so a crash mid-write can never leave a truncated file; other users, comments and blank lines are preserved verbatim on update.Intentional differences from Apache htpasswd
-B); d8 defaults to bcrypt at cost 10, so the output is strong and directly usable byd8 iam user create/d8 iam user reset-password --password-hash.-nand no username, d8 prints just the hash (Apache always requires a username and printsusername:hash), which is exactly what--password-hashconsumes. An explicit empty username (-n "") still prints:hash, matching Apache.-C4–31 (Apache caps at 17); the wider range still produces standard, interoperable bcrypt hashes.2usage/syntax,3verification failure,5over-long username,6bad/absent user,1file-access errors.Parity verification
Algorithm outputs were cross-checked byte-for-byte against reference implementations:
htpasswd2.4.58 (apache2-utils)openssl passwd -apr1/-1/-5/-6)python3 crypt, Ccrypt(3))cryptcrypt(DES)Verified byte-identical for DES,
$1$,$apr1$,$5$and$6$across a broad vector set, including edge cases (empty password, the DES 8-byte boundary, salt truncation at 8/16, SHA default-vs-explicitrounds=, rounds clamping, and the SHA-256 vs SHA-512 output permutations). Documented, benign divergences: crypt(3) treats the password as NUL-terminated while the Go port keeps bytes past an embedded0x00(unreachable via CLI argv/stdin); and out-of-range SHAroundsare clamped (per Drepper/classic glibc) rather than rejected.