The python twisted ssh daemon needs a web service to authenticate against like like the one currently provided by project_git_auth. This module is being replaced by this web service and other bits of code in other places. One of those bits is an authentication submodule provided by vcs_project.

sdboyer and mikey_p discussed for a while in IRC today and decided on the following:

The service will now be repo focused and will have a structure like this: http://drupalbin.com/17188 but with the added user data elements found here: http://drupalbin.com/17182

The base structure will be provided by the new submodule of vcs project but there will be two hooks, one for 'lookup' or 'auth' allowing other modules to reach in and add a way to find the user we're trying to authenticate (by ssh key fingerprint, for example) and another for 'data_alter' where modules can add other data (like password, ssh key fingerprints, etc.).

Comments

tizzo’s picture

tizzo’s picture

Assigned: tizzo » Unassigned
Status: Active » Needs review
StatusFileSize
new4.78 KB

This patch adds the simple webservice submodule and also adds a couple of useful api functions to versioncontrol_project.

I made the patch in a kinda funky way, try applying from vcs_project's root without the -p0 option. That should work, sorry about that.

mikey_p’s picture

Issue tags: +git phase 2, +git sprint 8
StatusFileSize
new4.25 KB

Looks good, would you like me to go head and commit this so that you can start patching against this?

Also, versioncontrol_project_get_project_repository_from_nid() looks like a duplicate of versioncontrol_project_repository_load().

I'm also attaching a filterdiffed version of the patch.

tizzo’s picture

Ah... I missed versioncontrol_project_repository_load(). I have to say I have no idea from the function name what is being loaded though. I suppose I should create an issue to rename that function?

Committing this would be great!

dww’s picture

Status: Needs review » Needs work
$repository = versioncontrol_project_get_project_repository_from_uri($project_uri);
$project = node_load(project_get_nid_from_uri($project_uri));

$project->versioncontrol_project['repo'] already has the repo, so I don't think we need versioncontrol_project_get_project_repository_from_uri() at all. And yeah, let's remove versioncontrol_project_get_project_repository_from_nid() while we're at it, since it's duplicate.

Otherwise, this seems good. Didn't look *that* closely, and certainly didn't test.

tizzo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.18 KB

Updated as per dww and mikey_p's notes.

dww’s picture

Status: Needs review » Needs work

Sorry, I didn't review closely enough earlier. I didn't realize we're publishing md5 hashed passwords in here. ;) Yes, definitely want a submodule for this. However, we need some more painful warnings about only turning it on if you've taken steps to lock it down. Probably that should just be in the description in the .info file. If it needs a lot of text, perhaps we should add a README.txt and have the .info file description just say something like:

<strong>This module is insecure</strong> unless you read the README.txt and take steps to restrict access to this service.

dww’s picture

Oh, and while you're rerolling, s/$user/$account/. There have been a number of security bugs cause by people using $user as a local variable name and then adding global $user. So, it's always safer to call your local variables $account.

tizzo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.13 KB

After giving this a bit of thought I think going with a drush command is going to be much easier than setting up the protected service on staging by Friday.

Sam and I discussed this and suspect that using some shared key/value store (perhaps something similar to memcachedb) may make more sense. In the meantime, this patch gives us what we need.

tizzo’s picture

StatusFileSize
new3.06 KB

oops, last patch was borked.

New and (hopefully) unborked.

dww’s picture

Title: Add versioncontrol authentication webservice (in a submodule) » Add versioncontrol authentication drush command
Status: Needs review » Needs work

Yay, thanks! In the interest of sprint 8 progress, I just addressed a few code style and legibility cleanups and committed to HEAD of vc_project: http://drupal.org/cvs?commit=480564

My only lingering concerns are:

A) At #1023856-3: Determine best way to provide private webservice to twisted daemon pwolanin asked (and I agree) why does this have to be your d.o login password? Couldn't we have another password field on the user account page for this feature if you want to enable password-only Git access?

B) This adds a drupal_alter(). It'd be nice if it therefore adds a versioncontrol_project.api.php file. ;) To facilitate this, I already added a stub of the file and docs, it just needs to actually be documented now. ;)

Both of these could happen in sprint 9 if needed. Maybe they should be split to separate issues so this one can be fixed.

tizzo’s picture

StatusFileSize
new1.61 KB

A couple of things needed to be tweaked because of changes in sshkeys HEAD and fixed a typo.

dww’s picture

#12 visually looks fine. Can't test it, but I assume it's good. Committed to vc_project HEAD, and deployed to git-dev.

tizzo’s picture

Status: Needs work » Needs review
StatusFileSize
new2.98 KB

Marking this as 'needs review' again because there is new code. We still need an api example.

This makes a small change to the data served back by the drush command ensuring that we have an object and not a linear array created by json_encode. It was tripping up python (which was making a list instead of a dict on json.loads()). Also added a command to check a password for a user (needed by the git daemon and probably useful to other future auth systems/hooks as well).

dww’s picture

Status: Needs review » Needs work

Reviewed and committed the fix for the json output to HEAD: http://drupal.org/cvs?commit=482154 -- I must admit I don't really understand why we need the empty field like that, but I believe you.

C) It'd be nice to add a code comment about this json object stuff, but I didn't feel qualified to write it. ;)

I made a few tweaks to the new drush command and committed that separately to HEAD: http://drupal.org/cvs?commit=482156

D) Pretty sure the way the code was written would throw PHP notices if you gave it an unknown username, since user_load() would return FALSE but you were directly trying to access ->pass off the return value from user_load().

E) Added an @todo that we don't really need a full bootstrap and user_load() to do this.

Anyway, back to needs work for 11.B, 15.C, and perhaps 15.E. 15.D is already fixed in HEAD.

Cheers,
-Derek

sdboyer’s picture

Status: Needs work » Fixed

This is in, fixed, and in fact has undergone some changes since this issue was last touched. Marking fixed.

Status: Fixed » Closed (fixed)
Issue tags: -git phase 2, -git sprint 8

Automatically closed -- issue fixed for 2 weeks with no activity.