-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAuth2 authentication fails once after access_token expired. #1775
Comments
The Git OAuth2 flow has (currently) no way to properly detect/communicate token expiration. |
Hi @becm In the log files, I see lines like
which indicates to me, that some validation is done, but with an erroneous result. Furthermore, from my experience in the past, I have not really experience problems, e.g. with github as provider. This problem occurs when selecting bitbucket as provider. Greetings |
This comment has been minimized.
This comment has been minimized.
@r-hans after a closer look, the bug you observe here is likely specific to the The code might have an issue with not indicating While the Git credential protocol itself can mark credentials as expired it has no real way forward from there on. If this worked correctly:
Last time I did test OAuth with GitHub, they did not provide expiring tokens to the GCM client. |
hi @becm,
@becm : Do you see any chance, that this can be fixed in future? We are hosting a Bitbucket instance for several thousands of users and would love to offer a OAuth2 authentication flow for our instance. However, current blocking point is, that with this bug, OAuth2 is nearly not usable. |
@r-hans you can try the mentioned (trivial) code changes to the flow of ValidateCredentialsWork:
I could implement and request the respective changes but would have no way of
But it's restricted to private code with only this single use case. |
hey @becm , Greetings |
There is an option to always refresh BitBucket credentials. But this will create multiple new tokens within the mentioned 2 hour window which may result in degraded server performance on heavy use. |
Oh good point! I tried above setting and it worked for me. (Instead of multiple re-tries to enforce a token update, I could authenticate without any error from gcm/bitbucket after token expiration). As already mentioned from you, I also see following risks:
|
fixes git-ecosystem#1775 credentials MUST be valid for OAuth and/or BasicAuth modes credentials SHOULD be considered invalid on auth mode mismatch setting override exists to skip credential expiry checks
@r-hans you might be able to also try the builds artifacts for the bugfix commit. |
Hi @becm Best regards |
@r-hans what I meant is the change might not be accepted even if you manage to verify it works. Notes on the PR about observable effects in the wild may at least be able to trigger some discussion. ☺ |
hey @becm, Greetings |
Please remove me
…On Tue, Feb 4, 2025, 1:59 AM r-hans ***@***.***> wrote:
hey @becm <https://github.com/becm>,
no matter whether the PR gets accepted or not, I appreciate your support
and contribution in that topic. This is great! From my side, I could verify
your patch. If I can do anything else to contribute here, please let me
know.
Greetings
—
Reply to this email directly, view it on GitHub
<#1775 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEV7X62BBOKM6MLTKENLT4D2OBQMXAVCNFSM6AAAAABSJGYJM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZTGAZTSOJYGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Version
2.5.0+d34930736e131ad80e5690e5634ced1808aff3e2, latest
Operating system
Windows
OS version or distribution
Windows 11
Git hosting provider(s)
Bitbucket Server/DC
Other hosting provider
No response
(Azure DevOps only) What format is your remote URL?
None
Can you access the remote repository directly in the browser?
Yes, I can access the repository
Expected behavior
After giving consent to the OAuth2 Token, gcm manages the token refresh without further user interaction in the background. This means, once the token expired, gcm refreshes the token automatically. Git can successfully authentication without error.
Actual behavior
After giving consent to the OAuth2 Token, git throws an authentication error once the access_token expired. This triggers the deletion of the access_token. During the follow-up execution of git, the missing access_token triggers the refresh of the OAuth Token with gcm and updates access/refresh_token as expected. However, as a user, I always have one initial git auth error after token expiration.
What can be seen from the error-log is, that gcm validates the auth_token, does not recognize that it is expired, and proceeds without refresh. This results in a 401 auth error and the deletion of the access_token.
failed_log.txt
Logs
No response
The text was updated successfully, but these errors were encountered: