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

Integrate an OAuth2 provider #27

Open
tboerger opened this Issue Nov 3, 2016 · 35 comments

Comments

@tboerger
Member

tboerger commented Nov 3, 2016

To make it easier for other applications to hook into Gitea we should integrate an OAuth2 provider, that way tools like Drone CI can authenticate against Gitea much easier. A good library for that can be https://github.com/RangelReale/osin.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@tboerger tboerger added this to the 1.2.0 milestone Nov 3, 2016

@joubertredrat

This comment has been minimized.

Show comment
Hide comment
@joubertredrat

joubertredrat Nov 3, 2016

Contributor

Oh, sounds good this :)

Contributor

joubertredrat commented Nov 3, 2016

Oh, sounds good this :)

@bkcsoft

This comment has been minimized.

Show comment
Hide comment
@bkcsoft

bkcsoft Nov 4, 2016

Member

Should this be integrated as "The" login-handler, or as an optional dependency? (i.e. build tag)

Member

bkcsoft commented Nov 4, 2016

Should this be integrated as "The" login-handler, or as an optional dependency? (i.e. build tag)

@tboerger

This comment has been minimized.

Show comment
Hide comment
@tboerger

tboerger Nov 4, 2016

Member

I think we can always integrate it but add an option for admins to disable it

Member

tboerger commented Nov 4, 2016

I think we can always integrate it but add an option for admins to disable it

@lunny

This comment has been minimized.

Show comment
Hide comment
@lunny

lunny Nov 4, 2016

Member

No build tag but default is closed until admin open it.

Member

lunny commented Nov 4, 2016

No build tag but default is closed until admin open it.

@joubertredrat

This comment has been minimized.

Show comment
Hide comment
@joubertredrat

joubertredrat Nov 4, 2016

Contributor

Nice idea 👍

Contributor

joubertredrat commented Nov 4, 2016

Nice idea 👍

@bkcsoft

This comment has been minimized.

Show comment
Hide comment
@bkcsoft

bkcsoft Nov 7, 2016

Member

@tboerger @lunny I was more wondering if all Authentication should be handled by OAuth, therefore removing the old auth-module

Member

bkcsoft commented Nov 7, 2016

@tboerger @lunny I was more wondering if all Authentication should be handled by OAuth, therefore removing the old auth-module

dbalexandre pushed a commit to gitlabhq/gitlabhq that referenced this issue Dec 21, 2016

Merge branch '22348-gitea-importer' into 'master'
It adds a brand new importer for Gitea!

This is a continuation of !6945 started by @bkc.

Gitea aims to be 100% GitHub-compatible but there's a few differences:

- Gitea is not an OAuth provider (yet): go-gitea/gitea#27
  - This means we cannot map Gitea users given an assignee ID => assignees are not set on imported issues and merge requests
- No releases API for now: go-gitea/gitea#330
- API version is `v1` (GitHub is `v3`)
- The IID field for milestones is `id` compared to `number` in GitHub.
- Issues, PRs, milestones, labels don't have a `url` field (the importer now fallback to `''` in that case)

**Known issues:**

- Comments are not imported because comments JSON always have a blank `html_url`/`issue_url`/`pull_request_url`, so the IID cannot be extracted and the issuable cannot be found... :( This is tracked in go-gitea/gitea#401, and solved by gogs/gogs#3624 but this needs to be submitted / merged in Gitea.

This is noted in the documentation.

## Are there points in the code the reviewer needs to double check?

1. I've made `Import::GiteaController` inherit from `Import::GithubController` since both controllers should be identical in the long-term and their current differences are small.
1. I've added a base `IssuableFormatter` class from which `IssueFormatter` & `PullRequestFormatter` inherit
1. I've added shared examples for GitHub/Gitea importer classes
1. I've made `Gitlab::ImportSources` more robust and tested! 🎄 
1. I've added routing specs for import routes! 🎄 

Closes #22348

See merge request !8116

dreampet pushed a commit to dreampet/gitlab that referenced this issue Dec 22, 2016

Merge branch '22348-gitea-importer' into 'master'
It adds a brand new importer for Gitea!

This is a continuation of !6945 started by @bkc.

Gitea aims to be 100% GitHub-compatible but there's a few differences:

- Gitea is not an OAuth provider (yet): go-gitea/gitea#27
  - This means we cannot map Gitea users given an assignee ID => assignees are not set on imported issues and merge requests
- No releases API for now: go-gitea/gitea#330
- API version is `v1` (GitHub is `v3`)
- The IID field for milestones is `id` compared to `number` in GitHub.
- Issues, PRs, milestones, labels don't have a `url` field (the importer now fallback to `''` in that case)

**Known issues:**

- Comments are not imported because comments JSON always have a blank `html_url`/`issue_url`/`pull_request_url`, so the IID cannot be extracted and the issuable cannot be found... :( This is tracked in go-gitea/gitea#401, and solved by gogs/gogs#3624 but this needs to be submitted / merged in Gitea.

This is noted in the documentation.

## Are there points in the code the reviewer needs to double check?

1. I've made `Import::GiteaController` inherit from `Import::GithubController` since both controllers should be identical in the long-term and their current differences are small.
1. I've added a base `IssuableFormatter` class from which `IssueFormatter` & `PullRequestFormatter` inherit
1. I've added shared examples for GitHub/Gitea importer classes
1. I've made `Gitlab::ImportSources` more robust and tested! 🎄 
1. I've added routing specs for import routes! 🎄 

Closes #22348

See merge request !8116

@lunny lunny referenced this issue Feb 23, 2017

Open

Gitea hosted Gitea #1029

6 of 8 tasks complete

@lunny lunny modified the milestones: 1.3.0, 1.2.0 Apr 6, 2017

@JohnTheodore

This comment has been minimized.

Show comment
Hide comment
@JohnTheodore

JohnTheodore May 2, 2017

+1, this would be awesome!!!

JohnTheodore commented May 2, 2017

+1, this would be awesome!!!

@femaref

This comment has been minimized.

Show comment
Hide comment
@femaref

femaref Jun 9, 2017

is there an ETA for this? Would make life easier.

femaref commented Jun 9, 2017

is there an ETA for this? Would make life easier.

@lafriks

This comment has been minimized.

Show comment
Hide comment
@lafriks

lafriks Sep 4, 2017

Member

I think this one could be good option to integrate into gitea - https://github.com/coreos/dex

Member

lafriks commented Sep 4, 2017

I think this one could be good option to integrate into gitea - https://github.com/coreos/dex

@lunny

This comment has been minimized.

Show comment
Hide comment
@lunny

lunny Sep 5, 2017

Member

@lafriks Looks good, but it requires go1.8 I think.

Member

lunny commented Sep 5, 2017

@lafriks Looks good, but it requires go1.8 I think.

@mikehaertl

This comment has been minimized.

Show comment
Hide comment
@mikehaertl

mikehaertl Sep 5, 2017

Here's another Go based alternative: https://github.com/ory/hydra

ORY Hydra is not an identity provider (user sign up, user log in, password reset flow), but connects to your existing identity provider through a consent app.

It seems quite easy to set up. Here's a nice tutorial: https://www.ory.am/run-oauth2-server-open-source-api-security.html?

mikehaertl commented Sep 5, 2017

Here's another Go based alternative: https://github.com/ory/hydra

ORY Hydra is not an identity provider (user sign up, user log in, password reset flow), but connects to your existing identity provider through a consent app.

It seems quite easy to set up. Here's a nice tutorial: https://www.ory.am/run-oauth2-server-open-source-api-security.html?

@lafriks

This comment has been minimized.

Show comment
Hide comment
@lafriks

lafriks Sep 5, 2017

Member

@mikehaertl Hydra does not support JWT and from what I understand even if added they won't be in community edition - https://ory.gitbooks.io/hydra/content/faq.html#is-jwt-supported

Member

lafriks commented Sep 5, 2017

@mikehaertl Hydra does not support JWT and from what I understand even if added they won't be in community edition - https://ory.gitbooks.io/hydra/content/faq.html#is-jwt-supported

@tboerger

This comment has been minimized.

Show comment
Hide comment
@tboerger

tboerger Sep 5, 2017

Member

JWT is a must have for drone integration

Member

tboerger commented Sep 5, 2017

JWT is a must have for drone integration

@lunny lunny modified the milestones: 1.3.0, 1.x.x Oct 10, 2017

@ts468

This comment has been minimized.

Show comment
Hide comment
@ts468

ts468 Dec 15, 2017

Remotely related, but would it also be possible to extend gitea so that gitea can listen on a second interface over which every access is granted automatically?

The idea is to allow tooling without OAuth2 authentication capabilities, like Hydra, to fetch data over, e.g., the loopback interface.

ts468 commented Dec 15, 2017

Remotely related, but would it also be possible to extend gitea so that gitea can listen on a second interface over which every access is granted automatically?

The idea is to allow tooling without OAuth2 authentication capabilities, like Hydra, to fetch data over, e.g., the loopback interface.

@JonasFranzDEV

This comment has been minimized.

Show comment
Hide comment
@JonasFranzDEV

JonasFranzDEV Mar 11, 2018

Member

https://github.com/ory/fosite looks like a promising library to integrate this feature. It is used by hydra AFAIK.

Member

JonasFranzDEV commented Mar 11, 2018

https://github.com/ory/fosite looks like a promising library to integrate this feature. It is used by hydra AFAIK.

@tboerger

This comment has been minimized.

Show comment
Hide comment
@tboerger

tboerger Mar 12, 2018

Member

IMHO https://github.com/coreos/dex looks more promising

Member

tboerger commented Mar 12, 2018

IMHO https://github.com/coreos/dex looks more promising

@bkcsoft

This comment has been minimized.

Show comment
Hide comment
@bkcsoft

bkcsoft Apr 28, 2018

Member

Migrating all existing users would be a PITA though 😂

Member

bkcsoft commented Apr 28, 2018

Migrating all existing users would be a PITA though 😂

@aaronpk

This comment has been minimized.

Show comment
Hide comment
@aaronpk

aaronpk Jun 4, 2018

It would be fantastic if Gitea were its own OAuth2 provider! In fact, IndieAuth is the perfect candidate for how to implement this.

IndieAuth is an OAuth 2.0 extension, which avoids the centralized problems with existing OAuth solutions by using DNS for "registration" of client IDs and user IDs. Every user account is identified by a URL (for Gitea this could be your Gitea user page), and client IDs are also URLs (would be the Gitea instance home page in this case.)

This would let people sign in to other Gitea instances without any sort of prior relationship or doing client registration and such. Happy to walk through this in more detail if you're interested!

(originally posted at https://aaronparecki.com/2018/06/04/12/gitea-indieauth)

aaronpk commented Jun 4, 2018

It would be fantastic if Gitea were its own OAuth2 provider! In fact, IndieAuth is the perfect candidate for how to implement this.

IndieAuth is an OAuth 2.0 extension, which avoids the centralized problems with existing OAuth solutions by using DNS for "registration" of client IDs and user IDs. Every user account is identified by a URL (for Gitea this could be your Gitea user page), and client IDs are also URLs (would be the Gitea instance home page in this case.)

This would let people sign in to other Gitea instances without any sort of prior relationship or doing client registration and such. Happy to walk through this in more detail if you're interested!

(originally posted at https://aaronparecki.com/2018/06/04/12/gitea-indieauth)

@tboerger

This comment has been minimized.

Show comment
Hide comment
@tboerger

tboerger Jun 4, 2018

Member

Sounds like it's comparable with openid connect.

Member

tboerger commented Jun 4, 2018

Sounds like it's comparable with openid connect.

@aaronpk

This comment has been minimized.

Show comment
Hide comment
@aaronpk

aaronpk Jun 4, 2018

Not quite, since OpenID Connect still requires registering clients to get client credentials to use with the flows. There is a dynamic client registration part of OpenID Connect, but this allows you to entirely bypass the need for registering clients separately since we just piggyback on the existing DNS for identifying clients.

(originally posted at https://aaronparecki.com/2018/06/04/18/)

aaronpk commented Jun 4, 2018

Not quite, since OpenID Connect still requires registering clients to get client credentials to use with the flows. There is a dynamic client registration part of OpenID Connect, but this allows you to entirely bypass the need for registering clients separately since we just piggyback on the existing DNS for identifying clients.

(originally posted at https://aaronparecki.com/2018/06/04/18/)

@ekozan

This comment has been minimized.

Show comment
Hide comment
@ekozan

ekozan Jun 14, 2018

I'll make an PRs for this one if nobody work on it

  • 1 : Add OIDC lib and API
  • 2 : Add Application managment
  • 3 : Add Oauth HTTP HANDLER

ekozan commented Jun 14, 2018

I'll make an PRs for this one if nobody work on it

  • 1 : Add OIDC lib and API
  • 2 : Add Application managment
  • 3 : Add Oauth HTTP HANDLER
@bkcsoft

This comment has been minimized.

Show comment
Hide comment
@bkcsoft

bkcsoft Jun 15, 2018

Member

@ekozan Mind linking to "OIDC" since I have no clue what that is 🙂

Member

bkcsoft commented Jun 15, 2018

@ekozan Mind linking to "OIDC" since I have no clue what that is 🙂

@techknowlogick

This comment has been minimized.

Show comment
Hide comment
@techknowlogick

techknowlogick Jun 15, 2018

Member

I think OIDC == OpenID Connect

Member

techknowlogick commented Jun 15, 2018

I think OIDC == OpenID Connect

@ekozan

This comment has been minimized.

Show comment
Hide comment
@ekozan

ekozan Jun 15, 2018

@bkcsoft :D sorry openid Connect : http://openid.net/connect/

It's like openid3 based on oauth2

but i have dig more and i'll stick to Oauth2 for the moment

Because all big ( Gitlab, Github, etc... ) use Oauth

ekozan commented Jun 15, 2018

@bkcsoft :D sorry openid Connect : http://openid.net/connect/

It's like openid3 based on oauth2

but i have dig more and i'll stick to Oauth2 for the moment

Because all big ( Gitlab, Github, etc... ) use Oauth

@ekozan

This comment has been minimized.

Show comment
Hide comment
@ekozan

ekozan Jun 17, 2018

I need some help and advise on the design :)

Do you think i'm right :

  • Every User can create an oauth app
  • Every Org can create an oauth app
  • Gitea admin can create offical app

@tboerger @bkcsoft @lunny

ekozan commented Jun 17, 2018

I need some help and advise on the design :)

Do you think i'm right :

  • Every User can create an oauth app
  • Every Org can create an oauth app
  • Gitea admin can create offical app

@tboerger @bkcsoft @lunny

@tarelda

This comment has been minimized.

Show comment
Hide comment
@tarelda

tarelda Jun 25, 2018

Contributor

IMHO, integrate OAuth2 endpoints with maintained external lib (no point in reinventing the wheel) into API. Maybe even strip out code generation from authentication code flow and force only global/org scope. At least this would work for tools like Drone, registry etc.

Contributor

tarelda commented Jun 25, 2018

IMHO, integrate OAuth2 endpoints with maintained external lib (no point in reinventing the wheel) into API. Maybe even strip out code generation from authentication code flow and force only global/org scope. At least this would work for tools like Drone, registry etc.

@lunny

This comment has been minimized.

Show comment
Hide comment
@lunny

lunny Jun 26, 2018

Member

@ekozan just like github, I think. :)

Member

lunny commented Jun 26, 2018

@ekozan just like github, I think. :)

@ekozan

This comment has been minimized.

Show comment
Hide comment
@ekozan

ekozan Jun 26, 2018

@tarelda Oauth2 is realy simple protocol integrate an external library is just pointless, and many required library is already present in Gitea - 60% of the oauth or OIDC provider is the UI :)

I'll make the PR next week i had no time for finish the UI this week

ekozan commented Jun 26, 2018

@tarelda Oauth2 is realy simple protocol integrate an external library is just pointless, and many required library is already present in Gitea - 60% of the oauth or OIDC provider is the UI :)

I'll make the PR next week i had no time for finish the UI this week

@JonasFranzDEV

This comment has been minimized.

Show comment
Hide comment
@JonasFranzDEV

JonasFranzDEV Jun 30, 2018

Member

@ekozan You can create a seperate PR for the UI, this may improve the review speed.

Member

JonasFranzDEV commented Jun 30, 2018

@ekozan You can create a seperate PR for the UI, this may improve the review speed.

@vtolstov

This comment has been minimized.

Show comment
Hide comment
@vtolstov

vtolstov Aug 13, 2018

so, what library decided to use? i don't find any pr about oauth2 server in gitea

vtolstov commented Aug 13, 2018

so, what library decided to use? i don't find any pr about oauth2 server in gitea

@xdevs23

This comment has been minimized.

Show comment
Hide comment
@xdevs23

xdevs23 Aug 13, 2018

I'm waiting for this one as well. Definitely looking forward to it!

xdevs23 commented Aug 13, 2018

I'm waiting for this one as well. Definitely looking forward to it!

@go-gitea go-gitea deleted a comment from cutec-chris Aug 19, 2018

@JohnTheodore

This comment has been minimized.

Show comment
Hide comment
@JohnTheodore

JohnTheodore Aug 22, 2018

Is there a branch or PR related to this change? or we're still in the discussion phase.

JohnTheodore commented Aug 22, 2018

Is there a branch or PR related to this change? or we're still in the discussion phase.

@lunny

This comment has been minimized.

Show comment
Hide comment
@lunny

lunny Aug 23, 2018

Member

@JohnTheodore no people are working on this.

Member

lunny commented Aug 23, 2018

@JohnTheodore no people are working on this.

@xdevs23

This comment has been minimized.

Show comment
Hide comment
@xdevs23

xdevs23 Aug 23, 2018

That's unfortunate

xdevs23 commented Aug 23, 2018

That's unfortunate

@JohnTheodore

This comment has been minimized.

Show comment
Hide comment
@JohnTheodore

JohnTheodore Aug 24, 2018

@ekozan mentioned a PR, I wasn't sure if that happened.

JohnTheodore commented Aug 24, 2018

@ekozan mentioned a PR, I wasn't sure if that happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment