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

CHE-5169: Add Git configuration agent #5285

Merged
merged 14 commits into from Jun 14, 2017
Merged

CHE-5169: Add Git configuration agent #5285

merged 14 commits into from Jun 14, 2017

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Jun 7, 2017

What does this PR do?

Added Git configuration agent that fetches SSH keys and Git username and email from CHE user preferences, and injects to console Git preferences

What issues does this PR fix or reference?

fixes #5169
fixes #4969

Changelog

Added a Git configuration agent that fetches Git SSH keys, username / email from Che preferences, and injects them into the console Git preferences.

Release Notes

N/A

Docs PR

N/A

@vinokurig vinokurig requested review from skabashnyuk, tolusha, a user and bmicklea June 7, 2017 06:48
@codenvy-ci
Copy link

Build # 2744 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/2744/ to view the results.

@gorkem
Copy link
Contributor

gorkem commented Jun 7, 2017

@ibuziuk Take a look at this PR and can you comment if this will work with the GH token work that you have just done for OSIO?

@tolusha
Copy link
Contributor

tolusha commented Jun 7, 2017

@vinokurig
Git agent name misused. Git agent means that git will be installed and ready to use.
Your PR brings new capability.

@vinokurig
Copy link
Contributor Author

@tolusha How about 'Git injector agent'?

@codenvy-ci
Copy link

@bmicklea bmicklea changed the title CHE-5169: Add Git agent CHE-5169: Add Git configuration agent Jun 7, 2017
@bmicklea
Copy link

bmicklea commented Jun 7, 2017

Updated title and description to clarify the agent's purpose. @vinokurig - does this inject preferences into the Git console only? In other words is it ensuring that the preferences match in console and menu?

@ibuziuk
Copy link
Member

ibuziuk commented Jun 7, 2017

@gorkem No, it is not related to setting access token during workspace creation (moving @sunix PRs #4444 #4438 to rh-che) This is more related to what was raised up on the mailing list recently by Pete / Burr - not possible to push via terminal OOTB

@slemeur
Copy link
Contributor

slemeur commented Jun 7, 2017

@vinokurig : Could you explain why you built this capability by using an agent?

@ghost
Copy link

ghost commented Jun 7, 2017

@slemeur I can explain - We need to make sure that this feature works in any environment. We had an idea to embed it into our base images and start in an entrypoint. However, it won't work with non Eclipse certified images.

@bmicklea what this agent does is that when git performs ssh operations, it gets keys and git prefs (committer name and email) from user prefs, if any.

@tolusha
Copy link
Contributor

tolusha commented Jun 7, 2017

How about 'Git injector agent'?

I don't like either

@vinokurig
Copy link
Contributor Author

@tolusha may be 'Git synchroniser agent' ?

@ghost
Copy link

ghost commented Jun 8, 2017

Git sync agent is cleaner I think.

@bmicklea
Copy link

bmicklea commented Jun 8, 2017

But it's inaccurate isn't it? If I change a git setting in the terminal it doesn't sync it back to the Che preferences panel does it?

@vinokurig
Copy link
Contributor Author

@bmicklea It doesn't change back CHE preferences, may be Git fetcher agent ?

@bmicklea
Copy link

bmicklea commented Jun 8, 2017

I think Git Config agent is clearest since it's configuring Git preferences.


if [ -z "$(cat /home/user/.bashrc | grep GIT_SSH)" ]
then
printf '\n export GIT_SSH='"$SCRIPT_FILE" >> /home/user/.bashrc
Copy link

Choose a reason for hiding this comment

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

Shouldn't it be ~ since /home/user is home directory only in Eclipse images?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reworked to relative path

@vinokurig
Copy link
Contributor Author

@bmicklea The problem is that the agent doesn't fetch only configs, it also fetches SSH keys

@bmicklea
Copy link

bmicklea commented Jun 8, 2017

if it's really just authentication then what about the git auth agent?

@vinokurig
Copy link
Contributor Author

Not just authentication, SSH keys injection + config injection

@codenvy-ci
Copy link

@vinokurig
Copy link
Contributor Author

I think Git sync agent is the most suitable name for this agent @bmicklea @tolusha WDYT?

@mmorhun
Copy link
Contributor

mmorhun commented Jun 12, 2017

@vinokurig what about Git credentials agent? WDYT?

@bmicklea
Copy link

I'm +1 for git credentials agent. I don't like git sync agent because sync implies something that is bi-directional and responsive but this just goes in one direction.

@vinokurig
Copy link
Contributor Author

Renamed to Git Credentials agent @bmicklea @tolusha @skabashnyuk @eivantsov please review

<version>5.12.0-SNAPSHOT</version>
</parent>
<artifactId>git-credentials-agent</artifactId>
<name>Git Agent</name>
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix name accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,5 @@
{
"id": "org.eclipse.che.git",
Copy link
Contributor

Choose a reason for hiding this comment

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

"id": "org.eclipse.che.git-credentials",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

agents/pom.xml Outdated
@@ -32,6 +32,7 @@
<module>che-core-api-agent-shared</module>
<module>che-core-api-agent</module>
<module>ls-json</module>
<module>git</module>
Copy link
Contributor

Choose a reason for hiding this comment

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

git-credentials

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@codenvy-ci
Copy link

@codenvy-ci
Copy link

Build # 2801 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/2801/ to view the results.


user_name="$(${request} "$api_url/preferences$(if [ -n "$token" ]; then echo "?token=$token"; fi)" | grep -Po '"git.committer.name":.*?[^\\]",' | sed -e "s/\"git.committer.name\":\"//" | sed -e "s/\",//")"
user_email="$(${request} "$api_url/preferences$(if [ -n "$token" ]; then echo "?token=$token"; fi)" | grep -Po '"git.committer.email":.*?[^\\]",' | sed -e "s/\"git.committer.email\":\"//" | sed -e "s/\",//")"
git config --global user.name \""$user_name"\"
Copy link
Contributor

Choose a reason for hiding this comment

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

that means that any commit from console git will be made from the name of workspace owner. Not sure it's good collaboration experience.

Copy link

Choose a reason for hiding this comment

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

Right, but it was discussed before, I mean security implications and commit authorship.

@vinokurig vinokurig merged commit c5e7a34 into master Jun 14, 2017
@vinokurig vinokurig added this to the 5.13.0 milestone Jun 14, 2017
@codenvy-ci
Copy link

@vinokurig vinokurig deleted the CHE-5169 branch June 14, 2017 14:44
@sunix
Copy link
Contributor

sunix commented Jun 26, 2017

how would this agent behave with multitenant ? (multiple users accessing to the same workspace running the terminal)
It would be bad if I give access to someone to my workspace and he got access to my git credentials

@tolusha
Copy link
Contributor

tolusha commented Jun 26, 2017

It is the same if you allowed someone to use your laptop. It is bad (
It is supposed that user injects this agent thoughtfully.

@sunix
Copy link
Contributor

sunix commented Jun 28, 2017

Sorry, No it is not the same, che is a cloud workspace. Sharing the workspace is not bad but something users expect to have. When you share your laptop to someone else, you don't give access to your user account, nor your Chome saved passwords. To me, all these git users related injection shouldn't go through a shared agent. This is a major security issue and should be reverted IMO. Moreover generated ssh keys are not protected with a passphrase.

@gorkem
Copy link
Contributor

gorkem commented Jun 28, 2017

I agree with @sunix . We should at least have password protection enabled or remove the SSH key on shared workspaces.

@slemeur slemeur added the kind/enhancement A feature request - must adhere to the feature request template. label Jul 6, 2017
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Git credentials agent fetches SSH keys and Git username and email from CHE user preferences, and injects to console Git preferences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync user ssh keys with git in a dev machine Git preferences for command line
10 participants