Skip to content
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

Improve authentication and logout request input params API #350

Merged
merged 5 commits into from Jul 26, 2021

Conversation

mauromol
Copy link
Contributor

@mauromol mauromol commented Jul 24, 2021

This PR is made of:

Benefits of this refactoring:

  • it polishes the AuthnRequest, LogoutRequest and Auth APIs: all those overridings were honestly cluttering the API and they were not easily extensible
  • it improves library evolution: any future evolution of this library which requires to add further input parameters to the AuthnRequest and LogoutRequest generation process, may simply extend AuthnRequestParams and LogoutRequestParams without the need to further touch the API of AuthnRequest, LogoutRequest and Auth classes (or to provide even more overridings); this allows, for instance, to implement NameIDPolicy AllowCreate hardcoded to true in AuthnRequest #329 by simply adding a new property to AuthnRequestParams (and of course adjust the generation process) without the need to provide new overloadings
  • it improves extensibility: in combination with the postProcessXml mechanism introduced in Allow for extension classes to post-process generated XML #321 (*), any consumer application which needs to extend this library, may pass to AuthnRequest and LogoutRequest constructors a proper input params extension, which will also be passed to postProcessXml, so that an overriding of the latter will allow for proper XML manipulation and/or extension based on the actual custom input params
  • further Auth extensibility improvement, which leverages this rafactoring, can be provided: I already anticipated he idea in Adding attributes to the "saml:Issuer" part in the AuthnRequest #265 (comment) and I may provide a separate PR for that if this is accepted and merge
  • it clarifies the nature of the different constructors of LogoutRequest: the new introduced constructors now are specialized on a single scenario (new outgoing logout request creation vs parsing of an incoming request in an IdP-initiated logout)

The change is 100% backward compatible: all those Auth.login, Auth.logout, AuthnRequest and LogoutRequest constructor overloadings have been deprecated (to ease migration), not removed. You may then consider their removal in the future sooner or later, depending on requirements.

(*) Please note that this PR also brings a change in postProcessXml API for AuthnRequest and LogoutRequest, letting it receive the input parameters as well. I think this is fine since the postProcessXml has not been released yet, so we should still be on time for this.

Input parameters, which drive how the AuthnRequest should be generated,
are now encapsulated into an AuthnRequestParams object which is far more
extensible and help to polish the API of AuthnRequest constructors and
Auth.login, which are crowded with overloadings and cannot be easily
extended.
Also, these input params are passed to postProcessXml: in this way, if
an extension plans to use a specialization of AuthnRequestParams, it can
access such a specialized instance also within a proper postProcessXml
overriding.
This refactor is pretty much the same done with AuthnRequest and
AuthnRequestParams: in this case, the params class encapsulates all the
logout request input parameters used whenever a new logout request is
created for subsequent sending. This as well allows to reduce the number
of LogoutRequest constructor and Auth.logout() overloadings, allows
an extension to use a customized input param object which is also passed
to postProcessXml and eases Auth extensibility.
@pitbulk pitbulk merged commit 820f581 into SAML-Toolkits:master Jul 26, 2021
@mauromol mauromol deleted the improve-input-params-api branch July 27, 2021 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants