On 15/10/2012 6:47am, Joshua Russo wrote:
I have project that I have been working and I was contemplating open
sourcing it but I ran into a little hang up. How to handle the database
authentication. The settings file obviously needs to be included but I
don't want to advertise the production database login. How is this
generally handled?

Although best practice seems to be separate local settings files I prefer the same settings.py in both development and production. The big problem of course is that sensitive information might end up in the repository. And I haven't even considered open sourcing.

My solution is a tiny script called getcreds[1] which gets all the necessary sensitive info whenever/wherever it is needed. I'm comfortable that long in the future nothing sensitive was ever in the repo. That includes certificate keys, passwords, userids, email addresses - anything.

I keep a private directory in which all my sensitive creds are kept in plain text files with each item on a separate line. I adopt a personal convention of userid, password, ip-address, port, etc etc. But it doesn't matter because getcreds returns a list and creds[3] or creds[4] can mean anything you want[2] in your seetings.

Mike

[1]
# -*- coding: utf-8 -*-
def getcreds(fname, credsdir='/var/creds/xxxx'):
    """ Return a list of userid and password and perhaps other data.
    make sure there are a few empty lines at the end of fname to avoid
    keyerrors
    """
    creds = []
    fname = '%s/%s' % (credsdir, fname)
    with open(fname, 'r') as f:
        for line in f:
            creds.append(line.strip())
    return creds

[2]
#excerpt from settings ...
dbhost = getcreds.getcreds('db.host')
DATABASES = {
    'default': {
        'ENGINE':   'django.db.backends.postgresql_psycopg2',
        'NAME':     PROJECT,
        'USER':     dbhost[0],
        'PASSWORD': dbhost[1],
        'HOST':     dbhost[2],
        'PORT':     dbhost[3],









Also, are there procedures that need to be followed to "properly" open
source a project, or is it really just choosing a licence and dubbing it so?

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/LJU31pYrcXgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to