Repository navigation
Open
Milestone
Description
OmniAuth depends on Hashie only for Hashie::Mash. OmniAuth::KeyStore subclasses it, and so do OmniAuth::AuthHash, AuthHash::InfoHash, and Strategy::Options. That dependency has cost us a fair amount over the years:
- Upgrade breakages: Hashie 3.3.0 Breaks Omniauth #765, Installing hashie 3.5.1 yields an OmniAuth warning #873, Performance Issue with version 1.5.0 #886 and Update dependencies to support use of hashie 4.0.0? #976.
- A warnings workaround: Hashie warnings #872 and Silence Hashie::Mash logger on Hashie 3.5.0+ #874.
- Per-request allocations, mostly fixed in Minimize object creation on middleware call. #774.
#773 proposed dropping Hashie in 2014, replacing it with an OpenStruct-based class. @mbleigh pointed out that this needs a major version, because apps and strategies treat these objects as hash-like Mashes. @schneems agreed that a struct copying Mash wasn't the right replacement. This issue is the v3 follow-up.
Proposal
Make OmniAuth::KeyStore a small Hash subclass, with no Hashie, that keeps the access patterns apps and strategies actually use:
- Method access, including chaining:
auth.info.email,auth.credentials.token,options.client_options.site, andoptions.foo = 'bar'. A missing key returnsnil. - Predicate methods:
info.email?,options.skip_info?, anduid?all return!!value. - Indifferent keys: keys are stored as strings, so
auth[:info],auth['info'],fetch(:uid),key?(:uid),dig(:info, :email), and so on are all equivalent. - Nested conversion: hashes assigned anywhere inside, including inside arrays, become
KeyStores, so chaining works all the way down.AuthHash#info=still produces anInfoHash. - What OmniAuth itself needs:
mergeandmerge!/update, plusdeep_mergeanddeep_merge!, which strategies use for options.- Deep
dup, so each strategy instance gets its own options. select,reject,slice, andexceptthat keep the class.to_hash(optionally withsymbolize_keys: true) that converts back to plain nestedHashes.
Everything else Mash offers would go away:
Hashie::Mashin the ancestry, sois_a?(Hashie::Mash)becomes false.- Bang and underscore readers such as
foo!andfoo_. - Mash's default values and blocks.
- Its extensions, its
loadmethod, andKeyStore.override_logging.
Plan
- Build it on a
drop-hashiebranch. - Run the same downstream suites we use before releases against it: omniauth-oauth2, google-oauth2, github, saml, facebook, identity, rails_csrf_protection, and Devise. That shows what actually breaks.
- Decide from those results whether anything needs a deprecation in a 2.x release first, for example a warning when a
Hashie::Mash-only method is called.
Reacted by Sampo Kuokkanen
Metadata
Metadata
Assignees
Labels
No labels
Activity
Replace Hashie::Mash with a Hash-based KeyStore
sferik commentedon Oct 21, 2026
There's a first implementation on the
drop-hashiebranch (2d871f0).KeyStoreis now a plainHashsubclass of about 150 lines, and thehashiedependency is gone. It does everything listed above and drops the rest.sig/omniauth.rbs.Downstream suites
These ran against the branch, with the same counts as against master:
Notes:
AuthHashno longer hasHashie::Mashamong its ancestors.Hashie,Mash,deep_fetch, oroverride_logging. The one KeyStore-specific call they make isto_hash(symbolize_keys: true)(omniauth-oauth2, google-oauth2), and that still works.The limitation is that this only covers what these suites exercise. Less popular strategies, and app code, may still use bang readers,
is_a?(Hashie::Mash), or other Mash methods. Before v3, we could ship a 2.x release that keeps Mash but warns whenever something calls a method KeyStore won't have.