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

Refactor: More extensible NameID validation. #37

Closed
wants to merge 3 commits into from
Closed

Refactor: More extensible NameID validation. #37

wants to merge 3 commits into from

Conversation

LiamKearn
Copy link
Contributor

In summary:

  1. NameID is now always validated to fit within Member's GUID field.
  2. Further validation is disabled by default behind SAMLConfiguration's validate_nameid.
  3. If validate_nameid is enabled validation will now be done via extensions.
  4. A GUID Validation extension is registered by default and only requires validate_nameid to be set to true to use.
  5. Docs are updated.
  6. Tests are updated to reflect new config flag and test the length validation.

I'm still of the opinion that GUID (or any) validation by default is a little out of place, When I tested the following with Azure AD it used user.userprinciplename with Email format by default. It might be a nice middle-ground to at least have something a little more generic and extensible. ADFS is too dinosaur and mirosofty for me to even think about 😁. More than happy to enable the validation by default if wanted.

Is there a way I can grab a DBField's size (arguments) without creating a singleton? Grabbing it from config or via DOschema sounds neater but I couldn't find the right API.

* 1. Is the nameID in a GUID pattern?
*
* You can add different methods of validation via SAMLHelper's `updateNameIDValidation` extension point.
* An example can be found in {@see EmailNameIDValidationExtension}.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exist here.
Will fix later, moved this from project code to this module then decided to chuck it in documentation here and not as an actual class.


// OK IF: One of the registered extensions returns true.
$validationResults = $this->extend('updateNameIDValidation', $nameID, $nameIDFormat);
if ($validationResults && is_array($validationResults)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is within convention. Usually it takes just one extension to object for the result to fail, not for just one to pass.

This way we are most cautious and we encourage implementors to be cautious too. There's false for hard fail, null for no opinion and true for pass. We should aim to have no false and at least one true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I rarely call extend since in non-module code extend is a little overkill for design.

I think I just snatched a code-snippet from SS somewhere when I wrote this for project code.

My opinion is still that there should be no GUID validation at all (maybe apart from the varchar length). If I ever need to revisit our SAML implementation in project I'll try and finish this PR to upstream our changes. For now I think I'm going to close this due to time. Sorry!

@LiamKearn LiamKearn closed this Jul 17, 2022
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