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

Replace MAX_BYTE_SIZE constant with setting #601

Conversation

gitlab-djensen
Copy link
Contributor

@gitlab-djensen gitlab-djensen commented Jul 15, 2021

Status

READY

Migrations

NO

Description

The MAX_BYTE_SIZE constant did not allow for customization, which
is necessary for cases where legitimate SAML responses are larger
than 250,000 bytes. This replaces the constant with a setting, which
has a default value of 250,000 bytes, but can be customized like
any other setting.

This was motivated by #598, which was motivated by https://gitlab.com/gitlab-org/gitlab/-/issues/329053.
This follows the existing pattern used for encode_raw_saml.

Related PRs

List related PRs against other branches:

branch PR
Introduce MAX_BYTE_SIZE link
Introduce inflate option to disable SAML message inflation link

Todos

  • Tests
  • Documentation

Deploy Notes

Nothing noteworthy.

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

git fetch
git checkout gitlab-djensen:gitlab-djensen-use-setting-for-max-byte-size
bundle install;
ruby -Itest test/settings_test.rb

Impacted Areas in Application

List general components of the application that this PR will affect:

  • Settings
  • SamlMessage

@gitlab-djensen
Copy link
Contributor Author

gitlab-djensen commented Jul 15, 2021

@dblessing would you mind doing the initial review on this whenever you have some time?

P.S. I wasn't able to get the tests to run because of dependency problems on my machine. If you could confirm you're seeing green on the tests that would be excellent.

@dblessing
Copy link

@gitlab-djensen Thanks for opening the PR. Looks good to me, with my limited knowledge of the ruby-saml code. Let's see what the maintainers think.

@gitlab-djensen
Copy link
Contributor Author

@pitbulk this PR is ready for your review, whenever you might have some time.

GitLab is hoping you will release a new version of this gem containing this fix, because MAX_BYTE_SIZE was a breaking change for implementations with large messages (example).

@johnnyshields
Copy link
Collaborator

👍 looks good to merge

@gitlab-djensen
Copy link
Contributor Author

@pitbulk friendly ping, hopefully this is an easy review 🙂

@gitlab-djensen
Copy link
Contributor Author

@pitbulk thanks for reviewing! I just marked both of your comments as resolved. Should we run the workflow next? (It's telling me "First-time contributors need a maintainer to approve running workflows.")

@gitlab-djensen
Copy link
Contributor Author

Strangely, the workflow ran anyway. There were a bunch of failures because settings was still optional in some places where it is now required. I just pushed 2 commits that make settings a required argument in multiple places, which makes this PR a breaking change. (We could avoid the breaking change by leaving settings as an optional argument and calling OneLogin::RubySaml::Settings.new when settings is not provided. But that approach is not currently used anywhere in the gem, so it would be a new pattern.) I'll keep working on this until the tests are green.

@pitbulk
Copy link
Collaborator

pitbulk commented Aug 16, 2021

We need to avoid breaking changes. If settings is not provided to the decode_raw_saml method, makes sense to keep using the default value, otherwise, the settings object should be there.

I don't want to force settings parameters on main constructors.

@gitlab-djensen gitlab-djensen force-pushed the gitlab-djensen-use-setting-for-max-byte-size branch 2 times, most recently from 5d3b53e to ce6d391 Compare August 24, 2021 03:31
@gitlab-djensen gitlab-djensen force-pushed the gitlab-djensen-use-setting-for-max-byte-size branch from ce6d391 to e5e8327 Compare August 24, 2021 04:28
The MAX_BYTE_SIZE constant did not allow for customization, which
is necessary for cases where legitimate SAML responses are larger
than 250,000 bytes. This replaces the constant with a setting, which
has a default value of 250,000 bytes, but can be customized like
any other setting.
@gitlab-djensen gitlab-djensen force-pushed the gitlab-djensen-use-setting-for-max-byte-size branch from e5e8327 to b6fa044 Compare August 24, 2021 21:47
@gitlab-djensen
Copy link
Contributor Author

@pitbulk gotcha, refactored to be non-breaking (by calling OneLogin::RubySaml::Settings.new when settings is not passed). Tests are green. How's it looking now?

@johnnyshields
Copy link
Collaborator

@pitbulk this looks good to me.

@gitlab-djensen
Copy link
Contributor Author

@pitbulk friendly ping, prompted by a colleague with an affected client. Does this look good for merge?

@johnnyshields
Copy link
Collaborator

Also, after merge, let's get an gem release please :) Lots of great improvements recently.

@pitbulk
Copy link
Collaborator

pitbulk commented Sep 2, 2021

Sorry I will be back from PTO on 6 and take care of all the pending PRs

@pitbulk pitbulk merged commit c21d693 into SAML-Toolkits:master Sep 6, 2021
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.

4 participants