+default_app_config = 'qcg.apps.QCGPortalConfig'
--- /dev/null
+from django.apps import AppConfig
+
+
+class QCGPortalConfig(AppConfig):
+ name = 'qcg'
+ verbose_name = "Portal QCG"
+
+ def ready(self):
+ import signals
--- /dev/null
+from django.dispatch import receiver
+from django_openid_auth.signals import openid_login_complete
+from openid.extensions import ax
+
+
+@receiver(openid_login_complete)
+def post_openid_login(sender, request, openid_response, **kwargs):
+ fetch_response = ax.FetchResponse.fromSuccessResponse(openid_response)
+ if fetch_response:
+ proxy = fetch_response.getSingle('http://openid.plgrid.pl/certificate/proxy')
+ user_cert = fetch_response.getSingle('http://openid.plgrid.pl/certificate/userCert')
+ proxy_priv_key = fetch_response.getSingle('http://openid.plgrid.pl/certificate/proxyPrivKey')
+
+ request.session['proxy'] = (proxy + proxy_priv_key + user_cert).replace('<br>', '\n')
{% load staticfiles webdesign %}
+{% load firstof from future %}
<!DOCTYPE html>
<html lang="pl">
from qcg import views
urlpatterns = patterns('',
- url(r'^openid/login/', views.openid_login, name='openid-login'),
+ url(r'^openid/login/', views.openid_begin, name='openid-login'),
+ url(r'^openid/complete/', 'django_openid_auth.views.login_complete', name='openid-complete'),
url(r'^openid/logout/', 'django.contrib.auth.views.logout', {'template_name': 'qcg/logout.html'}, name='logout'),
- url(r'^openid/', include('django_openid_auth.urls')),
url(r'^$', views.index, name='index'),
url(r'^jobs/$', views.jobs_list, name='jobs'),
return render(request, 'qcg/base.html')
-def openid_login(request):
+def openid_begin(request):
openid_request = make_consumer(request).begin(settings.OPENID_SSO_SERVER_URL)
fetch_request = ax.FetchRequest()
for (attr, alias) in [('http://axschema.org/namePerson/friendly', 'nickname'),
('http://axschema.org/contact/email', 'email'),
('http://axschema.org/namePerson', 'fullname'),
- # ('http://openid.plgrid.pl/certificate/proxy', 'proxy'),
- # ('http://openid.plgrid.pl/certificate/userCert', 'userCert'),
- # ('http://openid.plgrid.pl/certificate/proxyPrivKey', 'proxyPrivKey'),
+ ('http://openid.plgrid.pl/certificate/proxy', 'proxy'),
+ ('http://openid.plgrid.pl/certificate/userCert', 'userCert'),
+ ('http://openid.plgrid.pl/certificate/proxyPrivKey', 'proxyPrivKey'),
('http://openid.plgrid.pl/POSTresponse', 'POSTresponse')]:
fetch_request.add(ax.AttrInfo(attr, alias=alias, required=True))
openid_request.addExtension(fetch_request)