summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2015-05-20 17:27:22 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2015-05-20 17:27:27 (GMT)
commit3768a0c10398782bd36199176f1668e80296e8ca (patch)
tree2488fb3430dd26e3304838be50d66f7ce85c69eb
parenta7a828bb4687000a9f135ca9ab6c60cb93e909eb (diff)
downloadauthentic2-beid-3768a0c10398782bd36199176f1668e80296e8ca.zip
authentic2-beid-3768a0c10398782bd36199176f1668e80296e8ca.tar.gz
authentic2-beid-3768a0c10398782bd36199176f1668e80296e8ca.tar.bz2
associated certificate to new registered user
-rw-r--r--src/authentic2_beid/util.py3
-rw-r--r--src/authentic2_beid/views.py11
2 files changed, 11 insertions, 3 deletions
diff --git a/src/authentic2_beid/util.py b/src/authentic2_beid/util.py
index 9b16cf9..34694e3 100644
--- a/src/authentic2_beid/util.py
+++ b/src/authentic2_beid/util.py
@@ -14,6 +14,7 @@ def get_x509_url(request):
return 'https://%s:%s' % (request.get_host(),
app_settings.AUTH_PORT)
-def get_user_names(dn):
+def get_user_names(ssl_info):
+ dn = ssl_info.get('subject_dn')
data = dict(explode_dn(dn))
return data['GN'].split(' ', 1)
diff --git a/src/authentic2_beid/views.py b/src/authentic2_beid/views.py
index 63eb571..eb3f348 100644
--- a/src/authentic2_beid/views.py
+++ b/src/authentic2_beid/views.py
@@ -73,7 +73,7 @@ def delete_beid(request, certificate_pk):
def x509(request, registration_token):
ssl_info = SSLInfo(request)
- request.session['subject_dn'] = ssl_info.subject_dn
+ request.session['ssl_info'] = ssl_info.__dict__
return redirect(request, 'beid_registration_activate',
kwargs={'registration_token': registration_token})
@@ -88,8 +88,15 @@ class BeIDRegistrationCompletionView(RegistrationCompletionView):
def get_form_kwargs(self, **kwargs):
kw = super(BeIDRegistrationCompletionView, self).get_form_kwargs(**kwargs)
# get first and last names from certificate and fill the form
- f_name, l_name = get_user_names(self.request.session['subject_dn'])
+ f_name, l_name = get_user_names(self.request.session['ssl_info'])
kw['initial'].update({'first_name': f_name, 'last_name': l_name})
return kw
+ def form_valid(self, form):
+ ret = super(BeIDRegistrationCompletionView, self).form_valid(form)
+ cert = models.ClientCertificate(user=self.object)
+ cert.__dict__.update(self.request.session['ssl_info'])
+ cert.save()
+ return ret
+
registration_completion = valid_token(BeIDRegistrationCompletionView.as_view())