0001-manager-include-oidc-and-saml-federation-info-in-use.patch
src/authentic2_auth_oidc/apps.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import django.apps |
18 |
from django import template |
|
18 | 19 | |
19 | 20 | |
20 | 21 |
class Plugin(object): |
... | ... | |
97 | 98 |
'issuer': oidc_account.provider.issuer, |
98 | 99 |
'sub': oidc_account.sub, |
99 | 100 |
}) |
101 | ||
102 |
def a2_hook_manager_user_data(self, view, user): |
|
103 |
context = {'user': user} |
|
104 |
return [template.loader.get_template('authentic2_auth_oidc/manager_user_sidebar.html').render(context)] |
src/authentic2_auth_oidc/templates/authentic2_auth_oidc/manager_user_sidebar.html | ||
---|---|---|
1 |
{% load i18n %} |
|
2 |
<div class="auth-oidc-user-sidebar"> |
|
3 |
{% if user.oidc_account %} |
|
4 |
<p> |
|
5 |
{% blocktrans trimmed with created=user.oidc_account.created name=user.oidc_account.provider.name %} |
|
6 |
Link with OIDC provider "{{ name }}" created on {{ created }} |
|
7 |
{% endblocktrans %} |
|
8 |
</p> |
|
9 |
{% endif %} |
|
10 |
</div> |
src/authentic2_auth_saml/apps.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import django.apps |
18 |
from django import template |
|
18 | 19 | |
19 | 20 | |
20 | 21 |
class AppConfig(django.apps.AppConfig): |
... | ... | |
40 | 41 |
'issuer': saml_account.issuer, |
41 | 42 |
'name_id': saml_account.name_id, |
42 | 43 |
}) |
44 | ||
45 |
def a2_hook_manager_user_data(self, view, user): |
|
46 |
context = {'user': user} |
|
47 |
return [template.loader.get_template('authentic2_auth_saml/manager_user_sidebar.html').render(context)] |
src/authentic2_auth_saml/templates/authentic2_auth_saml/manager_user_sidebar.html | ||
---|---|---|
1 |
{% load i18n %} |
|
2 |
{% for identifier in user.saml_identifiers.all %} |
|
3 |
<div class="auth-saml-user-sidebar"> |
|
4 |
<p title="{{ identifier.issuer }}">{% trans "Link with SAML identity provider created on" %} {{ identifier.created }}</p> |
|
5 |
</div> |
|
6 |
{% endfor %} |
tests/test_auth_oidc.py | ||
---|---|---|
913 | 913 |
assert '_auth_user_id' not in app.session |
914 | 914 |
assert OIDCAccount.objects.count() == 0 |
915 | 915 |
assert 'too many users' in caplog.records[-1].message |
916 | ||
917 | ||
918 |
def test_manager_user_sidebar(app, superuser, simple_user, oidc_provider): |
|
919 |
utils.login(app, superuser, '/manage/') |
|
920 |
response = app.get('/manage/users/%s/' % simple_user.id) |
|
921 |
assert 'OIDC' not in response |
|
922 | ||
923 |
OIDCAccount.objects.create(user=simple_user, provider=oidc_provider, sub='1234') |
|
924 | ||
925 |
response = app.get('/manage/users/%s/' % simple_user.id) |
|
926 |
assert 'OIDC provider "Server"' in response |
tests/test_auth_saml.py | ||
---|---|---|
31 | 31 |
from authentic2.custom_user.models import DeletedUser |
32 | 32 |
from authentic2_auth_saml.adapters import AuthenticAdapter, MappingError |
33 | 33 | |
34 |
from .utils import login |
|
35 | ||
34 | 36 |
User = get_user_model() |
35 | 37 | |
36 | 38 | |
... | ... | |
289 | 291 |
'name_id': '4567', |
290 | 292 |
} |
291 | 293 |
] |
294 | ||
295 | ||
296 |
def test_manager_user_sidebar(app, superuser, simple_user): |
|
297 |
login(app, superuser, '/manage/') |
|
298 |
response = app.get('/manage/users/%s/' % simple_user.id) |
|
299 |
assert 'SAML' not in response |
|
300 | ||
301 |
UserSAMLIdentifier.objects.create(user=simple_user, issuer='https://idp1.com/', name_id='1234') |
|
302 | ||
303 |
response = app.get('/manage/users/%s/' % simple_user.id) |
|
304 |
assert 'SAML' in response |
|
292 |
- |