{"id":19015237,"url":"https://github.com/olivierobert/rails-devise-engine","last_synced_at":"2026-05-08T16:48:24.734Z","repository":{"id":141374628,"uuid":"113390758","full_name":"olivierobert/rails-devise-engine","owner":"olivierobert","description":"Re-usable authentication engine","archived":false,"fork":false,"pushed_at":"2017-12-07T08:47:13.000Z","size":103,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T22:43:06.738Z","etag":null,"topics":["rails-engine","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":null,"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/olivierobert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"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":"2017-12-07T02:11:44.000Z","updated_at":"2017-12-07T05:58:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"54ea6b42-e906-4801-9e0b-5184ba98b307","html_url":"https://github.com/olivierobert/rails-devise-engine","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivierobert%2Frails-devise-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivierobert%2Frails-devise-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivierobert%2Frails-devise-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivierobert%2Frails-devise-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olivierobert","download_url":"https://codeload.github.com/olivierobert/rails-devise-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240055257,"owners_count":19740973,"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":["rails-engine","ruby","ruby-on-rails"],"created_at":"2024-11-08T19:36:23.587Z","updated_at":"2025-11-11T16:33:55.702Z","avatar_url":"https://github.com/olivierobert.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# POC - Re-usable authentication engine\n\nResearch how to isolate generic authentication functionality into a [Rails engine](http://guides.rubyonrails.org/engines.html) so \nthat it can be-used as-is in other applications. \n\n## Rationale\n\nIn each project, authentication is almost always required and [Devise](https://github.com/plataformatec/devise) is almost \nalways the go-to gem to implement such functionality. While Devise is easy to use and configure, its codebase lives in \nthe core of the application and often needs tinkering. So in an effort of separating concerns and adopting a modular architecture, \nthis proof of concept isolates the authentication functionality and configuration in a separate engine `app_authentication`.\n\nThis authentication engine can now be configured, tested independently and re-used in multiple projects as-is.\n\n## How it works\n\n* The engine is mounted into the host application:\n\n```ruby\n# config/routes.rb\nRails.application.routes.draw do\n  mount AppAuthentication::Engine, at: '/'\n\n  root 'home#index'\nend\n```\n\n* All Devise controller methods and helpers such as `current_user` and `authenticate_user!` are exposed via an `initializer`:\n\n```ruby\n# engines/app_authentication/lib/app_authentication/engine.rb\ninitializer 'app_authentication.action_controller' do\n  ActiveSupport.on_load :action_controller do\n    helper AppAuthentication::Engine.helpers\n  end\nend\n``` \n\nThese methods and helpers can now be used in the core of the app or in the other engines:\n\n```ruby\n# engines/app_frontend/app/controllers/app_frontend/dashboard_controller.rb\nmodule AppFrontend\n  class DashboardController \u003c ApplicationController\n    before_action :authenticate_user!\n  end\nend\n```\n\n## How to use it\n\nThis POC can be used as a source of information for your own implementation. But if you wish to use it as-is, then follow these steps:\n\n* Clone the project `git clone git@github.com:olivierobert/rails-devise-engine.git`.\n* Copy the directory `engine/app_authentication` to the host application directory.\n* Copy and edit if needed the initializer for the engine `config/initializers/app_authentication.rb`. This configuration \nallows to override the resource to which Devise will be bound to (usually the `user` model). \n\n```ruby\nAppAuthentication.resource_class = 'User'\n```\n\nThe configuration must match the model class name that exists either in the core of the application (recommended) or in the other engines.\n\n## TODO\n\n* Extract the `app_authentication` engine into a standalone gem.\n* Create a generator to install the `app_authentication` gem.\n\n## License\nThe proof of concept is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivierobert%2Frails-devise-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folivierobert%2Frails-devise-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivierobert%2Frails-devise-engine/lists"}