{"id":19724165,"url":"https://github.com/fastruby/ombu_labs-auth","last_synced_at":"2025-04-29T22:31:15.201Z","repository":{"id":61438136,"uuid":"550225339","full_name":"fastruby/ombu_labs-auth","owner":"fastruby","description":"A Ruby gem to make authentication easier for OmbuLabs' tools and web applications ","archived":false,"fork":false,"pushed_at":"2025-03-31T21:48:50.000Z","size":90,"stargazers_count":4,"open_issues_count":7,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T22:29:05.417Z","etag":null,"topics":["devise","omniauth","ruby"],"latest_commit_sha":null,"homepage":"","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/fastruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-LICENSE","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":"2022-10-12T12:03:13.000Z","updated_at":"2025-02-10T14:18:06.000Z","dependencies_parsed_at":"2024-11-11T23:28:14.541Z","dependency_job_id":"57ebc6e4-8157-4bc9-94e5-3113a19689d7","html_url":"https://github.com/fastruby/ombu_labs-auth","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":"0.21739130434782605","last_synced_commit":"369ef64ee98ce2193f41b7bea64c780be8195d85"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fombu_labs-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fombu_labs-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fombu_labs-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fombu_labs-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastruby","download_url":"https://codeload.github.com/fastruby/ombu_labs-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251593021,"owners_count":21614459,"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","ruby"],"created_at":"2024-11-11T23:24:45.346Z","updated_at":"2025-04-29T22:31:14.327Z","avatar_url":"https://github.com/fastruby.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OmbuLabs::Auth\n\nThis gem provides an easy way to generate new (Devise) sessions for members of a GitHub organization.\n\nIf a user is signing in with GitHub and they are a (public) member of the configured GitHub organization, they will be allowed in.\n\n## Environment Variables\n\n### GitHub Login\n\nMake sure you configure your ENV variables to use Github authentication.\n\n```\nENV[\"GITHUB_APP_ID\"]\nENV[\"GITHUB_APP_SECRET\"]\nENV[\"ORGANIZATION_LOGIN\"]\n```\n\n`ORGANIZATION_LOGIN`: This is the organization name as it appears in the GitHub URL, for instance `orgname` in https://github.com/orgname. It is needed to check if users are a part of the organization. Ensure that your membership is set to _public_ when you visit https://github.com/orgs/orgname/people.\n\nIf you don't belong to any organization, you can set up one here: https://github.com/organizations/plan\n\nMake sure you add your organization to the `.env` file like this:\n\n```\nORGANIZATION_LOGIN=orgname\n```\n\n`GITHUB_APP_ID` and `GITHUB_APP_SECRET`: These are the credentials of the OAuth GitHub App that you need to create. Follow the instructions on this link to create one: [Creating an OAuth GitHub App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)\n\nWhen creating the OAuth GitHub App, the `Homepage URL` field should be set to http://localhost:3000, and the `Authorization callback URL` should be http://localhost:3000/users/auth/github/callback.\n\nOnce you create the app and generate credentials for it, make sure you add them to the `.env` file like this:\n\n```\nGITHUB_APP_ID=xxxxxxxxxxxxxxxxxxxx\nGITHUB_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\n\n### Developer Login\n\nTo avoid the need of a GitHub application setup (useful for local development or Heroku Review Apps), the `developer` strategy can be enabled using setting a `SHOW_DEVELOPER_AUTH` variable with any non-blank value (`SHOW_DEVELOPER_AUTH=1` or `SHOW_DEVELOPER_AUTH=true` for example).\n\n## Getting Started\n\n### Requirements\n\nA `User`-like model that will be used for the authentication (`User`, `Admin`, `Client`, etc).\n\nThe database table for that model must have, at least, these fields:\n\n```rb\ncreate_table :clients do |t|\n  t.string :email, unique: true\n  t.string :provider\n  t.string :uid, unique: true\n  t.string :name\n  t.string :encrypted_password\nend\n```\n\n### Installation\n\n- Add this line to your application's Gemfile:\n\n```ruby\ngem 'ombu_labs-auth'\n```\n\n- And then execute:\n\n```bash\n$ bundle\n```\n\n- Add the following line to `config/routes.rb`\n\n```ruby\nmount OmbuLabs::Auth::Engine, at: '/', as: 'ombu_labs_auth'\n```\n\n- Add a Devise signin link in your homepage (notice all URL helpers will be under the engine object `ombu_labs_auth`)\n\n```html\n\u003cdiv\u003e\n  \u003ch1\u003eWelcome to the App\u003c/h1\u003e\n  \u003c%= link_to \"Sign in\", ombu_labs_auth.new_user_session_path %\u003e\n\u003c/div\u003e\n```\n\n\u003e This will default to a basic HTML page included in this gem. To customize this view, check [this section](#customizing-sign-in-page)\n\n- Add the Devise authentication helper to your private objects controllers\n\n```rb\nbefore_action :authenticate_user!\n```\n\n- Include the `OmbuLabsAuthenticable` concern in the authenticable model\n\n```rb\nclass Admin \u003c ApplicationRecord\n  include OmbuLabsAuthenticable\n  ...\nend\n```\n\n- Tell `OmbuLabs::Auth` the user class name and table for the authenticable model\n\n```rb\n# config/initializers/ombu_labs-auth.rb\nOmbuLabs::Auth.user_class_name = \"Admin\" # defaults to \"User\" if not set\nOmbuLabs::Auth.users_table_name = :admins # defaults to :users if not set\n```\n\n\u003e You can skip this step if the table is called `users` and the model is called `User`\n\n- Log Out action\n\nA link to `ombu_labs_auth.destroy_user_session_path` with method `DELETE` can be used. If rails-ujs is not available, a `button_to` can be used.\n\n```\n\u003c%= link_to \"Sign out\", ombu_labs_auth.destroy_user_session_path, method: :delete, class: \"button magenta\" %\u003e\n```\n\n### TODO: create a rails template to do all the previous steps automatically\n\n## Customizing sign in page\n\nThe gem provides a basic html template to select the authentication method. To customize it, create a view at `views/devise/session/new.html.erb` and a layout at `views/layouts/devise.html.erb`.\n\nInclude this snippet in the `new` view:\n\n```\n\u003c%- Devise.omniauth_providers.each do |provider| %\u003e\n  \u003c%= button_to \"Sign in with #{OmniAuth::Utils.camelize(provider)}\", omniauth_authorize_path(OmbuLabs::Auth.user_class, provider), method: :post %\u003e\u003cbr /\u003e\n\u003c% end -%\u003e\n```\n\nTo use a `link_to` helper instead of a `button_to` helper to, rails-ujs is needed to support making a `POST` request with link tags. Then, replace with:\n\n```\n\u003c%= link_to \"Sign in with #{OmniAuth::Utils.camelize(provider)}\", omniauth_authorize_path(OmbuLabs::Auth.user_class, provider), method: :post, data: { 'turbo-method' =\u003e :post } %\u003e\u003cbr /\u003e\n```\n\n\u003e If this intermediate page is not needed, the button/link to `omniauth_authorize_path` can be used directly.\n\n## Running tests\n\nRun `rake app:test:all` to run all tests and `rake app:test` to skip system tests.\n\n## Caveats\n\nPlease be aware this gem is a mountable engine which depends on Devise, and it's not possible to mount it multiple times. Refer to their Wiki for more on the issue - https://github.com/heartcombo/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine\n\n## Contributing\n\nHave a fix for a problem you've been running into or an idea for a new feature you think would be useful?\n\nTake a look at the [Contributing document](https://github.com/fastruby/ombu_labs-auth/blob/main/CONTRIBUTING.md) for instructions to set up the repo on your machine and create a good Pull Request.\n\n## Release\n\nIf you are looking to contribute in the gem you need to be aware that we are using the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) specification to release versions in this gem.\n\nwhich means, when doing a contribution your commit message must have the following structure\n\n```git\n\u003ctype\u003e[optional scope]: \u003cdescription\u003e\n\n[optional body]\n\n[optional footer(s)]\n```\n\n[here](https://www.conventionalcommits.org/en/v1.0.0/#examples) you can find some commit's examples.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fombu_labs-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastruby%2Fombu_labs-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fombu_labs-auth/lists"}