-
Notifications
You must be signed in to change notification settings - Fork 145
Add assertion param to backed.authenticate and backend.is_authorized #260
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
Conversation
|
Thank you @lucyeun-alation I need some more clarifications about:
regarding the point 2. That's only for a better understanding, I just need to understand in the deep what's your design in this new feature |
|
Hi @peppelinux , thanks for the quick review! We are planning on storing the assertion ids in redis. The We also need the assertion's |
|
Probably a hash of the assertion dict would be good enough, what do you think about that? And more, the redis TTL I Imagine that Will have the delta equal to (notonafter - now) in seconds. Does It make sense? Anyway, probably It would be Better to generilize the storage, something not too linked to a specific technology. We Need a clear and documented approach to handle this new feature, do you agree? |
|
Yes, you store assertion.id that's quite opaque and also the timedelta, sounds good |
|
Just to make sure I understand, is your suggestion making the assertion param a dictionary, like
Redis uses ttl, but other storages may use expiry time, so I think the hook can just provide the |
|
Dict can be serialized if its elements are simple types. So that would be the best choice. Documentation... Well, we still have a poor readme, we should move to a RTD, but for your proposal a section in the readme would be good enough for now. Regarding storage, yes, Better a general purpose approach, id+expiration datetime. If not redis, something that prune expired values. Not at least, this feature should be optionally activated/disactivated. Do you agree or did It sounds too polite? |
|
Hi @peppelinux sorry for the delay in the response. I just pushed some changes.
I agree that it should be optional. The interface definitely allows the optional configuration, I'm not sure how to make it more obvious in the documentation. Please let me know what you think! |
| assertion = response.assertion | ||
| assertion_info = {} | ||
| for sc in assertion.subject.subject_confirmation: | ||
| if sc.method == SCM_BEARER: | ||
| assertion_not_on_or_after = sc.subject_confirmation_data.not_on_or_after | ||
| assertion_info = {'assertion_id': assertion.id, 'not_on_or_after': assertion_not_on_or_after} | ||
| break | ||
|
|
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.
SAML doc says
The service provider MUST ensure that bearer assertions are not replayed, by maintaining the set of used ID values for the length of time for which the assertion would be considered valid based on the NotOnOrAfter attribute in the <SubjectConfirmationData>.
The bearer <SubjectConfirmation> element described above MUST contain a <SubjectConfirmationData> element that contains a Recipient attribute containing the service provider's assertion consumer service URL and a NotOnOrAfter attribute that limits the window during which the assertion can be delivered.
|
Hi @lucyeun-alation |
|
I think I rebased the latest and moved the readme section to |
|
Thanks @peppelinux for the quick and thorough reviews and @basavakanaparthi-alation for the guidance! |
|
you give me the impression that you are two good guys! |
PR for #250
In SAML standard doc, section 4.1.4.5 it states
The service provider MUST ensure that bearer assertions are not replayed, by maintaining the set of used ID values for the length of time for which the assertion would be considered valid based on the NotOnOrAfter attribute in the <SubjectConfirmationData>..This is not taken care of by djangosaml2 because djangosaml2 doesn't want to worry about the storage to store the seen assertion ids, but it should provide hooks for the consumer to add the assertion id check. The existing backend.is_authorized can be used, but it does not provide the assertion information, hence adding the assertion as an additional parameter to the
is_authorizedhook