git-ecosystem / git-credential-manager

Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services.
Other
6.74k stars 1.75k forks source link

OAuth for Gitea does not work within vs code remote #1514

Open ghost opened 8 months ago

ghost commented 8 months ago

Version

latest

Operating system

Linux

OS version or distribution

Ubuntu 22.04 fresh install

Git hosting provider(s)

Other - please describe below

Other hosting provider

Gitea

(Azure DevOps only) What format is your remote URL?

None

Can you access the remote repository directly in the browser?

No, I get a permission error

Expected behavior

after installing gcm, vs code (with SSH remote plugin) shoud prompt for oauth login.

Actual behavior

OAuth for Gitea does not work within vs code SSH remote plugin https://github.com/microsoft/vscode/issues/202123#issuecomment-1896563886

Logs

No response

dscho commented 8 months ago

No, I get a permission error

Maybe you want to make that a less mysterious report by sharing the actual error message?

ghost commented 8 months ago

sorry that is from the issue template.

when cloning a gitea repo, VS code prompt for user name and password like in a HTTP basic auth, instead of using git-credential-manager.

when cloing a github repo, VS code started a pop up window for the oauth as desired.

@dscho could you give me some hint about how to get a debug level log for git-credential-manager when running git clone http://....?

dscho commented 8 months ago

how to get a debug level log for git-credential-manager

The common way is to set the environment variable GCM_TRACE either to 1 (in which case the debug log goes to the standard error output) or to a full path (in which case the log is written to the specified file).

ghost commented 8 months ago

sudo dpkg -i <path-to-package> git-credential-manager configure and then in a new bash export GCM_TRACE=1 gives me

22:24:11.284666 ...e/Application.cs:106 trace: [RunInternalAsync] Version: 2.4.1.0
22:24:11.285784 ...e/Application.cs:107 trace: [RunInternalAsync] Runtime: .NET 7.0.13
22:24:11.285816 ...e/Application.cs:108 trace: [RunInternalAsync] Platform: Linux (x86-64)
22:24:11.285823 ...e/Application.cs:109 trace: [RunInternalAsync] OSVersion: Ubuntu 22.04.3 LTS
22:24:11.285839 ...e/Application.cs:110 trace: [RunInternalAsync] AppPath: /usr/local/bin/git-credential-manager
22:24:11.285900 ...e/Application.cs:111 trace: [RunInternalAsync] InstallDir: /usr/local/share/gcm-core/
22:24:11.285925 ...e/Application.cs:112 trace: [RunInternalAsync] Arguments: get
22:24:11.310428 ...GitCommandBase.cs:32 trace: [ExecuteAsync] Start 'get' command...
22:24:11.319339 ...GitCommandBase.cs:46 trace: [ExecuteAsync] Detecting host provider for input:
22:24:11.320679 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   protocol=https
22:24:11.320726 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   host=gitea.example.com
22:24:11.324057 ...oviderRegistry.cs:99 trace: [GetProviderAsync] Host provider override was set id='generic'
22:24:11.325909 ...GitCommandBase.cs:49 trace: [ExecuteAsync] Host provider 'Generic' was selected.
22:24:11.327541 .../HostProvider.cs:126 trace: [GetCredentialAsync] Looking for existing credential in store with service=https://git.example.com account=...
22:24:11.332872 .../HostProvider.cs:131 trace: [GetCredentialAsync] No existing credentials found.
22:24:11.332888 .../HostProvider.cs:134 trace: [GetCredentialAsync] Creating new credential...
22:24:11.335289 ...ricOAuthConfig.cs:38 trace: [TryGet] Invalid OAuth configuration - missing/invalid authorize endpoint: 
22:24:11.335540 ...cHostProvider.cs:104 trace: [GenerateCredentialAsync] Skipping check for Windows Integrated Authentication on Linux.
22:24:11.335556 ...cHostProvider.cs:113 trace: [GenerateCredentialAsync] Prompting for basic credentials...
Enter basic credentials for 'https://gitea.example.com/':
Username: 22:24:11.340498 .../LinuxTerminal.cs:45 trace: [.ctor] Setting terminal echo state to 'True'

the exact repo link works on the same GCM version on windows, though

hickford commented 8 months ago

This is expected. You can't use OAuth on a remote machine because Gitea OAuth requires a desktop web browser:

https://github.com/git-ecosystem/git-credential-manager/blob/0d23f96d79dc73e3b7f1ed165289aa6fe6fb675f/src/shared/Core/Authentication/OAuthAuthentication.cs#L44

At least until Gitea implements OAuth Device Authorization Grant https://github.com/go-gitea/gitea/issues/27309#issue-1915279735 (as GitHub does).

SagePtr commented 3 months ago

22:24:11.335289 ...ricOAuthConfig.cs:38 trace: [TryGet] Invalid OAuth configuration - missing/invalid authorize endpoint:

This one line is not related to vscode remote, but if your git version is older than 2.41.0, it won't pass the WWW-Authenticate header to the credential helper and therefore won't autodetect Gitea. Either configure endpoints manually or update git executable.