add audience field, switch base processor, better handle processor loading failure

This commit is contained in:
Jens Langhammer 2019-04-18 11:30:21 +02:00
parent 98cd646044
commit 9f8fb7378a
5 changed files with 44 additions and 7 deletions

View file

@ -116,11 +116,7 @@ class Processor:
def _determine_audience(self):
"""Determines the _audience."""
self._audience = self._request_params.get('DESTINATION', None)
if not self._audience:
self._audience = self._request_params.get('PROVIDER_NAME', None)
self._audience = self._remote.audience
self._logger.info('determined audience')
def _determine_response_id(self):

View file

@ -25,7 +25,7 @@ class SAMLProviderForm(forms.ModelForm):
class Meta:
model = SAMLProvider
fields = ['name', 'property_mappings', 'acs_url', 'processor_path', 'issuer',
fields = ['name', 'property_mappings', 'acs_url', 'audience', 'processor_path', 'issuer',
'assertion_valid_for', 'signing', 'signing_cert', 'signing_key', ]
labels = {
'acs_url': 'ACS URL',
@ -33,6 +33,7 @@ class SAMLProviderForm(forms.ModelForm):
}
widgets = {
'name': forms.TextInput(),
'audience': forms.TextInput(),
'issuer': forms.TextInput(),
'property_mappings': FilteredSelectMultiple(_('Property Mappings'), False)
}

View file

@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-04-18 09:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_saml_idp', '0002_samlpropertymapping'),
]
operations = [
migrations.AddField(
model_name='samlprovider',
name='audience',
field=models.TextField(blank=True, default=''),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-04-18 09:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_saml_idp', '0003_samlprovider_audience'),
]
operations = [
migrations.AlterField(
model_name='samlprovider',
name='audience',
field=models.TextField(default=''),
),
]

View file

@ -15,6 +15,7 @@ class SAMLProvider(Provider):
name = models.TextField()
acs_url = models.URLField()
audience = models.TextField(default='')
processor_path = models.CharField(max_length=255, choices=[])
issuer = models.TextField()
assertion_valid_for = models.IntegerField(default=86400)
@ -33,7 +34,10 @@ class SAMLProvider(Provider):
def processor(self):
"""Return selected processor as instance"""
if not self._processor:
try:
self._processor = path_to_class(self.processor_path)(self)
except ModuleNotFoundError:
self._processor = None
return self._processor
def __str__(self):