Permalink
Browse files

Autocreate CA functionality working, with needed additions to conf an…

…d settings files.
  • Loading branch information...
1 parent 7f23d0d commit ae3cdd1839b9576b19b37b078784bccc73c9df4d @clemesha-ooi clemesha-ooi committed Feb 10, 2010
View
@@ -12,6 +12,9 @@
ssl.cert: var/sslcert.pem
ssl.key: var/sslkey.pem
+# CA dir
+
+ca.dir: var/ca
# Port to run the standalone webserver on.
@@ -25,7 +25,7 @@ def nimbus_user_create(sender, instance, **kwargs):
Notes:
- Only attempt to create Nimbus User on Django User creation.
"""
- if kwargs.get('created'):
+ if kwargs.get('created') and instance.id != 1:
remote_user_creator = kwargs.get("remote_user_creator")
if remote_user_creator is None:
remote_user_creator = nimbus_user_create_remote
@@ -5,6 +5,7 @@
import sys
here = lambda x: os.path.join(os.path.abspath(os.path.dirname(__file__)), x)
+WEBDIR = here("../../../../") #uh, ok?
# ------------------------------------------------------------------------------
@@ -1,6 +1,8 @@
+from django.conf import settings
+from nimbusweb.setup.ezpz_ca import EzPzCA
def create_nimbus_user_stub(dn):
- nimbus_userid = "test_nimbus_userid"
+ nimbus_userid = "test_nimbus_userid - dn =>", dn
return nimbus_userid
create_nimbus_user = create_nimbus_user_stub
@@ -9,8 +11,16 @@ def extract_dn_stub(cert, key):
return new_users_dn
extract_dn = extract_dn_stub
-def autocreate_cert_stub():
+def autocreate_cert_stub(cn):
new_users_dn = "test_dn"
return new_users_dn
autocreate_cert = autocreate_cert_stub
-
+
+def autocreate_cert(cn):
+ """Create a cert using local CA functionality.
+
+ The 'cn' (common name) is the 'username' of the new User.
+ """
+ ezpz = EzPzCA(settings.NIMBUS_CADIR, settings.WEBDIR)
+ (DN, cert, key) = ezpz.create_cert(cn)
+ return (DN, cert, key)
@@ -53,7 +53,8 @@ def method(request, method):
#No form data needed, correct?
form = AutoCreateForm(request.POST)
if form.is_valid():
- dn = util.autocreate_cert()
+ cn = form.cleaned_data["username"] #username is used as the CN (common name)
+ (dn, cert, key) = util.autocreate_cert(cn)
else:
form = AutoCreateForm()
@@ -3,7 +3,7 @@
from setuperrors import *
import string
-def run(basedir, timezone, accountprompt, log, debug, insecuremode, printurl, expire_hours):
+def run(basedir, timezone, accountprompt, log, debug, insecuremode, printurl, expire_hours, cadir):
log.debug("Installing new configurations to django and cherrypy")
if not accountprompt:
@@ -34,6 +34,9 @@ def run(basedir, timezone, accountprompt, log, debug, insecuremode, printurl, ex
lines.append("TIME_ZONE = '%s'" % timezone)
lines.append("NIMBUS_ACCOUNT_PROMPT = '%s'" % accountprompt)
+
+ cadir_path = pathutil.pathjoin(basedir, cadir)
+ lines.append("NIMBUS_CADIR = '%s'" % cadir_path)
if debug:
lines.append("DEBUG = True")
@@ -307,6 +307,7 @@ def main(argv=None):
certconf = config_from_key(config, "ssl.cert")
keyconf = config_from_key(config, "ssl.key")
+ cadir = config_from_key(config, "ca.dir")
timezone = config_from_key(config, "timezone")
port = config_from_key(config, "webserver.port")
printurl = config_from_key(config, "print.url")
@@ -330,7 +331,7 @@ def main(argv=None):
checkssl.run(basedir, certconf, keyconf, log)
if opts.newconf:
- newconf.run(basedir, timezone, accountprompt, log, printdebugoutput, insecuremode, printurl, expire_hours)
+ newconf.run(basedir, timezone, accountprompt, log, printdebugoutput, insecuremode, printurl, expire_hours, cadir)
if opts.printport:
if not port:
@@ -400,4 +401,4 @@ def main(argv=None):
print >>sys.stderr, errmsg
traceback.print_tb(sys.exc_info()[2])
sys.exit(97)
-
+

0 comments on commit ae3cdd1

Please sign in to comment.