{"id":14955999,"url":"https://github.com/tiltcamp/omniauth-outseta","last_synced_at":"2025-10-06T09:30:32.661Z","repository":{"id":168470048,"uuid":"644034920","full_name":"tiltcamp/omniauth-outseta","owner":"tiltcamp","description":"Enables the use of Outseta as an authentication provider in combination with Devise and/or OmniAuth.","archived":false,"fork":false,"pushed_at":"2024-08-02T01:01:25.000Z","size":37,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-24T22:59:00.319Z","etag":null,"topics":["devise","omniauth","outseta","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/omniauth-outseta","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiltcamp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-22T17:11:17.000Z","updated_at":"2024-05-14T22:35:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d7da7e02-da37-4e6d-b2e4-63328d3a30a7","html_url":"https://github.com/tiltcamp/omniauth-outseta","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":"0.23809523809523814","last_synced_commit":"0493305198c7d9d80a2f53e6865a93ef005fde32"},"previous_names":["tiltcamp/omniauth-outseta"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiltcamp%2Fomniauth-outseta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiltcamp%2Fomniauth-outseta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiltcamp%2Fomniauth-outseta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiltcamp%2Fomniauth-outseta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiltcamp","download_url":"https://codeload.github.com/tiltcamp/omniauth-outseta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515428,"owners_count":19002481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devise","omniauth","outseta","rails","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:12:09.288Z","updated_at":"2025-10-06T09:30:32.072Z","avatar_url":"https://github.com/tiltcamp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Omniauth::Outseta\n\nThis gem enables the use of [Outseta](https://www.outseta.com/) as an authentication provider in combination with the \n[Devise](https://github.com/heartcombo/devise) and [OmniAuth](https://github.com/omniauth/omniauth) gems. Outseta\nenables you to manage, authenticate, and charge your customers all in one place.\n\n## Installation (With Devise)\n\n### Prerequisites\n\nEnsure you have [Devise](https://github.com/heartcombo/devise) set up for your Ruby on Rails application. If not, you \ncan follow the Devise [Getting Started](https://github.com/heartcombo/devise#getting-started) guide.\n\n### Adding the Gem\n\nAdd the `omniauth-outseta` gem to your Gemfile:\n\n```ruby\ngem 'omniauth-outseta'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\n### Configuration\n\nTo configure the gem, add the following to your Devise initializer (`config/initializers/devise.rb`):\n\n```ruby\nconfig.omniauth :outseta, subdomain: 'your_subdomain', jwt_public_key: \u003c\u003c~PEM\n  -----BEGIN CERTIFICATE----- \n  YourPublicKeyHere\n  -----END CERTIFICATE-----\nPEM\n```\n\nReplace `'your_subdomain'` and `'YourPublicKeyHere'` with your actual Outseta subdomain and public key. The public key\ncan be retrieved by logging in to your Outseta account and navigating to \"Auth\" -\u003e \"Sign up and Login\", and expanding\nthe \"Show advanced options\" panel inside the \"Login settings\" section. The last section will be the \"JWT Key\" card,\ncontaining the public key used to validate the signature on Outseta JWTs.\n\n### User Model\n\n#### Adding Necessary Fields\n\nAdd the necessary fields to your User model by generating a migration:\n\n```bash\n$ rails generate migration AddFieldsToUser email:string outseta_uid:string:index name:string account_uid:string\n```\n\nAnd add a unique constraint to the `outseta_uid` field in the newly generated migration:\n\n```ruby\nadd_index :users, :outseta_uid, unique: true\n```\n\nAnd then migrate the database:\n\n```bash\n$ rails db:migrate\n```\n\n#### Updating the User Model\n\nUpdate the User model (`app/models/user.rb`) to include the following static `from_outseta_omniauth` method:\n\n```ruby\nclass User \u003c ApplicationRecord\n  devise :trackable, :rememberable, :timeoutable, :omniauthable, omniauth_providers: [:outseta]\n\n  def self.from_outseta_omniauth(auth)\n    where(outseta_uid: auth.uid).first_or_create do |user|\n      user.email = auth.info.email\n      user.name = auth.info.name\n      user.account_uid = auth.extra.account_uid\n    end\n  end\nend\n```\n\n### Omniauth Callbacks Controller\n\nCreate or update the Omniauth Callbacks Controller (`app/controllers/users/omniauth_callbacks_controller.rb`) to include\nthe following:\n\n```ruby\nmodule Users\n  class OmniauthCallbacksController \u003c Devise::OmniauthCallbacksController\n    def outseta\n      @user = User.from_outseta_omniauth(request.env[\"omniauth.auth\"])\n\n      if @user.persisted?\n        sign_in_and_redirect @user, event: :authentication\n      else\n        redirect_to user_outseta_omniauth_authorize_url\n      end\n    end\n  end\nend\n```\n\n### Routes\n\nEnsure your `config/routes.rb` file includes an override for the Omniauth Callbacks Controller. If not, add the following:\n\n```ruby\nRails.application.routes.draw do\n  devise_for :users, controllers: { omniauth_callbacks: \"users/omniauth_callbacks\" }\nend\n```\n\n### Without [Database Authenticatable](https://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/DatabaseAuthenticatable)\n\nThis may be obvious to those with a deep familiarity with Devise, but if you opt not to use Devise's \n`database_authenticatable` module (as suggested above) you will not get the default `sessions` routes. This means that \nyou will need to create your own 'Sign in' and 'Sign out' pages and routes. You can do this without a new controller by\njust overriding the default Devise `sessions/new` view as follows.\n\nFirst, enable scoped views in your Devise configuration (`config/initializers/devise.rb`):\n\n```ruby\n  # ==\u003e Scopes configuration\n  # Turn scoped views on. Before rendering \"sessions/new\", it will first check for\n  # \"users/sessions/new\". It's turned off by default because it's slower if you\n  # are using only default views.\n  config.scoped_views = true\n```\n\nThen, create a new file at `app/views/users/sessions/new.html.erb` with the following contents:\n\n```erb\n\u003c%= button_to \"Sign in with Outseta\", user_outseta_omniauth_authorize_path %\u003e\n```\n\nAnd then add the following `devise_scope :user` block to your `config/routes.rb` file:\n\n```ruby\nRails.application.routes.draw do\n  devise_for :users, controllers: { omniauth_callbacks: \"users/omniauth_callbacks\" }\n  devise_scope :user do\n    authenticated do\n      delete 'sign_out', to: 'devise/sessions#destroy', as: :destroy_user_session\n    end\n\n    unauthenticated do\n      root to: 'devise/sessions#new', as: :unauthenticated_root\n    end\n  end\nend\n```\n\nYou can then add a sign out button anywhere in your application with the following:\n\n```erb\n\u003c%= link_to \"Sign out\", destroy_user_session_path, data: { \"turbo-method\": :delete } %\u003e\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can \nalso run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. Releases are made automatically using\n[GitHub Actions and conventional commits](https://andrewm.codes/blog/automating-ruby-gem-releases-with-github-actions/).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tiltcamp/omniauth-outseta. This project is\nintended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the \n[code of conduct](https://github.com/tiltcamp/omniauth-outseta/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Omniauth::Outseta project's codebases, issue trackers, chat rooms and mailing lists is \nexpected to follow the [code of conduct](https://github.com/tiltcamp/omniauth-outseta/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiltcamp%2Fomniauth-outseta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiltcamp%2Fomniauth-outseta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiltcamp%2Fomniauth-outseta/lists"}