gerrit-oauth-provider icon indicating copy to clipboard operation
gerrit-oauth-provider copied to clipboard

Untrusted identity problem

Open spinus opened this issue 9 years ago • 12 comments

  • gerrit 2.11
  • Add OAuth provider

-> Lost admin group, my identitty is "untrusted"

solution: I had to add

[auth]
        allowedOpenID = ^.*$
        trustedOpenID = ^.*$

to the config (by default it accepts only ids starting with http:// or https://, so oauth "numbers" were not matched).

As gerrit "sees" oauth plugin as OpenID identities (it's probably to gerrit internals, I'm not sure) it would be nice to add some prefix to the EXTERNAL_IDS table. For example, ssh identities have "username:" prefix. OpenID identities have URL, but for this plugin the content of the field is just some number (user id on oauth provider side?).

Maybe this could be the URL to user account on provider side or something like:

  • "oauth:github:2132131"
  • "oauth:https://github.com/user" ?

Also would be nice to add this tip to readme, it took a while to figure it out.

spinus avatar Apr 24 '15 00:04 spinus

There is similar discussion in context of this change on gerrit-review: [1].

  • [1] https://gerrit-review.googlesource.com/67280

davido avatar Apr 28 '15 09:04 davido

Agreed on the prefix. Btw the current OAuth / GitHub implementation (based on HTTP authentication) uses the following scheme: external:github_oauth:NNNNNN (using the Gerrit's ability to store external identities).

Defining a new scheme for oauth would then result in: oauth:github:NNNNNN

lucamilanesio avatar Apr 28 '15 09:04 lucamilanesio

@lucamilanesio So you are going to use oauth-provider-name as middle suffix (not plugin name!)? What when two different gerrit-oauth-provider plugin would use the same name?

Let's say, both gerrit-oauth-provider and GitHub plugin would choose "github" as middle prefix, and GitHub-login-id as external_id, then it would end up with:

  • oauth:github:lucamilanesio
  • oauth:github:lucamilanesio

for both plugins, when both OAuth-providers are deployed on the same gerrit site. That cannot work either.

davido avatar Apr 28 '15 09:04 davido

@davido true, we need to keep the plugin name as well in the syntax somewhere :-)

lucamilanesio avatar Apr 28 '15 09:04 lucamilanesio

@lucamilanesio We should be able to agree on that ;-)

davido avatar Apr 28 '15 10:04 davido

oauth:provider/plugin-name:NNNN ... how does it sound?

Example: oauth:github/github-plugin:lucamilanesio

lucamilanesio avatar Apr 28 '15 10:04 lucamilanesio

Or just plugin name (with or without provider-suffix in my case), to follow DRY principle?

GitHub:

  • oauth:github:lucamilanesio

Gerrit-OAuth-Provider:

  • oauth:gerrit-oauth-provider:lucamilanesio

or mit suffix:

  • oauth:gerrit-oauth-provider-github-oauth:lucamilanesio

?

davido avatar Apr 28 '15 10:04 davido

I havent't looked at intetrnals yet but maybe if both plugins use the same user id the prefix and whole auth string could be used by both plugins (oauth procedure it done the same way)?

spinus avatar Apr 28 '15 12:04 spinus

Yes, I asked another gerrit-oauth-provider plugin stock holder, and he voted for your proposal:

oauth:github:lucamilanesio
oauth:google:394875623489576398756395

No matter which plugin identified this entry. This would even allow to replace the plugins and still all would keep working, at least this is the plan ;-)

davido avatar Apr 28 '15 12:04 davido

Great stuff. Cheers.

spinus avatar Apr 28 '15 12:04 spinus

@davido not really as different plugins for the same OAuth provider could use different external ids (gerrit-oauth-provider uses the GitHub internal ID whilst GitHub plugin uses GitHub username).

We do need to include the plugin name as well, in order to identity who is managing and has provided that identity over time.

lucamilanesio avatar Apr 28 '15 15:04 lucamilanesio

@lucamilanesio Good catch! I wonder why I did it and if changing the semantic in my plugin would be better approach? I was confused that Google OAuth doesn't such a thing as user id, and i went to if, and added GitHub later to the plugin and missed to switch to the login external id.

davido avatar Apr 29 '15 11:04 davido