source-integration icon indicating copy to clipboard operation
source-integration copied to clipboard

How to Gitea integration?

Open zamachuga opened this issue 4 years ago • 12 comments

https://gitea.io/en-us/ How to Gitea integration?

zamachuga avatar Jul 07 '21 18:07 zamachuga

Hello I also use gitea, and it would be great for us if you implemented source integration for gitea

lds-lds avatar Nov 18 '21 08:11 lds-lds

Contributions are always welcome, feel free to submit a pull request for gitea integration.

dregad avatar Nov 18 '21 11:11 dregad

I currently work on it based on the GitHub Plugin. Its not finished yet but basically working. Code cleanup is needed. Still have some questions and a few unclear points. I hope I can create a repository for it soon. I still need to implement the webhook creation through button clich from the repo configuraton page.

fokkersim avatar Feb 14 '22 16:02 fokkersim

I currently work on it based on the GitHub Plugin

Great news, thanks ! Looking forward to it.

Still have some questions and a few unclear points

Can't help with the Gitea side of things, but if your questions are related to MantisBT or the Source Integration framework, I'll be glad to assist if I can. Just ask !

I hope I can create a repository for it soon

Rather than having it as a standalone repository, I would suggest to bundle your plugin with this one, whenever you're ready.

dregad avatar Feb 14 '22 21:02 dregad

I currently work on it based on the GitHub Plugin. Oh great :) thanks @fokkersim

lds-lds avatar Feb 15 '22 08:02 lds-lds

Can't help with the Gitea side of things, but if your questions are related to MantisBT or the Source Integration framework, I'll be glad to assist if I can. Just ask !

Oh great! On which channel should I contact you? Basically first big question is: Is it normal that the Mantis repository $t_repo->id changes when a "Import Everything" is done? If yes, how to handle this with respect to oauth refresh token usage? The redirect_uri seems to need the repository id as a parameter for the Reply with the code. When the repo id changes the token refresh via oauth fails due to a now wrong redirect_uri.

fokkersim avatar Feb 15 '22 08:02 fokkersim

On which channel should I contact you

Here is fine, or if you prefer https://gitter.im/mantisbt-plugins/source-integration (if I'm on-line you may get faster turnaround)

Is it normal that the Mantis repository $t_repo->id changes when a "Import Everything" is done?

That's just the way the plugin was originally written (long before I took over the project's maintenance). Not sure I would call that normal, though. I agree that changing repo id is confusing at best, and may cause issues.

AFAIK, the idea was to perform the full import into a new, empty repository so the original could be kept and restored in case of errors during the import operation, but I do not think there was any actual intention to change the id; that's probably just a side effect.

how to handle this with respect to oauth refresh token usage? The redirect_uri seems to need the repository id as a parameter for the Reply with the code. When the repo id changes the token refresh via oauth fails due to a now wrong redirect_uri.

I was not aware of any issues with changing repo id until now, but TBH the full import is a feature I rarely use.

dregad avatar Feb 15 '22 22:02 dregad

Making a full import like that makes totally sense to me, but keeping the id would be probably nice?

I was not aware of any issues with changing repo id until now, but TBH the full import is a feature I rarely use.

I think this/my question can be seen best in oauth_authorize.php where the id and the code is required as a parameter to process the further authentication procedure after the initial request. This involves then later on to assign also the authentication token and refresh token to a repository. At the moment I dont see, how this would work with one authentication for all repositories configured in Mantis. Probably something like iterating through all repositories and checking for the application id and populate all repos with the same application id with the same authentication token and refresh token once the oauth procedure is finished? Am I missing smth. here? Basically its not a problem to do the oauth procedure for every repo, it works.

fokkersim avatar Feb 16 '22 22:02 fokkersim

assign also the authentication token and refresh token to a repository [...] I dont see, how this would work with one authentication for all repositories configured in Mantis

I believe this is by design, it was never meant to be a global authentication

dregad avatar Feb 17 '22 22:02 dregad

I believe this is by design, it was never meant to be a global authentication

I never would have had the idea that this could work, if it wouldnt be mentioned in the Github plugin documentation

NOTE: a single OAuth app is sufficient to handle all the GitHub repositories configured in a given MantisBT instance Github doc

fokkersim avatar Feb 18 '22 15:02 fokkersim

I found out that this works for github, because github allows redirect_uris to be more felxible than gitea (see last two sentences). So that means for github your could define in github settings redirect_uri = https://mydomain/mantisbt/ and at the same time pass https://mydomain/mantisbt/+SUBDIRECTORY+PARAMS in the authentication request, which makes no issues. This is why a single OAuth app is sufficient for all github repos...

fokkersim avatar Feb 18 '22 18:02 fokkersim

I could not work on this for a couple of weeks now. I made a push to my repository https://github.com/fokkersim/SourceGitea maybe it helps. Basics seem to work for me

fokkersim avatar Apr 28 '22 17:04 fokkersim