Skip to content

Support headless login #2317

@micrump

Description

@micrump

Version

2.7.3+5fa7116896c82164996a609accd1c5ad90fe730a

Operating system

Linux

OS version or distribution

Ubuntu 24.04

Git hosting provider(s)

GitLab

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

BROWSER=echo git clone git.abc.de/.....

It would be very helpful for working on remote machines to allow running Browser flow without a desktop environment. If "BROWSER=echo" would just dump the URL to the console, that would already allow me to complete the flow. The redirect through the forwarded port 7171 is a little awkward but at least it works.

Actual behavior

I'm working via Visual Studio Code in the browser on a remote Linux Ubuntu machine. My SSH configuration forwards port 7171 from my local machine to the remote machine. PATs are disabled for security reasons, we only use short lived OIDC tokens to interact with the Gitlab server.

In the Terminal Window I can do "glab auth login" and when the glab tool does not detect a BROWSER or a DISPLAY variable set, it just dumps the URL to the command line:

glab auth login
- Signing into git.abc.de
Error: no DISPLAY environment variable specified
Failed opening a browser at https://git.abc.de/oauth/authorize?client_id=MYID&code_challenge=MYCHALLENGE&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A7171%2Fauth%2Fredirect&response_type=code&scope=openid+profile+read_user+write_repository+api&state=MYSTATE
Encountered error: exit status 1
Try entering the URL in your browser manually.
- glab config set -h git.abc.de git_protocol https
✓ Configured Git protocol.
- glab config set -h git.abc.de api_protocol https
✓ Configured API protocol.
✓ Logged in as username
✓ Configuration saved to /home/username/.config/glab-cli/config.yml
  - Host: git.abc.de

When I click the URL my local browser on Mac OSX opens, I grant access and the redirect goes through my port forwarding to the glab tool on port 7171.

With the git-credential-manager this unfortunately does not work. It complains "fatal: Browser authentication requires a desktop session". When I try to fake some DISPLAY or BROWSER, it crashes, trying to bring up some UI dialog:

$ DISPLAY=:0 BROWSER=echo git clone git.abc.de/.....
Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/usr/local/bin/libSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/local/bin/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/local/bin/libSkiaSharp: cannot open shared object file: No such file or directory
/usr/local/bin/liblibSkiaSharp: cannot open shared object file: No such file or directory

   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at Avalonia.Skia.PlatformRenderInterface..ctor(Nullable`1 maxResourceBytes)
   at Avalonia.Skia.SkiaPlatform.Initialize(SkiaOptions options)
   at Avalonia.SkiaApplicationExtensions.<>c.<UseSkia>b__0_0()
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithoutStarting()
   at GitCredentialManager.UI.AvaloniaUi.<>c__DisplayClass8_1.<ShowWindowAsync>b__1(CancellationToken appCancelToken)
   at GitCredentialManager.UI.Dispatcher.DispatcherJob.Execute(CancellationToken ct)
   at GitCredentialManager.UI.Dispatcher.DispatcherJobQueue.Run()
   at GitCredentialManager.UI.Dispatcher.Run()
   at GitCredentialManager.Program.Main(String[] args)
Aborted (core dumped)

Logs

GCM_TRACE=1 DISPLAY=:0 BROWSER=echo GCM_GUI_PROMPT=never git clone https://git.abc.de/COMPANY/repo.git
Cloning into 'repo'...
13:39:50.969675 ...e/Application.cs:106 trace: [RunInternalAsync] Version: 2.7.3.0
13:39:50.979527 ...e/Application.cs:107 trace: [RunInternalAsync] Runtime: .NET 8.0.24
13:39:50.979575 ...e/Application.cs:108 trace: [RunInternalAsync] Platform: Linux (x86-64)
13:39:50.979580 ...e/Application.cs:109 trace: [RunInternalAsync] OSVersion: Ubuntu 24.04.4 LTS
13:39:50.979593 ...e/Application.cs:110 trace: [RunInternalAsync] AppPath: /usr/local/bin/git-credential-manager
13:39:50.979650 ...e/Application.cs:111 trace: [RunInternalAsync] InstallDir: /usr/local/bin/
13:39:50.979675 ...e/Application.cs:112 trace: [RunInternalAsync] Arguments: get
13:39:51.001245 ...GitCommandBase.cs:32 trace: [ExecuteAsync] Start 'get' command...
13:39:51.016736 ...GitCommandBase.cs:46 trace: [ExecuteAsync] Detecting host provider for input:
13:39:51.017953 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   protocol=https
13:39:51.018006 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   host=git.abc.de
13:39:51.018016 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   path=COMPANY/repo.git
13:39:51.018021 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   wwwauth=Basic realm="GitLab"
13:39:51.021064 ...oviderRegistry.cs:99 trace: [GetProviderAsync] Host provider override was set id='gitlab'
13:39:51.023035 ...GitCommandBase.cs:49 trace: [ExecuteAsync] Host provider 'GitLab' was selected.
13:39:51.049062 ...essionManager.cs:131 trace: [GetWebBrowserAvailable] VSCode (Remote SSH) detected - browser is available.
Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/usr/local/bin/libSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/local/bin/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/local/bin/libSkiaSharp: cannot open shared object file: No such file or directory
/usr/local/bin/liblibSkiaSharp: cannot open shared object file: No such file or directory

   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at Avalonia.Skia.PlatformRenderInterface..ctor(Nullable`1 maxResourceBytes)
   at Avalonia.Skia.SkiaPlatform.Initialize(SkiaOptions options)
   at Avalonia.SkiaApplicationExtensions.<>c.<UseSkia>b__0_0()
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithoutStarting()
   at GitCredentialManager.UI.AvaloniaUi.<>c__DisplayClass8_1.<ShowWindowAsync>b__1(CancellationToken appCancelToken)
   at GitCredentialManager.UI.Dispatcher.DispatcherJob.Execute(CancellationToken ct)
   at GitCredentialManager.UI.Dispatcher.DispatcherJobQueue.Run()
   at GitCredentialManager.UI.Dispatcher.Run()
   at GitCredentialManager.Program.Main(String[] args)
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-issueAn issue authenticating to a host

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions