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

Set Github token through workspace master Rest API. Added a force act… #4444

Closed
wants to merge 2 commits into from

Conversation

sunix
Copy link
Contributor

@sunix sunix commented Mar 16, 2017

Set Github token through workspace master Rest API. Added a force activation property variable to register Github Oauth provider even without client id/secret

Signed-off-by: Sun Seng David Tan sutan@redhat.com

What does this PR do?

  • add a new REST operation to set a Oauth token to an existing provider
  • add a property che.oauth.github.forceactivation to force registration of Github Oauth provider, even without client id/secret (actually set NULL string for these value)

What issues does this PR fix or reference?

https://issues.jboss.org/browse/CHE-151

Changelog

Set Github token through workspace master Rest API. Added a force activation property variable to register Github Oauth provider even without client id/secret

Release Notes

Set Github token through workspace master Rest API. Added a force activation property variable to register Github Oauth provider even without client id/secret

Docs PR

…ivation property variable to register Github Oauth provider even without client id/secret

Signed-off-by: Sun Seng David Tan <sutan@redhat.com>
Copy link
Contributor

@skabashnyuk skabashnyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually -1
Explained opinion here #4438

@@ -50,6 +50,8 @@ oauth.github.authuri= https://github.com/login/oauth/authorize
oauth.github.tokenuri= https://github.com/login/oauth/access_token
#redirected uris
oauth.github.redirecturis= http://localhost:${SERVER_PORT}/che/api/oauth/callback
# register github even without client id and secret
oauth.github.forceactivation=false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the place in code that uses this property. Can you point to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, will remove it

@@ -142,7 +142,8 @@ che.oauth.github.clientsecret=NULL
che.oauth.github.authuri= https://github.com/login/oauth/authorize
che.oauth.github.tokenuri= https://github.com/login/oauth/access_token
che.oauth.github.redirecturis= http://localhost:${SERVER_PORT}/wsmaster/api/oauth/callback

# register github even without client id and secret
che.oauth.github.forceactivation=false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on what will happen if token is not injected but this property is set to true and client secret/id are unset.
What will happen on clicking OAuth button in IDE?
What will happen on an operation with github?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These video shows an attempt to perform a git operation or github operation (would be similar to clicking in OAuth button):

  1. attempt with default che.oauth.github.forceactivation false
  2. attempt with che.oauth.github.forceactivation true without setToken
  3. attempt with che.oauth.github.forceactivation true and setting the token

&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
public GitHubOAuthAuthenticator(@Nullable @Named("che.oauth.github.clientid") String clientId, //

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is uncommon for existing codebase to use trailing slashes, can you elaborate on why they are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the default formatter in Che. So these were to keep the current formatting

return;
}

if (forceActivation != null && forceActivation) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make forceActivation primitive then nullness check can be avoided.

Copy link
Contributor Author

@sunix sunix Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be a default null value (so it's false by default) ?


if (forceActivation != null && forceActivation) {
configure("NULL", "NULL", redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return is not needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for readability. But I can remove it ...

}

if (forceActivation != null && forceActivation) {
configure("NULL", "NULL", redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If client id/secret are not configured how other params (redirectUris, etc) can be used? Should they be unset too?

@POST
@Path("token")
@Consumes(MediaType.APPLICATION_JSON)
public void setToken(@Required @QueryParam("oauth_provider") String oauthProvider, //

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like one of map's entry can growth infinitely because of this API, and it is not restricted so any user of the product can cause OOM

Copy link
Contributor Author

@sunix sunix Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that EnvironmentContext.getCurrent().getSubject().getUserId(); can return any userId ? or be dynamically changed ? are you sure of that ?
If you are sure of that, so getToken shouldn't be available because anyone could still others' token ...

@codenvy-ci
Copy link

@skabashnyuk
Copy link
Contributor

@sunix are you 100% sure that there is no way(even theoretical) to hack the system like Che or Codenvy with this method? How confident you are?

@POST @Path("token"

@l0rd @benoitf wdyt? Is this only my paranoia :)?

@sunix
Copy link
Contributor Author

sunix commented Mar 16, 2017

@skabashnyuk I think that User's data and access to other system is more important than anything.
But if I were a hacker, I would try to get the token and have access to the users Github ( or whatever) and steal informations or change rights if I can. Setting the token ... ? I really don't see how this can be used.

In my opinion, setting the token and use another system to do the oauth stuff is actually more secured than letting Codenvy/Che doing the whole thing: the system responsible for oauth would focus on security ... where as we (Che) want to focus our effort on providing the best development tool.

@skabashnyuk
Copy link
Contributor

Can you comment
https://oauth.net/articles/authentication/
Injection of access tokens
An additional (and very dangerous) threat occurs when clients accept access tokens from sources other than the return call from the token endpoint. This can occur for a client that uses the implicit flow (where the token is passed directly as a parameter in the URL hash) and don't properly use the OAuth state parameter. This issue can also occur if different parts of an application pass the access token between components in order to "share" access among them. This is problematic because it opens up a place for access tokens to potentially be injected into an application by an outside party (and potentially leak outside of the application). If the client application does not validate the access token through some mechanism, it has no way of differentiating between a valid token and an attack token.

This can be mitigated by using the authorization code flow and only accepting tokens directly from the authorization server's token enpdoint, and by using a state value that is unguessable by an attacker.

Are you sure it's not related to what you are proposing?

@sunix
Copy link
Contributor Author

sunix commented Mar 16, 2017

Yes OK. Thanks for this. The plan is: we will add validation of token.
@skabashnyuk how does it sounds ? or you still think we shouldn't add a setToken at all ?

…rce activation property variable to register Github Oauth provider even without client id/secret

Signed-off-by: Sun Seng David Tan <sutan@redhat.com>
@codenvy-ci
Copy link

@TylerJewell
Copy link

@sunix - I think your plan sounds appropriate. What is the plan to revise and then get this merged?

@vparfonov
Copy link
Contributor

@sunix @skabashnyuk any update here, look like not actual for now?

@sunix
Copy link
Contributor Author

sunix commented Jul 17, 2017

not needed anymore thanks

@sunix sunix closed this Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants