omniauth-identity

A simple login and password strategy for OmniAuth.

https://github.com/omniauth/omniauth-identity

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 29 committers (3.4%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.0%) to scientific vocabulary

Keywords

authentication authentication-middleware authentication-strategy omniauth omniauth-strategy

Keywords from Contributors

mesh

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation ·

Repository

A simple login and password strategy for OmniAuth.

Basic Info
  • Host: GitHub
  • Owner: omniauth
  • License: mit
  • Language: Ruby
  • Default Branch: main
  • Homepage:
  • Size: 2.13 MB
Statistics
  • Stars: 358
  • Watchers: 20
  • Forks: 100
  • Open Issues: 3
  • Releases: 11
Topics
authentication authentication-middleware authentication-strategy omniauth omniauth-strategy
Created over 14 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing Funding License Code of conduct Citation Security

README.md

Galtzo.com Logo by Aboling0, CC BY-SA 4.0 OmniAuth Logo possibly by Ted O'Meara, license unknown Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5

🫵 OmniAuth::Identity

Version License: MIT Downloads Rank Open Source Helpers Depfu Coveralls Test Coverage CodeCov Test Coverage QLTY Test Coverage QLTY Maintainability CI Heads CI Runtime Dependencies @ HEAD CI Current CI JRuby Deps Locked Deps Unlocked CI Supported CI Legacy CI Unsupported CI Ancient CI Test Coverage CI Style


Liberapay Goal Progress Sponsor Me on Github Buy me a coffee Donate on Polar Donate to my FLOSS or refugee efforts at ko-fi.com Donate to my FLOSS or refugee efforts using Patreon

The omniauth-identity gem provides a way for applications to utilize a traditional username/password based authentication system without the need to give up the simple authentication flow provided by OmniAuth. Identity is designed on purpose to be as featureless as possible: it provides the basic construct for user management and then gets out of the way.

💡 Info you can shake a stick at

| Tokens to Remember | Gem name Gem namespace | |-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Works with JRuby | JRuby 9.2 Compat JRuby 9.3 Compat JRuby 9.4 Compat JRuby 10.0 Compat JRuby HEAD Compat | | Works with MRI Ruby 3 | Ruby 3.0 Compat Ruby 3.1 Compat Ruby 3.2 Compat Ruby 3.3 Compat Ruby 3.4 Compat Ruby HEAD Compat | | Works with MRI Ruby 2 | Ruby 2.4 Compat Ruby 2.5 Compat Ruby 2.6 Compat Ruby 2.7 Compat | | Source | Source on Github.com The best SHA: dQw4w9WgXcQ! | | Documentation | Current release on RubyDoc.info YARD on Galtzo.com BDFL Blog Wiki | | Compliance | License: MIT 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 | | Style | Enforced Code Style Linter Keep-A-Changelog 1.0.0 Gitmoji Commits | | Support | Live Chat on Discord Get help from me on Upwork Get help from me on Codementor | | Enterprise Support | Get help from me on Tidelift
💡Subscribe for support guarantees covering all FLOSS dependencies!
💡Tidelift is part of Sonar!
💡Tidelift pays maintainers to maintain the software you depend on!
📊@Pointy Haired Boss: An enterprise support subscription is "never gonna let you down", and supports open source maintainers! | | Comrade BDFL 🎖️ | Follow Me on LinkedIn Follow Me on Ruby.Social Follow Me on Bluesky Contact BDFL My technical writing | | ... 💖 | Find Me on WellFound: Find Me on CrunchBase My LinkTree More About Me 🧊 🐙 🛖 🧪 |

✨ Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add omniauth-identity

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install omniauth-identity

🔒 Secure Installation

omniauth-identity is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums by stone_checksums. Be sure the gem you install hasn’t been tampered with by following the instructions below.

Add my public key (if you haven’t already, expires 2045-04-29) as a trusted certificate:

console gem cert --add <(curl -Ls https://raw.github.com/omniauth/omniauth-identity/main/certs/pboling.pem)

You only need to do that once. Then proceed to install with:

console gem install omniauth-identity -P MediumSecurity

The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.

This is necessary because not all of omniauth-identity’s dependencies are signed, so we cannot use HighSecurity.

If you want to up your security game full-time:

console bundle config set --global trust-policy MediumSecurity

NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.

🔧 Compatibility

This gem is compatible with a wide range of Ruby versions and Ruby ORMs, as of May 2025, version 3.1.

  • Tested in CI against:
    • Ruby 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, ruby-head
    • JRuby 9.2, 9.3, 9.4, 10.0, jruby-head
    • omniauth 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, HEAD
    • activerecord 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0, HEAD
    • sqlite3 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 2.0, 2.1
    • couch_potato 1.17+
    • mongoid 7.3, 7.4, 8.1, 9.0
    • bson 4.12, 4.15, 5.0, HEAD
    • sequel 5.86+
  • At least 5 different database ORM adapters, which connect to 15 different database clients!

| Databases | Adapter Libraries | | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | | MySQL, MariaDB, PostgreSQL, SQLite | ActiveRecord | | CouchDB | CouchPotato | | MongoDB | Mongoid | | RethinkDB | NoBrainer | | ADO, Amalgalite, IBM_DB, JDBC, MySQL, MariaDB, ODBC, Oracle, PostgreSQL, SQLAnywhere, SQLite, and TinyTDS | Sequel |

🔧 Basic Usage

This can be a bit hard to understand the first time. Luckily, Ryan Bates made a Railscast about it!

You use omniauth-identity just like you would any other OmniAuth provider: as a Rack middleware. In rails, this would be created by an initializer, such as config/initializers/omniauth.rb. The basic setup for an email/password authentication would look something like this:

ruby use OmniAuth::Builder do provider :identity, # required: tells OA that the Identity strategy is being used model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity" fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table end

Next, you need to create a model (called Identity by default, or specified with :model argument above) that will be able to persist the information provided by the user. Luckily for you, there are pre-built models for popular ORMs that make this dead simple.

Once you've got an Identity persistence model and the strategy up and running, you can point users to /auth/identity and it will request that they log in or give them the opportunity to sign up for an account. Once they have authenticated with their identity, OmniAuth will call through to /auth/identity/callback with the same kinds of information it would have had the user authenticated through an external provider.

Note: OmniAuth Identity is different from many other user authentication systems in that it is not built to store authentication information in your primary User model. Instead, the Identity model should be associated with your User model giving you maximum flexibility to include other authentication strategies such as Facebook, Twitter, etc.

ActiveRecord

Just subclass OmniAuth::Identity::Models::ActiveRecord and provide fields in the database for all the fields you are using.

```ruby class Identity < OmniAuth::Identity::Models::ActiveRecord auth_key :email # optional: specifies the field within the model that will be used during the login process # defaults to email, but may be username, uid, login, etc.

# Anything else you want! end ```

Sequel

Sequel is an alternative to ActiveRecord.

Just include OmniAuth::Identity::Models::Sequel mixin, and specify whatever else you will need.

ruby class SequelTestIdentity < Sequel::Model(:identities) include ::OmniAuth::Identity::Models::Sequel auth_key :email # whatever else you want! end

Mongoid

Include the OmniAuth::Identity::Models::Mongoid mixin and specify fields that you will need.

```ruby class Identity include ::Mongoid::Document include ::OmniAuth::Identity::Models::Mongoid

field :email, type: String field :name, type: String field :password_digest, type: String end ```

CouchPotato

Include the OmniAuth::Identity::Models::CouchPotatoModule mixin and specify fields that you will need.

```ruby class Identity # NOTE: CouchPotato::Persistence must be included before OmniAuth::Identity::Models::CouchPotatoModule include ::CouchPotato::Persistence include ::OmniAuth::Identity::Models::CouchPotatoModule

property :email property :password_digest

def self.where(searchhash) CouchPotato.database.view(Identity.byemail(key: search_hash)) end

view :by_email, key: :email end ```

NoBrainer

NoBrainer is an ORM for RethinkDB.

Include the OmniAuth::Identity::Models::NoBrainer mixin and specify fields that you will need.

```ruby class Identity include ::NoBrainer::Document include ::OmniAuth::Identity::Models::NoBrainer

auth_key :email end ```

Ruby Object Mapper

Would love to add a mixin for the Ruby Object Mapper (ROM) if anyone wants to work on it!

Custom Auth Model

To use a class other than the default, specify the :model option to a different class.

ruby use OmniAuth::Builder do provider :identity, fields: [:email], model: MyCustomClass end

NOTE: In the above example, MyCustomClass must have a class method called auth_key that returns the default (email) or custom auth_key to use.

Customizing Registration Failure

To use your own custom registration form, create a form that POSTs to /auth/identity/register with password, password_confirmation, and your other fields.

erb <%= form_tag '/auth/identity/register' do |f| %> <h1>Create an Account</h1> <%= text_field_tag :email %> <%= password_field_tag :password %> <%= password_field_tag :password_confirmation %> <%= submit_tag %> <% end %>

Beware not to nest your form parameters within a namespace. This strategy looks for the form parameters at the top level of the post params. If you are using simple_form, then you can avoid the params nesting by specifying :input_html.

erb <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %> <h1>Create an Account</h1> <%# specify :input_html to avoid params nesting %> <%= f.input :email, :input_html => {:name => 'email'} %> <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %> <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %> <button type='submit'>Sign Up</button> <% end %>

Next you'll need to let OmniAuth know what action to call when a registration fails. In your OmniAuth configuration, specify any valid rack endpoint in the :on_failed_registration option.

ruby use OmniAuth::Builder do provider :identity, fields: [:email], on_failed_registration: UsersController.action(:new) end

For more information on rack endpoints, check out this introduction and ActionController::Metal

Customizing Locate Conditions

You can customize the way that matching records are found when authenticating. For example, for a site with multiple domains, you may wish to scope the search within a particular subdomain. To do so, add :locate_conditions to your config. The default value is:

ruby use OmniAuth::Builder do provider :identity, locate_conditions: ->(req) { {model.auth_key => req.params["auth_key"]} } # ... end

locate_conditions takes a Proc object, and must return a Hash object, which will be used as the argument to the locate method for your ORM. The proc is evaluated in the callback context, and has access to your Identity model (using model) and receives the request object as a parameter. Note that model.auth_key defaults to email, but is also configurable.

Note: Be careful when customizing locate_conditions. The best way to modify the conditions is to copy the default value, and then add to the hash. Removing the default condition will almost always break things!

Customizing Other Things

From the code - here are the options we have for you, a couple of which are documented above, and the rest are documented... in the specs we hope!?

``` option :fields, %i[name email]

  # Primary Feature Switches:

option :enableregistration, true # See #otherphase and #requestphase option :enablelogin, true # See #other_phase

  # Customization Options:

option :onlogin, nil # See #requestphase option :onvalidation, nil # See #registrationphase option :onregistration, nil # See #registrationphase option :onfailedregistration, nil # See #registrationphase option :locateconditions, ->(req) { {model.authkey => req.params["authkey"]} } ```

Please contribute some documentation if you have the gumption! The maintainer's time is limited, and sometimes the authors of PRs with new options don't update the this readme. 😭

🔐 Security

See SECURITY.md.

🤝 Contributing

If you need some ideas of where to help, you could work on adding more code coverage, or if it is already 💯 (see below) check issues, or PRs, or use the gem and think about how it could be better.

We Keep A Changelog so if you make changes, remember to update it.

See CONTRIBUTING.md for more detailed instructions.

🚀 Release Instructions

See CONTRIBUTING.md.

Code Coverage

Coverage Graph

Coveralls Test Coverage

🪇 Code of Conduct

Everyone interacting with this project's codebases, issue trackers, chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

🌈 Contributors

Contributors

Made with contributors-img.

⭐️ Star History

Star History Chart

📌 Versioning

This Library adheres to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.

📌 Is "Platform Support" part of the public API?

Yes. But I'm obligated to include notes...

SemVer should, but doesn't explicitly, say that dropping support for specific Platforms is a breaking change to an API. It is obvious to many, but not all, and since the spec is silent, the bike shedding is endless.

dropping support for a platform is both obviously and objectively a breaking change

To get a better understanding of how SemVer is intended to work over a project's lifetime, read this article from the creator of SemVer:

As a result of this policy, and the interpretive lens used by the maintainer, you can (and should) specify a dependency on these libraries using the Pessimistic Version Constraint with two digits of precision.

For example:

ruby spec.add_dependency("omniauth-identity", "~> 3.1")

See CHANGELOG.md for a list of releases.

📄 License

The gem is available as open source under the terms of the MIT License License: MIT. See LICENSE.txt for the official Copyright Notice.

© Copyright

  • Copyright (c) 2021, 2024-2025 Peter H. Boling, of Galtzo.com Galtzo.com Logo by Aboling0, CC BY-SA 4.0 , and omniauth-identity contributors
  • Copyright (c) 2020 Peter H. Boling, Andrew Roberts, and Jellybooks Ltd.
  • Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.

🤑 One more thing

Having arrived at the bottom of the page, please endure a final supplication. The primary maintainer of this gem, Peter Boling, wants Ruby to be a great place for people to solve problems, big and small. Please consider supporting his efforts via the giant yellow link below, or one of smaller ones, depending on button size preference.

Buy me a latte

Liberapay Goal Progress Sponsor Me on Github Donate on Polar Donate to my FLOSS or refugee efforts at ko-fi.com Donate to my FLOSS or refugee efforts using Patreon

P.S. If you need help️, or want to say thanks, 👇 Join the Discord.

Live Chat on Discord

Owner

  • Name: OmniAuth Community
  • Login: omniauth
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
title: omniauth-identity
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Peter Hurn
    family-names: Boling
    email: peter@railsbling.com
    affiliation: railsbling.com
    orcid: 'https://orcid.org/0009-0008-8519-441X'
identifiers:
  - type: url
    value: 'https://github.com/omniauth/omniauth-identity/'
    description: omniauth-identity
repository-code: 'https://github.com/omniauth/omniauth-identity/'
abstract: >-
  omniauth-identity
license: See license file

GitHub Events

Total
  • Create event: 29
  • Issues event: 1
  • Release event: 8
  • Watch event: 11
  • Delete event: 35
  • Issue comment event: 81
  • Push event: 163
  • Pull request review event: 17
  • Pull request event: 64
Last Year
  • Create event: 29
  • Issues event: 1
  • Release event: 8
  • Watch event: 11
  • Delete event: 35
  • Issue comment event: 81
  • Push event: 163
  • Pull request review event: 17
  • Pull request event: 64

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 373
  • Total Committers: 29
  • Avg Commits per committer: 12.862
  • Development Distribution Score (DDS): 0.311
Past Year
  • Commits: 161
  • Committers: 6
  • Avg Commits per committer: 26.833
  • Development Distribution Score (DDS): 0.149
Top Committers
Name Email Commits
Peter Boling p****g@g****m 257
Michael Bleigh m****l@i****m 28
depfu[bot] 2****] 18
Andrew Roberts a****k@g****m 14
Michael Bleigh m****h@m****m 6
Matt Knopp m****p@g****m 6
Jerry Cheung j****h@w****m 4
Justin Powers j****n@d****m 4
Jeremy Bueler j****r@g****m 4
Gustavo Beathyate g****e@m****m 3
ian i****r@m****m 2
Anton Maminov a****x@g****m 2
Blake Gentry b****y 2
Caleb Woods c****s@g****m 2
Corey Haines c****s@g****m 2
George Hudson g****8@g****m 2
dependabot[bot] 4****] 2
froderik f****k@e****e 2
ghiblin a****i@g****m 2
KOMURA Takaaki k****v@k****p 2
Akira Matsuda r****e@d****p 1
Andrew Freemantle a****w@f****k 1
slainer68 s****8@g****m 1
Boban Sugareski b****n@a****m 1
Bryan Talbot b****t@i****m 1
Kevin Merritt k****t@g****m 1
Mitch Dempsey m****y@g****m 1
Nate Bird n****d@g****m 1
Takeshi Yabe t****e@n****m 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 53
  • Total pull requests: 108
  • Average time to close issues: almost 6 years
  • Average time to close pull requests: over 1 year
  • Total issue authors: 47
  • Total pull request authors: 33
  • Average comments per issue: 3.28
  • Average comments per pull request: 1.59
  • Merged pull requests: 67
  • Bot issues: 1
  • Bot pull requests: 48
Past Year
  • Issues: 1
  • Pull requests: 53
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Issue authors: 1
  • Pull request authors: 5
  • Average comments per issue: 0.0
  • Average comments per pull request: 1.58
  • Merged pull requests: 45
  • Bot issues: 1
  • Bot pull requests: 38
Top Authors
Issue Authors
  • ryanb (2)
  • nbibler (2)
  • sanemat (2)
  • aman199002 (2)
  • envygeeks (2)
  • irwangunardi (2)
  • depfu[bot] (1)
  • shaileshgupta (1)
  • yashaka (1)
  • paulspringett (1)
  • tylerhunt (1)
  • kul1 (1)
  • andyroberts (1)
  • adrianotadao (1)
  • badnorseman (1)
Pull Request Authors
  • depfu[bot] (36)
  • pboling (24)
  • dependabot[bot] (19)
  • George-Hudson (5)
  • emon (4)
  • amatsuda (2)
  • davide (2)
  • Xeragus (2)
  • Aboling0 (2)
  • adolski (2)
  • ghost (2)
  • btalbot (2)
  • jbueler (1)
  • ianmiller (1)
  • webdestroya (1)
Top Labels
Issue Labels
documentation (6) bug (1) enhancement (1) dependencies (1)
Pull Request Labels
depfu (35) dependencies (19) github_actions (5) bug (2)

Packages

  • Total packages: 1
  • Total downloads:
    • rubygems 1,988,343 total
  • Total docker downloads: 7,208
  • Total dependent packages: 7
  • Total dependent repositories: 441
  • Total versions: 23
  • Total maintainers: 4
rubygems.org: omniauth-identity

Traditional username/password based authentication system for OmniAuth

  • Versions: 23
  • Dependent Packages: 7
  • Dependent Repositories: 441
  • Downloads: 1,988,343 Total
  • Docker Downloads: 7,208
Rankings
Dependent repos count: 1.6%
Docker downloads count: 2.2%
Downloads: 2.2%
Dependent packages count: 2.2%
Average: 2.3%
Forks count: 2.6%
Stargazers count: 3.0%
Funding
  • https://github.com/sponsors/pboling
Last synced: 4 months ago

Dependencies

Gemfile rubygems
  • activerecord ~> 6 development
  • activerecord ~> 5 development
  • anonymous_active_record ~> 1 development
  • byebug >= 0 development
  • couch_potato >= 0 development
  • github-markup >= 0 development
  • growl >= 0 development
  • guard >= 0 development
  • guard-bundler >= 0 development
  • guard-rspec >= 0 development
  • mongoid ~> 7 development
  • mongoid-rspec >= 0 development
  • nobrainer ~> 0 development
  • pry >= 0 development
  • pry-byebug >= 0 development
  • rb-fsevent >= 0 development
  • redcarpet >= 0 development
  • rubocop ~> 1.9 development
  • rubocop-md >= 0 development
  • rubocop-minitest >= 0 development
  • rubocop-packaging >= 0 development
  • rubocop-performance >= 0 development
  • rubocop-rake >= 0 development
  • rubocop-rspec >= 0 development
  • rubocop-sequel >= 0 development
  • sequel ~> 5 development
  • simplecov ~> 0.21 development
  • test-unit >= 3.0 development
  • yard ~> 0.9.24
omniauth-identity.gemspec rubygems
  • rack-test ~> 1 development
  • rake ~> 13 development
  • rspec ~> 3 development
  • rspec-block_is_expected ~> 1.0 development
  • sqlite3 ~> 1.4 development
  • bcrypt >= 0
  • omniauth >= 0
.github/workflows/style.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite
.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • amancevice/setup-code-climate v0 composite
  • ruby/setup-ruby v1 composite