Skip to content

make MAX_REMEMBERED_SIGN_INS & MAX_REMEMBERED_PARAMS_BYTESIZE configurable - #1185

Merged
sferik merged 17 commits into
omniauth:masterfrom
nov:configurable_MAX_REMEMBERED_PARAMS_BYTESIZE
Nov 18, 2026
Merged

sferik merged 17 commits into
omniauth:masterfrom
nov:configurable_MAX_REMEMBERED_PARAMS_BYTESIZE

Conversation

@nov

@nov nov commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

fixes #1184

introduce 2 configurable variables, and keep the default as is.

# instead of OmniAuth::Strategy::SignIns::MAX_REMEMBERED_SIGN_INS
OmniAuth.config.max_remembered_sign_ins # default 3

# instead of OmniAuth::Strategy::SignIns::MAX_REMEMBERED_PARAMS_BYTESIZE
OmniAuth.config.max_remembered_params_bytesize # default 512

so that, applications utilize 512+ byte params can modify the numbers balancing with their session storage.

@nov
nov force-pushed the configurable_MAX_REMEMBERED_PARAMS_BYTESIZE branch from ba40f70 to 8265baa Compare November 18, 2026 07:04
@nov
nov marked this pull request as ready for review November 18, 2026 07:04

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, Nov. I think making these configurable makes sense. 512 bytes was a guess about what fits comfortably in a cookie session, and apps that use a different session store shouldn't be stuck with it.

I'd like a few changes before merging. The biggest one is keeping the constants. They shipped in 2.4.0 and they're in the RBS signatures, so removing them would break anyone who references them in a minor release. I'd rather keep them and use them as the defaults. I'd also like the setters to reject bad values up front, plus a spec for each setting that actually changes it. A short README note would help too, warning people that raising both limits can overflow a 4 KB cookie session. Details are inline.

Comment thread lib/omniauth.rb Resolved
Comment thread lib/omniauth.rb Resolved
Comment thread lib/omniauth.rb Resolved
Comment thread lib/omniauth/strategy/sign_ins.rb Resolved
Comment thread sig/omniauth.rbs Resolved
Comment thread spec/omniauth/strategy/sign_ins_spec.rb Resolved

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Marking this as changes requested so it's clear where things stand. The details are in my review above.

@nov
nov requested a review from sferik November 18, 2026 12:41
Comment thread .rubocop.yml Resolved

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the quick turnaround, Nov. Keeping the constants as the defaults looks good, and so does moving the checks into the setters. There are still a few things I'd like before merging, though.

The mutant job is failing on this commit: https://github.com/omniauth/omniauth/actions/runs/44306980646/job/134816145125?pr=1185. Nine mutants survive in the two new setters. For example, changing value < 1 to value < 2 in max_remembered_sign_ins= doesn't fail any spec, and neither does dropping the message from the bytesize raise. Specs that set the lowest allowed values (1 and 0) and check the error messages should kill them.

The spec I asked for last time is still missing. The new ones in configuration_spec.rb check that the setters store the value, but nothing in sign_ins_spec.rb changes a setting and checks that OmniAuth then remembers a different number of sign-ins or larger params. Without that, no spec would fail if sign_ins.rb went back to reading the constants.

The setters don't check for an Integer yet either. nil raises NoMethodError instead of ArgumentError, and 2.5 and Float::INFINITY are both accepted. Infinity then fails in the middle of a sign-in with a RangeError from Array#last, which is exactly the late failure the check is meant to prevent.

The README note is still missing too. The "Several Sign-Ins at Once" section still talks about the latest 3 sign-ins and 512 bytes without mentioning the settings, and it should warn that raising both can overflow a 4 KB cookie session. A CHANGELOG entry under Unreleased would be nice as well.

The rest are smaller things, inline.

Comment thread lib/omniauth.rb Resolved
Comment thread lib/omniauth.rb Resolved
Comment thread spec/omniauth/configuration_spec.rb Resolved
Comment thread spec/omniauth/configuration_spec.rb Resolved
Comment thread spec/omniauth/configuration_spec.rb Resolved
Comment thread spec/omniauth/strategy/sign_ins_spec.rb Resolved
Comment thread spec/omniauth/strategy/sign_ins_spec.rb Resolved
Comment thread lib/omniauth/strategy/sign_ins.rb Resolved
Comment thread duel/callback_duel.rb Resolved
Comment thread .rubocop.yml Resolved
@nov
nov requested a review from sferik November 18, 2026 13:23

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, Nov, this is nearly there. The Integer check, the specs that change each setting, and moving the specs and duels back to the constants all look good.

The mutant job is still failing, though: https://github.com/omniauth/omniauth/actions/runs/44317377467/job/134856533598. 10 mutants survive, and the ones in the log both remove the Integer check from the setters (unless value >= 0 and unless value && value >= 1). That's because no spec passes anything that isn't an Integer. I've suggested specs inline.

I've also suggested some rewording for the README and CHANGELOG. Once those are in and mutant passes, I'm happy to merge.

Comment thread spec/omniauth/configuration_spec.rb Resolved
Comment thread spec/omniauth/configuration_spec.rb Resolved
Comment thread README.md Resolved
Comment thread CHANGELOG.md Resolved
@nov
nov requested a review from sferik November 18, 2026 14:26

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for applying those, Nov. One last thing: mutant still leaves two mutants that turn is_a?(Integer) into instance_of?(Integer). No spec can kill them, because nothing can create an instance of an Integer subclass. Using instance_of? here, like sign_ins.rb does for String, gets mutant to zero survivors. With that change I'm happy to merge.

Comment thread lib/omniauth.rb Resolved
Comment thread lib/omniauth.rb Resolved
nov and others added 2 commits November 18, 2026 23:47
Co-authored-by: Erik Berlin <[email protected]>
Co-authored-by: Erik Berlin <[email protected]>
@nov
nov requested a review from sferik November 18, 2026 14:51

@sferik sferik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, Nov! This all looks good to me now. I hope you had a positive experience collaborating on this patch. 😄

@sferik
sferik merged commit 02e5b25 into omniauth:master Nov 18, 2026
59 checks passed
@nov

nov commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

thanks!

@sferik

sferik commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Shipped in v2.4.2.

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.

prefer configurable MAX_REMEMBERED_PARAMS_BYTESIZE

2 participants