Skip to content
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

Add support for multiple forges #138

Open
5 of 7 tasks
JensHeinrich opened this issue Aug 31, 2020 · 4 comments
Open
5 of 7 tasks

Add support for multiple forges #138

JensHeinrich opened this issue Aug 31, 2020 · 4 comments
Labels
epic feature add new functionality
Milestone

Comments

@JensHeinrich
Copy link
Contributor

JensHeinrich commented Aug 31, 2020

Add support for running with GitHub and gitea for example

Idea:

  • check if multiple providers are defined
  • if so, use the solution for OAuth support for Gitea #136 to supply a login with $PROVIDER button and namespace the repositories $PROVIDER/ORG/REPO
  • could even be extended with a $PROVIDER_PROVIDERS List, eg GITEA_PROVIDERS="DEVGITEA,PRODGITEA" and using these as new variable names DEVGITEA_OAUTHID=...

TODO

@6543 6543 added the feature add new functionality label Sep 21, 2021
@anbraten anbraten added the epic label Oct 17, 2021
@jdoubleu
Copy link
Contributor

There are a few questions which came into mind, that also need to be addressed. To be fair, they slightly address an edge case where one user would like to connect multiple vcs servers (I think that's what they are called in the documentation).

  • Going forward, how are the repositories displayed when the user is logged in? At the moment, the repository list only names org/repo. What if an repository exists with the same hierarchy on a different vcs server? Sure, internally it uses the $provider/org/repo structure, but how is that communicated with the user?
  • How does repository synchronization work? Woodpecker would have to go through all remotes, the user is currently authenticated with, and fetch the repository list. How is the user shown which remotes were synced? Maybe the user forgot to login with some vcs server or their authorization token expired.

could even be extended with a $PROVIDER_PROVIDERS List, eg GITEA_PROVIDERS="DEVGITEA,PRODGITEA" and using these as new variable names DEVGITEA_OAUTHID=...

I fear that it introduces complexity on the configuration (env variables). It also introduces config "keys" (e.g. with DEVGITEA_ prefix), which are only valid in a special context, i.e. when GITEA_PROVIDERS="DEVGITEA" was given prior.

The alternative would be to store these information in the database and have the admin configure it through the web interface, right? One benefit of that approach I can think of would be to also have the flexibility to customize the given integration. The admin could add a name/title and maybe links to their privacy policy. The admin could also customize the "Login with Gitea" button to show e.g. "Login with Development Gitea @ Woodpecker Next".

However, I'm not sure what implications this might have, besides being harder to implement.

@anbraten anbraten changed the title Feature Request: Add support for multiple repository servers Add support for multiple forges Apr 4, 2022
@anbraten anbraten mentioned this issue Nov 15, 2022
7 tasks
@anbraten
Copy link
Member

anbraten commented Nov 15, 2022

I have started to get this feature in by changing the code in small steps #1418 #1417. First of all I will try to load the forges config from the database. The env vars will simply add a signle entry to the database if none with that url exists. To be able to load the forge from the database I will also add a forge-id to each repo.

Next step would be to load repositories via their woodpecker internal id and not by their slug.

After that we need to check how to use multiple forges at once. For the beginning we could say a user authenticates with a specific forge and that user is by that only seeing repos of a specific forge as well.

Later we could check if a user could do some kind of re-authentication with another forge to be able to see repos from multiple forges at once.

@anbraten anbraten mentioned this issue Nov 26, 2022
31 tasks
@qwerty287 qwerty287 added this to the 3.x.x milestone Nov 4, 2023
anbraten added a commit that referenced this issue Apr 16, 2024
This is the first step towards support for multiple forges (#138). It
inserts a forge using the currently existing env varaibles into db and
uses this forge from db later on in all places of the code.

closes #621

addresses #138 

# TODO
- [x] add forges table
- [x] add id of forge to repo
- [x] use forge of repo
- [x] add forge from env vars to db if not exists
- [x] migrate repo.ForgeID to the newly generated forge
- [x] support cache with forge from repo
- [x] maybe add forge loading cache? (use LRU cache for forges, I expect
users to have less than 10 forges normally)

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
@wyatt-herkamp
Copy link

Instead of having an account for each forge. What about allowing an account to be connected to multiple forges?

Have a table of user_forges

type UserForge struct {
	ID int64
	// References a user
	USER_ID int64
	FORGE_ID: inti64
	// Other OAUTH Token Parameters
} 

For my purposes in woodpecker this would be easier to manage so I only have user account and don't have to swap accounts to change the pipeline in a different forge.

@anbraten
Copy link
Member

anbraten commented May 20, 2024

That will be absolutely possible in the long term. For the beginning it however will be much easier to have 1user<=>1forge as a lot of api endpoints are not compatible with for example fetching repo details from multiple forges. I almost finished the login part (#3695 & main...anbraten:woodpecker:forge-login)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic feature add new functionality
Projects
None yet
Development

No branches or pull requests

6 participants