-
Notifications
You must be signed in to change notification settings - Fork 145
Better error message around us choosing what binding to use #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error message around us choosing what binding to use #51
Conversation
|
Thanks for your input @liquidpele. Ad 1.) As you can see djangosaml2 tries to "automatically" choose the binding based on Ad 2.) I think this is best explained in the comments already:
Since we don't have a custom implementation for the signatures yet in djangosaml2 and only rely on the external |
But djangosaml2 doesn't use xmlsec1... pysaml2 does. It seems like djangosaml2 shouldn't have to be dealing with any of the security validation... furthermore, now that I'm looking at it, djangosaml2 doesn't appear to tell pysaml2 to actually DO the response cert validation: https://github.com/knaperek/djangosaml2/blob/master/djangosaml2/views.py#L226 The call to parse_authn_request_response takes an "outstanding_certs" option which appears to be a list of trusted certs that pysaml2 then uses later to run response.verify(cert) on the appropriate ones. Am I missing something here? |
|
In regards to selecting the right binding, I feel like that should probably be done based off the IDP metadata specified... since that defines what's allowed. There's also a a "WantAuthnRequestsSigned" attribute used in the IDP metadata that we could automatically select whether to sign stuff or not if it's not specified... |
That's right, djangosaml2 does not perform any crypto, it uses pysaml2 which in turn uses xmlsec1. Thus, in order to support the Redirect binding with
Look closer, it does. This is just a way to override the default. I admit that the |
Okay, so the real issue is that pysaml2 doesn't support it yet. Okay, I get it now.
Ah okay, whew :p |
If we are to change this, then I'd be more in favour of an explicit solution. Yes, I agree that the |
Yes, and the reason for that comes from |
…based on signing setting
|
I've updated this to use the same logic, but then check if the selected binding is supported according the IDP's metadata and if not then try the other binding type. |
djangosaml2/views.py
Outdated
| # ensure our selected binding is supported by the IDP | ||
| supported_bindings = get_idp_sso_supported_bindings(selected_idp) | ||
| if binding not in supported_bindings: | ||
| logger.debug('Binding %s not in IDP %s supported bindings: %s' % ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a common antipattern - please pass the arguments to the logger directly instead of pre-merging into the message. It's easier to process the logs then...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay will fix. I'm having merge conflicts between my two PRs though, so I'm going to make one combined one in just a sec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually prefer if you kept them separate. It's easier to discuss and review then. If that import line bothers you, just use a separate import line in each...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll redo the other one then and I'll reopen this one.
|
Okay, I fixed the logger lines you commented on and also fixed 2 issues that unit tests found with python3 |
|
Thanks for your work @liquidpele, now it turned out these changes will after all be related to the other PR about parsing HTML with XML parser. Would you mind fixing this branch now? Thanks! |
Conflicts: djangosaml2/views.py
|
@knaperek merged in master and fixed conflicts. |
|
Fair enough, thanks for your work @liquidpele! |
We have customer inputted IDP metadata, and one of them only allows for HTTP-Redirect in their SingleSignOnService definition. We have our saml2 config set with authn_requests_signed as True (which is the default according to pysaml2 - https://github.com/rohe/pysaml2/blob/master/doc/howto/config.rst#authn-requests-signed). The djangosaml2 code uses that param to decide if it should use a HTTP-POST or HTTP-Redirect binding, so since we specified it on, it only tries HTTP-POST, which pysaml2 then raises an exception over since the IDP metadata didn't support it.
This gives a better error message around this, but I question if this is correct at all...
Would appreciate some feedback on this, thanks!