CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API Change proposal: password not mandatory anymore in cleartext
Pages: [1]

Author Topic: API Change proposal: password not mandatory anymore in cleartext  (Read 2287 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
API Change proposal: password not mandatory anymore in cleartext
November 15, 2009, 09:56:45 am
Hi all,

I'm trying to modify some of the cli (eg process cron for civimail) so it works from the shell, like it should instead of adding a layer of webserver and wget, and avoid the timeout and all that web introduced jazz.

So I end up with something along this line in the crontab

php bin/EmailProcessor.php -s example.org -u xavier -p {password that is supposed to be secret] -k ABCDE1234

And I really not like having the password in clear like that (and I don't like it either on the call of the REST interface)

Wes introduced a new feature to allow a per user key. I would suggest that we modify the authentication on the REST or on the CLI so if the user key is present, and correct, it doesn't need a password.

So, for the cli interface:

php bin/EmailProcessor.php -s example.org -u xavier -x sdgofgbuo2407 -k ABCDE1234

with z being the user key.

And changing the REST interface as well. For compatibility reason, probably keeping the two as an option for the next versions, but mentioning in the doc that the favoured option is the user key

What do you think ?

If you want to add another layer of security, we can list into the civicrm.setting the user(s) that are allowed to run via the cron or the REST.

Worthwhile ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

cap10morgan

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 9
Re: API Change proposal: password not mandatory anymore in cleartext
November 15, 2009, 10:21:11 am
One problem is that you in effect turn that user key into a password. It lets you perform many (someday, all) actions as that user via the API and other utility scripts like the e-mail sender. So that doesn't necessarily get you anything (except that it doesn't let you into the CMS, which for standalone is a non-issue anyway).

A better approach, in my opinion, would be to not require a username and password for scripts like the e-mail processor but instead severely restrict from which IPs they may connect. By default we'd set it to 127.0.0.1/32 (i.e. localhost) and actively prevent folks from setting it to 0.0.0.0/0 (i.e. world).

The long-term solution, in my mind, is OAuth (http://oauth.net/). But I don't have the time to implement that right now (nor on the horizon).

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API Change proposal: password not mandatory anymore in cleartext
November 15, 2009, 12:19:23 pm
Well, that's a password, but that can be as long and complicated as you want, and that won't be the same as the one for his online banking, email provider and every single account he ever created online.

As for the restriction to 127.0.0.1, then isn't it better to add an option in the config "cli only" in essence switching off the possibility to run the bin scripts from apache  ?

X+

P.S. On PHPList (at least for the cli commands, not sure you can all the crons from the web), you define in the setting the list of user(s) that can run the cron, and they don't need the password. Simple and efficient IMO.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Further reflexions on the "fake" security added by the key or the user + passwor
November 16, 2009, 12:11:19 am
Hi,

I'm trying to imagine what would be the case of a user that is able to run a php from the civicrm/bin from the shell, but can't READ the civicrm_settings.php file.

In other word, what is the point of requesting the key ? A bad/stupid guy that has access to the shell will simply have to read the setting file and copy the KEY, isn't it ?

I would argue that a much better security is to put the settings in readonly, and add a new variable inside cli_allowed_userid= array ("www-data","xdutoit"). And not let the program run if it isn t one of the linux users defined.

As for the civicrm user (not the linux user), what about adding a second variable listing the allowed civicrm users

cli_allowed_civicrm_users = array ('admin', 'cronuser')


so the linux users www-data and  xdutoit are the only ones that can run a script from the shell, and they can specify it to be run in civicrm as admin or cronuser only.
so:
php bin/EmailProcessor.php -s example.org -u cronuser

would be fine if xdutoit runs it

Again, I really dislike having a password in clear in the crontab (or in the list of process running, or in the apache log for the non cli version). Trying to find a solution as secure (arguably much secure) to replace it.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API Change proposal: password not mandatory anymore in cleartext
November 16, 2009, 06:45:55 am

1. I do think that we should definitely keep the web based invocation also irrespective of where we go with the CLI

2. I do agree that sending in the password via plain text is awful and needs to be fixed. Switching to using the user name and "user api key" is potentially a good workaround

3. Put all settings in the DB. We need to minimize stuff in settings file

4. If u'll want this change in 3.2, i'd start working on it / tweaking it NOW. Create an svn branch for this and then we can merge it back into trunk once we branch off for 3.1

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API Change proposal: password not mandatory anymore in cleartext
November 16, 2009, 09:00:28 am
Quote from: Donald Lobo on November 16, 2009, 06:45:55 am
1. I do think that we should definitely keep the web based invocation also irrespective of where we go with the CLI

Sure it was meant as an alternate access, not a replacement. I'd however suggest to put is as the "most robust" approach in the doc.


Quote from: Donald Lobo on November 16, 2009, 06:45:55 am

2. I do agree that sending in the password via plain text is awful and needs to be fixed. Switching to using the user name and "user api key" is potentially a good workaround


On the REST interface, the user api key is already there. That's just a matter of not putting the password mandatory (I'll need to discuss it with Wes, and obviously make it validated by you, that's a sensitive area).

Quote from: Donald Lobo on November 16, 2009, 06:45:55 am

3. Put all settings in the DB. We need to minimize stuff in settings file


Well, it should be as "protected" as possible and that's probably the same argument in favour of putting the KEY in the civicrm_settings.
Beside, that's about configuring the shell access, would make sense to have that on a config file, isn't it.

This being said, where would you put the config in the db ?

Quote from: Donald Lobo on November 16, 2009, 06:45:55 am

4. If u'll want this change in 3.2, i'd start working on it / tweaking it NOW. Create an svn branch for this and then we can merge it back into trunk once we branch off for 3.1

I'm working on a local copy of the trunk. And won't commit until you branch.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API Change proposal: password not mandatory anymore in cleartext

This forum was archived on 2017-11-26.