{"id":22511106,"url":"https://github.com/rjayroach/dry-auth","last_synced_at":"2025-10-14T03:32:47.337Z","repository":{"id":10688990,"uuid":"12929806","full_name":"rjayroach/dry-auth","owner":"rjayroach","description":"Don't Repeat Yourself Authentication, Authorization and Accounting for Rails","archived":false,"fork":false,"pushed_at":"2017-06-27T13:10:10.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T02:28:35.904Z","etag":null,"topics":[],"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/rjayroach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-18T17:36:03.000Z","updated_at":"2017-06-27T12:44:52.000Z","dependencies_parsed_at":"2022-09-22T21:30:26.777Z","dependency_job_id":null,"html_url":"https://github.com/rjayroach/dry-auth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjayroach%2Fdry-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjayroach%2Fdry-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjayroach%2Fdry-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjayroach%2Fdry-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjayroach","download_url":"https://codeload.github.com/rjayroach/dry-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245949553,"owners_count":20698916,"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":[],"created_at":"2024-12-07T02:08:45.852Z","updated_at":"2025-10-14T03:32:47.262Z","avatar_url":"https://github.com/rjayroach.png","language":"Ruby","readme":"# DryAuth\n\n[![Build Status](https://semaphoreapp.com/api/v1/projects/6a4f592a-4a69-4976-983f-c10726d6a718/130967/shields_badge.png )](https://semaphoreapp.com/api/v1/projects/6a4f592a-4a69-4976-983f-c10726d6a718/130967/shields_badge.png)\n[![Code Climate](https://codeclimate.com/github/rjayroach/dry-auth.png)](https://codeclimate.com/github/rjayroach/dry-auth)\n[![Coverage Status](https://coveralls.io/repos/rjayroach/dry-auth/badge.png?branch=master)](https://coveralls.io/r/rjayroach/dry-auth?branch=master)\n\nDryAuth is a simple AAA solution for Rails applications. \nIt's purpose, as it's name implies, is to provide a simple Do Not Repeat Yourself AAA solution for Rails applications.\n\n## Features\n\nDryAuth bundles commonly used gems into a single Rails Engine and provides additional features out of the box:\n\n* A JSON authentication API\n* A GUI for CRUD on User and Roles tables for admin roles\n* A User Preferences view for a single user to update their profile\n* A menu system to access the above\n* A view for history changes stored by PaperTrail (todo)\n* Auth Profiles for 3rd party authentication credentials mapped to the User\n\n## Dependencies\n\nTo provide AAA, it depends on the following:\n\n1. Authentication: [Devise](https://github.com/plataformatec/devise)\n1. Authorization: [CanCan](https://github.com/ryanb/cancan) and [Rolify](https://github.com/EppO/rolify)\n1. Accounting: [PaperTrail](https://github.com/airblade/paper_trail)\n\n\n## Getting started\n\nIn your Gemfile:\n\n```ruby\ngem \"dry_auth\"\n```\n\n## Usage\n\nDryAuth provides drop-in AAA by providing a User model.\nThis model needs to be associated to the application's User model, e.g. Member, Author, etc.\n\n### Model Assocation\n\n1. Generate a user model, e.g FacebookUser, in the application with a reference to DryAuth::User:\n\n\t```bash\n\trails g model facebook_user dry_auth_user:references name\n\trake dry_auth:install:migrations db:migrate\n\t```\n\n1. Update the User model association:\n\n\t```ruby\n\tclass FacebookUser \u003c ActiveRecord::Base\n\t  belongs_to :user, class_name: \"DryAuth::User\"\n\tend\n\t```\n\n1. Create an association from an application model to DryAuth::User:\n\n\tIn the application, create an initializer to add association and delegates to DryAuth::User:\n\n\t```ruby\n\tRails.application.config.to_prepare do\n\n\t  # \n\t  # Add an association to the User model to FacebookUser\n\t  #\n\t  DryAuth::User.class_eval do\n\t    # todo conditions on this association? would be when provider.eql? 'facebook'\n\t    has_one :facebook_user, class_name: 'CacheParty::FacebookUser', dependent: :destroy\n\t  end\n\n\n\t  # \n\t  # Create a new CacheParty::FacebookUser when a new AuthProfile is created and the provider name is 'facebook'\n\t  # NOTE: The method below has knowledge of the inner workings of DryAuth User and AuthUser classes\n\t  #   Specifically, it assumes that the auth_profile will have a valid reference to a user (which is reasonable)\n\t  #\n\t  DryAuth::AuthProfile.class_eval do\n\n\t    # After saving an AuthProfile, check for an existing record of FacebookUser and create one if it doesn't exist\n\t    after_save :facebook_user_create, if: \"self.provider.eql?('facebook') and self.user.facebook_user.nil?\"\n\n\t    #\n\t    # Create a FacebookUser setting the username to the uid returned from facebook\n\t    #\n\t    def facebook_user_create\n\t      Rails.logger.debug \"Creating CacheParty::FacebookUser for DryAuth::User from #{ __FILE__ }\\n\"\n\t      self.user.create_facebook_user(facebook_id: self.uid)\n\t    end\n\t  end\n\n\tend\n\t```\n\n### Customize Views\n\nTo add fields to DryAuth's User edit view\n\n1. create a partial to render to edit fields:\n\n\tThe file must live in:  app/views/\\\u003cengine\\\u003e/users/\\_form.html.erb\n\n\tSee: mcp_common/app/views/mcp_common/users/\\_form.html.erb\n\n### TODO\n\n1. Strong Parameters on DryAuth::UserController\n\ntest\n\n\n## Adding Roles and Authorization\n\nSee: https://github.com/EppO/rolify/wiki/Tutorial\n\nSee: https://github.com/EppO/rolify/wiki/Tutorial\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjayroach%2Fdry-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjayroach%2Fdry-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjayroach%2Fdry-auth/lists"}