Repository navigation
core(gitdns-fix): ensure that gitdns support token support works with all Git server providers - #8778
Conversation
eda001a to
7883173
Compare
sipsma
left a comment
There was a problem hiding this comment.
Should add a changelog for this, otherwise LGTM
| if s.token { | ||
| dt = []byte("basic " + base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("x-access-token:%s", dt)))) | ||
|
|
||
| if strings.Contains(gs.src.Remote, "bitbucket.org") { |
There was a problem hiding this comment.
suggestion: maybe we should just check the host here? e.g. we don't want to do this for something weird like [email protected]:jedevc/bitbucket.org
| gs.auth = []string{ | ||
| "-c", fmt.Sprintf("credential.helper=!f() { echo \"username=x-token-auth\"; echo \"password=%s\"; }; f", string(dt)), | ||
| "-c", "credential.https://bitbucket.org.username=x-token-auth", | ||
| "-c", "credential.useHttpPath=true", | ||
| } |
There was a problem hiding this comment.
suggestion: I would apply the logic for detecting this in authSecretNames, and then extend authSecret to have a credhelper bool property. This keeps the logic decoupled, but also means that we don't end up trying to put AuthHeaderSecretss as passwords (we should only put the tokens there).
If this is called using an AuthHeader, we shouldn't be plugging the entire auth header in as a password - we should plug it in as a header as requested. It's only for the AuthToken that we want to apply the logic in this PR.
7883173 to
b4402bf
Compare
server providers Bitbucket Cloud requires a specific auth format for Git operations using tokens, where the username must be 'x-token-auth'. This fixes token authentication for Bitbucket while maintaining compatibility with other Git providers like GitHub and GitLab, and Azure. Signed-off-by: Guillaume de Rouville <[email protected]>
As we realized that gitdns auth token implementation was breaking against bitbucket, this commit adds a full integration test suite against real providers: - github - gitlab - bitbucket Azure does not enable us to have a pat without a deadline, but this was manually tested Signed-off-by: Guillaume de Rouville <[email protected]>
Move the logic for determining authentication methods (Bitbucket credential helper) from getAuthToken to authSecretNames Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
0dc7cce to
a924e0e
Compare
Bitbucket Cloud requires a specific auth format for Git operations using tokens, where the username must be 'x-token-auth'. This fixes token authentication for Bitbucket while maintaining compatibility with other Git providers like GitHub and GitLab, and Azure.
Context for Bitbucket Token Handling
Our implementation for Bitbucket Cloud authentication is based on the Repository Access Tokens Documentation, which specifically covers Git operations. While Bitbucket's HTTP Access Tokens Documentation suggests using Bearer authentication for some cases, this appears to only be working for to REST API calls (upon personal tests).
For Git operations, the documentation recommends using
x-token-authas the username, with the token as password, regardless of the token type. After testing both user tokens and repository tokens, I found that Bearer authentication did not work reliably for Git operations, leading my choice to always rely on that for bitbucket auth