fix(auth): support in-memory private key content in goph.Key (Issue #48)#77
Draft
ljluestc wants to merge 2 commits into
Draft
fix(auth): support in-memory private key content in goph.Key (Issue #48)#77ljluestc wants to merge 2 commits into
goph.Key (Issue #48)#77ljluestc wants to merge 2 commits into
Conversation
Detect PEM private key content in GetSigner and parse it directly while preserving file-path behavior; add tests and README example.
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.
fix(auth): support in-memory private key content in
goph.Key(Issue #48)Related Issue
Closes #48
Summary
This change fixes SSH key authentication when the private key is provided as in-memory PEM content instead of a filesystem path.
After this update,
goph.Key(...)supports both:Problem
Users reported that they keep private keys in memory and do not write them to disk, but
goph.Key(...)failed because it always treated its input as a file path.Example failing pattern before:
When
serverData.SshPrivateKeycontained PEM text, the implementation attemptedReadFile(...)and failed.Root Cause
Key(...)callsGetSigner(...).GetSigner(...)previously always read from disk and did not detect raw PEM content.What Changed
1) Auth behavior fix
GetSigner(prvFile, passphrase)inauth.go:-----BEGIN ...).GetSignerForRawKey(...).2) Tests
auth_test.gowith coverage for:GetSignerusing in-memory raw private key content,Keyusing in-memory raw private key content,GetSignerusing a private key file path (compatibility regression check).3) Documentation
README.mdwith an explicit example for in-memory private key usage:auth, err := goph.Key(privateKeyPEM, "")Backward Compatibility
Validation
go test ./...Result: pass.
Files Changed
auth.goauth_test.goREADME.mdChange Type