@@ -362,18 +362,21 @@ def _handle_authn_response(self, context, internal_response, idp):
362
362
logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
363
363
logger .debug (logline )
364
364
365
- policies = self .idp_config .get (
366
- 'service' , {}). get ( 'idp' , {}) .get ('policy' , {})
365
+ idp_conf = self .idp_config .get ('service' , {}). get ( 'idp' , {})
366
+ policies = idp_conf .get ('policy' , {})
367
367
sp_policy = policies .get ('default' , {})
368
368
sp_policy .update (policies .get (sp_entity_id , {}))
369
369
370
370
sign_assertion = sp_policy .get ('sign_assertion' , False )
371
371
sign_response = sp_policy .get ('sign_response' , True )
372
- sign_alg = sp_policy .get ('sign_alg' , 'SIG_RSA_SHA256' )
373
- digest_alg = sp_policy .get ('digest_alg' , 'DIGEST_SHA256' )
374
372
encrypt_assertion = sp_policy .get ('encrypt_assertion' , False )
375
373
encrypted_advice_attributes = sp_policy .get ('encrypted_advice_attributes' , False )
376
374
375
+ signing_algorithm = idp_conf .get ('signing_algorithm' )
376
+ digest_algorithm = idp_conf .get ('digest_algorithm' )
377
+ sign_alg_attr = sp_policy .get ('sign_alg' , 'SIG_RSA_SHA256' )
378
+ digest_alg_attr = sp_policy .get ('digest_alg' , 'DIGEST_SHA256' )
379
+
377
380
# Construct arguments for method create_authn_response
378
381
# on IdP Server instance
379
382
args = {
@@ -389,31 +392,35 @@ def _handle_authn_response(self, context, internal_response, idp):
389
392
'encrypted_advice_attributes' : encrypted_advice_attributes ,
390
393
}
391
394
392
- try :
393
- args ['sign_alg' ] = getattr (xmldsig , sign_alg )
394
- except AttributeError as e :
395
- msg = "Unsupported sign algorithm {}" .format (sign_alg )
396
- logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
397
- logger .error (logline )
398
- raise Exception (msg ) from e
399
- else :
400
- msg = "signing with algorithm {}" .format (args ['sign_alg' ])
401
- logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
402
- logger .debug (logline )
395
+ args ['sign_alg' ] = signing_algorithm
396
+ if not args ['sign_alg' ]:
397
+ try :
398
+ args ['sign_alg' ] = getattr (xmldsig , sign_alg_attr )
399
+ except AttributeError as e :
400
+ msg = "Unsupported sign algorithm {}" .format (sign_alg )
401
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
402
+ logger .error (logline )
403
+ raise Exception (msg ) from e
404
+
405
+ msg = "signing with algorithm {}" .format (args ['sign_alg' ])
406
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
407
+ logger .debug (logline )
403
408
404
- try :
405
- args ['digest_alg' ] = getattr (xmldsig , digest_alg )
406
- except AttributeError as e :
407
- msg = "Unsupported digest algorithm {}" .format (digest_alg )
408
- logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
409
- logger .error (logline )
410
- raise Exception (msg ) from e
411
- else :
412
- msg = "using digest algorithm {}" .format (args ['digest_alg' ])
413
- logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
414
- logger .debug (logline )
409
+ args ['digest_alg' ] = digest_algorithm
410
+ if not args ['digest_alg' ]:
411
+ try :
412
+ args ['digest_alg' ] = getattr (xmldsig , digest_alg_attr )
413
+ except AttributeError as e :
414
+ msg = "Unsupported digest algorithm {}" .format (digest_alg )
415
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
416
+ logger .error (logline )
417
+ raise Exception (msg ) from e
418
+
419
+ msg = "using digest algorithm {}" .format (args ['digest_alg' ])
420
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
421
+ logger .debug (logline )
415
422
416
- if 'sign_alg' in args or 'digest_alg' in args :
423
+ if sign_alg_attr or digest_alg_attr :
417
424
msg = (
418
425
"sign_alg and digest_alg are deprecated; "
419
426
"instead, use signing_algorithm and digest_algorithm "
0 commit comments