Multiple repositories with same bridge/token

Labels: kind/bug

Timeline

Simon Schuster (noctux) opened

It does not seem to be possible to have two bridges using a common token with the same target:

The following was performed within a clean environment:

  1. Initial clone of one repository (I've edited out my token), everything works as expected:
[eve@computer test]$ git clone https://github.com/MichaelMure/git-bug
Cloning into 'git-bug'...
remote: Enumerating objects: 85, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (64/64), done.
remote: Total 11128 (delta 35), reused 41 (delta 20), pack-reused 11043
Receiving objects: 100% (11128/11128), 15.75 MiB | 13.19 MiB/s, done.
Resolving deltas: 100% (6415/6415), done.
[eve@computer test]$ cd git-bug
[eve@computer git-bug]$ git bug user create
Building identity cache... Done.
Building bug cache... Done.
Error: Error running git command: config user.name
[eve@computer git-bug]$ git config user.name "eve"
[eve@computer git-bug]$ git config user.email "eve@example.org"
[eve@computer git-bug]$ git bug user create
Name [eve]: 
Email [eve@example.org]: 
Avatar URL: 

a66bcfdac7e2687ddb9310fc27bd011a5b8e334d
[eve@computer git-bug]$ git bug bridge configure --name=github --target=github --token=$MYTOKEN --url=https://github.com/MichaelMure/git-bug
Successfully configured bridge: github
[eve@computer git-bug]$ git bug bridge pull github
new identity: 85871c63bc6b96359ec6ab4db876bba950ddd2a8
...
changed status: 1ee55b4f149e87fbc80d1ddefb43666e33f12381748044dd8c195d305d12b9b5
imported 120 issues and 81 identities with github bridge
  1. Clone of another repository
[eve@computer test]$ git clone https://github.com/MichaelMure/go-term-text
Cloning into 'go-term-text'...
remote: Enumerating objects: 263, done.
remote: Counting objects: 100% (263/263), done.
remote: Compressing objects: 100% (158/158), done.
remote: Total 263 (delta 141), reused 216 (delta 100), pack-reused 0
Receiving objects: 100% (263/263), 132.13 KiB | 782.00 KiB/s, done.
Resolving deltas: 100% (141/141), done.
[eve@computer test]$ cd go-term-text/
[eve@computer go-term-text]$ git config user.name "eve"
[eve@computer go-term-text]$ git config user.email "eve@example.org"
[eve@computer go-term-text]$ git bug bridge configure --name=github2 --target=github --token=$TOKEN --url=https://github.com/MichaelMure/go-term-text
Building identity cache... Done.
Building bug cache... Done.
Successfully configured bridge: github2
[eve@computer go-term-text]$ git bug bridge pull github2
Error: missing identity token
[eve@computer go-term-text]$ git bug user create
Name [eve]: 
Email [eve@example.org]: 
Avatar URL: 

605b22282a8abb56095422679affa4bf7872a98e
[eve@computer go-term-text]$ git bug bridge pull github2
Error: missing identity token

The same issue also happens when running git bug bridge auth afterwards: Repo from 1):

[eve@computer git-bug]$ git bug bridge auth 
51e8d3f github     token eve $TOKEN

Repo from 2):

[eve@computer go-term-text]$ git bug bridge auth
Error: identity doesn't exist

My guess is that this is related to the credentials stored in the global .gitconfig file. After both bridges have been configured, there is only a single auth block (ids shortended as I don't know whether they leak information):

[git-bug "auth.51e8d..."]
	kind = token
	userid = a66bcfdac7e2687ddb9310fc27bd011a5b8e334d
	target = github
	createtime = 1578397411
	value = $TOKEN

As you can see, it maps to the userid of the user created in 1). If I edit userid to the userid from step 2 (so 605b22282a8abb56095422679affa4bf7872a98e) I can query auth (git bug bridge auth) pull (git bug bridge pull githubX) in the repo from 2), but not anymore in the one from 1).

Generally, it would be nice to have a general bridge configuration that is usable from all my repositories and not bound to an individual (repository-local) identity. So I'd rather have a bridge "github" with token from my account that I can use with all my repositories on github. If multiaccount-usage is required, the user could then create an "github-account2" bridge...

Thank you for this software and reading thus far in this bug report :) I hope this information is more-or-less complete and sufficient, but feel free to ping me if you need more information/a tester.

Best regards, Simon

Useful information:

  • git-bug version 0.6.0.r3.gca1d305-1, revision ca1d305308d4ee6d0fec16a0af10b62bb52cd265 build from git
  • go version go1.13.5 linux/amd64
  • git version 2.24.1

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) commented

You are correct in your assessment. The concept of global token came quite late in the bridge design and while you can configure multiple bridges within the same repository, I failed to realize that the userID are not common across repository. I'm working on a fix to address this problem in the cred-metadata branch

Instead of storing the user ID, bridges will be able to tag credentials with arbitrary metadata that they can search for later from another repo. Typically, bridges would store the user login or email.

Michael Muré (MichaelMure) commented

This should be working now on the master branch, care to test ?

Simon Schuster (noctux) commented (edited)

Hey, thanks for the effort!

I've tested it with multiple github-repositories and it seems to work as expected. Only read access was tested (sorry, currently have no bugs to report), but I could successfully register with the same credentials and only have one set of credentials stored in ~/.config/git/config.

I've always registered with full set of information (git bug bridge configure --name=github --target=github --token=... --url=https://github.com/.../...). If the new method has some concept of adopting an already configured set of credentials and you want that tested as well, feel free to ping me.

Once more thank you for the patch :)

Michael Muré (MichaelMure) commented

Thanks for testing !

Michael Muré (MichaelMure) closed the bug