|
43 | 43 | UnsolicitedResponse) |
44 | 44 | from saml2.s_utils import UnsupportedBinding |
45 | 45 | from saml2.saml import SCM_BEARER |
46 | | -from saml2.samlp import AuthnRequest |
| 46 | +from saml2.samlp import AuthnRequest, IDPEntry, IDPList, Scoping |
47 | 47 | from saml2.sigver import MissingKey |
48 | 48 | from saml2.validate import ResponseLifetimeExceed, ToEarly |
49 | 49 |
|
@@ -192,6 +192,16 @@ def get(self, request, *args, **kwargs): |
192 | 192 | if selected_idp is None: |
193 | 193 | selected_idp = list(configured_idps.keys())[0] |
194 | 194 |
|
| 195 | + # perform IdP Scoping if scoping param is present |
| 196 | + idp_scoping_param = request.GET.get('scoping', None) |
| 197 | + if idp_scoping_param: |
| 198 | + idp_scoping = Scoping() |
| 199 | + idp_scoping.idp_list = IDPList() |
| 200 | + idp_scoping.idp_list.idp_entry.append( |
| 201 | + IDPEntry(provider_id = idp_scoping_param) |
| 202 | + ) |
| 203 | + sso_kwargs['scoping'] = idp_scoping |
| 204 | + |
195 | 205 | # choose a binding to try first |
196 | 206 | binding = getattr(settings, 'SAML_DEFAULT_BINDING', |
197 | 207 | saml2.BINDING_HTTP_POST) |
@@ -231,12 +241,11 @@ def get(self, request, *args, **kwargs): |
231 | 241 | sign_requests = getattr(conf, '_sp_authn_requests_signed', False) |
232 | 242 |
|
233 | 243 | if sign_requests: |
234 | | - sso_kwargs["sigalg"] = settings.SAML_CONFIG['service']['sp']\ |
235 | | - .get('signing_algorithm', |
236 | | - saml2.xmldsig.SIG_RSA_SHA256) |
237 | | - sso_kwargs["digest_alg"] = settings.SAML_CONFIG['service']['sp']\ |
238 | | - .get('digest_algorithm', |
239 | | - saml2.xmldsig.DIGEST_SHA256) |
| 244 | + csc = settings.SAML_CONFIG['service']['sp'] |
| 245 | + sso_kwargs["sigalg"] = csc.get('signing_algorithm', |
| 246 | + saml2.xmldsig.SIG_RSA_SHA256) |
| 247 | + sso_kwargs["digest_alg"] = csc.get('digest_algorithm', |
| 248 | + saml2.xmldsig.DIGEST_SHA256) |
240 | 249 |
|
241 | 250 | # pysaml needs a string otherwise: "cannot serialize True (type bool)" |
242 | 251 | if getattr(conf, '_sp_force_authn', False): |
@@ -609,10 +618,14 @@ class LogoutView(SPConfigMixin, View): |
609 | 618 | logout_error_template = 'djangosaml2/logout_error.html' |
610 | 619 |
|
611 | 620 | def get(self, request, *args, **kwargs): |
612 | | - return self.do_logout_service(request, request.GET, saml2.BINDING_HTTP_REDIRECT, *args, **kwargs) |
| 621 | + return self.do_logout_service( |
| 622 | + request, request.GET, saml2.BINDING_HTTP_REDIRECT, *args, **kwargs |
| 623 | + ) |
613 | 624 |
|
614 | 625 | def post(self, request, *args, **kwargs): |
615 | | - return self.do_logout_service(request, request.POST, saml2.BINDING_HTTP_POST, *args, **kwargs) |
| 626 | + return self.do_logout_service( |
| 627 | + request, request.POST, saml2.BINDING_HTTP_POST, *args, **kwargs |
| 628 | + ) |
616 | 629 |
|
617 | 630 | def do_logout_service(self, request, data, binding): |
618 | 631 | logger.debug('Logout service started') |
|
0 commit comments