idp_openid: manage openid services with backend, do not use federation processor anymore.
This commit is contained in:
parent
0e38d2a144
commit
99b7a35b8d
|
@ -1,5 +1,4 @@
|
|||
from idp.views import accumulate_from_backends
|
||||
from django.conf import settings
|
||||
|
||||
class UserFederations(object):
|
||||
'''Provide access to all federations of the current user'''
|
||||
|
@ -24,10 +23,4 @@ class UserFederations(object):
|
|||
return super(UserFederations, self).__getattr__(name)
|
||||
|
||||
def federations_processor(request):
|
||||
context = {'federations': UserFederations(request)}
|
||||
if settings.IDP_OPENID:
|
||||
from authentic2.idp.idp_openid import models
|
||||
openid_links = [link for link in accumulate_from_backends(request,
|
||||
'links') if isinstance(link, models.TrustedRoot)]
|
||||
context['openid_links'] = openid_links
|
||||
return context
|
||||
return {'federations': UserFederations(request) }
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from authentic2.idp.utils import Service
|
||||
|
||||
import models
|
||||
|
||||
logger = logging.getLogger('authentic2.idp.idp_openid.backend')
|
||||
|
||||
|
||||
class OpenIDBackend(object):
|
||||
def links(self, request):
|
||||
def service_list(self, request):
|
||||
if not request.user.is_authenticated():
|
||||
return ()
|
||||
return models.TrustedRoot.objects.filter(user=request.user.id)
|
||||
q = models.TrustedRoot.objects.filter(user=request.user.id)
|
||||
ls = []
|
||||
for service_provider in q:
|
||||
actions = []
|
||||
actions.append(('go', 'GET', service_provider.trust_root, None))
|
||||
actions.append(('unlink', 'GET', reverse('trustedroot_delete',
|
||||
kwargs={'pk': service_provider.id}), None))
|
||||
ls.append(Service(url=None, name=service_provider.trust_root,
|
||||
actions=actions))
|
||||
return ls
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
<p>{% trans "Are you sure you want to delete link with" %} {{ trustedroot }} ?</p>
|
||||
<input type="submit" value="Yes" />
|
||||
</form>
|
||||
<a href="{% url 'account_management' %}">{% trans "Back" %}</a>
|
||||
<p><a href="/">{% trans "Back" %}<a/></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -295,5 +295,5 @@ def openid_discovery(request, id):
|
|||
|
||||
class TrustedRootDelete(DeleteView):
|
||||
model = models.TrustedRoot
|
||||
success_url = reverse_lazy('account_management')
|
||||
success_url = '/'
|
||||
template_name = 'idp/openid/trustedroot_confirm_delete.html'
|
||||
|
|
|
@ -7,16 +7,10 @@ import authentic2.saml.models as models
|
|||
import authentic2.idp.saml.saml2_endpoints as saml2_endpoints
|
||||
import authentic2.saml.common as common
|
||||
|
||||
from authentic2.idp.utils import Service
|
||||
|
||||
logger = logging.getLogger('authentic2.idp.saml.backend')
|
||||
|
||||
class Service(object):
|
||||
url = None
|
||||
name = None
|
||||
actions = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
class SamlBackend(object):
|
||||
def service_list(self, request):
|
||||
q = models.LibertyServiceProvider.objects.filter(enabled = True)
|
||||
|
|
|
@ -32,11 +32,5 @@
|
|||
{% for html_block in frontends_block %}
|
||||
{{ html_block|safe }}
|
||||
{% endfor %}
|
||||
{% if openid_links %}
|
||||
<h3>{% trans "Links with OpenID Relying Parties" %}</h3>
|
||||
{% for link in openid_links %}
|
||||
<p>{{ link }} <a href="{% url 'trustedroot_delete' link.id %}">Unlink</a></p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<p><a href="/">{% trans "Back" %}<a/></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -21,13 +21,15 @@
|
|||
<ul>
|
||||
{% for service in authorized_services %}
|
||||
{% if service.actions %}
|
||||
<li>{% if service.url %}<a href="{{ service.url }}">{% endif %}{{ service.name }}{% if service.url %}</a>{% endif %}
|
||||
<li>{% if service.url %}<a href="{{ service.url }}">{% endif %}{{ service.name }}{% if service.url %}</a>{% endif %}
|
||||
<div class="actions">
|
||||
{% for action in service.actions %}
|
||||
<form action="{{ action.2 }}" method="{{ action.1 }}">
|
||||
{% if action.3 %}
|
||||
{% for key, value in action.3 %}
|
||||
<input type="hidden" name="{{ key }}" value="{{ value }}" />
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<input type="hidden" name="next" value="/"/>
|
||||
<input type="submit" class="submit-link" value="{{ action.0 }}">
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class Service(object):
|
||||
url = None
|
||||
name = None
|
||||
actions = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
Loading…
Reference in New Issue