Project

mtdevise

0.02
No release in over 3 years
Low commit activity in last 3 years
MTDevise Rails 5.1 engine that adds multi-tenant basecamp style user logins (multi-tenant authetication using devise) to your ruby on rails application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.14
~> 4.7
~> 2.0
~> 1.14
~> 3.10
~> 1.2
~> 0.14.3
~> 5.2, >= 5.2.4.3
~> 3.2
phcadmin7
~> 10.3
phctheme3
~> 25.3
phctheme6
~> 11.3
phctheme7
~> 5.3
phcadmin4
~> 28.3
phcadmin5
~> 27.3
phcadmin6
~> 16.3
phctheme4
~> 23.3
phctheme5
~> 18.3
phctheme2
~> 45.3
phcadmin1
~> 51.3
phctitleseo
~> 48.3
phcadmin2
~> 53.3
phcadmin3
~> 46.3
phcnotifi
~> 49.3
phctheme1
~> 56.3
 Project Readme

security Code Climate Gem Version License: MIT

MTDevise Rails 5.1 Multi-Tenancy Engine Documentation

PHC MTDevise Rails 5.1 engine adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.

  • Multi-tenancy using subdomain scoping and account_id column.
  • Adds basecamp style logins to devise authentication gem.
  • Welcome, Dashboard with custom Devise views included.
  • Highly customizable views and layouts using standard bootstrap 3 code.
  • Central login screen for all tenants (users) or logins through a subdomain.
  • Mis-Spelling and redirect to welcome screen if subdomain none-existent.
  • Compatible with postgre, mysql and sqlite (for dev environments).

Step 1 - Add user model to your app (Must be Done First!!)

Generate a user.rb file in your mainapp and add the code below

rails g model User
include Mtdevise::UserStorage

Step 2 - Add Mtdevise to your gemfile and run command

gem 'mtdevise', '~> 16.0'
bundle exec install

Step 3 - Add and migrate mtdevise database tables

rake railties:install:migrations
rake db:migrate

Step 4 - Configure ActionMailer

  • Mailer functions are required in order for mtdevise to operate.
  • Mailer is used for confirmation and password reset functions.

Step 5 - Mount the Engine in your Routes File

Add this line at the end of the routes file.

mount Mtdevise::Engine, :at => '/'

Step 6 - Constrain the routs you want secured

All the routes you want to have multi-tenacy login functions goes in between the constraints block.

constraints(Mtdevise::Constraints::SubdomainRequired) do
	# Routes Requiring Security & Multi-Tenancy Routes  
end

Step 7 - Modifications to MainApp Controllers & Database

Your app needs modification to controllers (example)
Any corresponding db database tables must have an accounts_id column

accounts_id

Step 8 - Add mtdevise extension to models

Add the mtdevise extension to the top of all models for the routes configured in the previous step.

def self.scoped_to(account)
	where(:account_id => account.id)
end

Step 9 - Configure scopes in your controller

Scope your controllers. Examples on github wiki or multi-tenant starter app.

.scoped_to(current_account)

Step 10 - Environment (ENV) Variables

Set a sent from email address for confirmation and password reset emails more info here. .

PHC_MTDEVISE_SENDER = no_reply@example.com

Additional Information

Views - Mtdevise Views Can be Customized

Once installed views can be generated and customized to your apps needs.

rails generate mtdevise:views
rake assets:clobber
rake assets:precompile

Additional Documentation

Multi-Tenant Starter App
Documentation (Github Wiki)
Environment Variables
Issues & Bug Reports
Past Security Patch Notes
Managed by PHCNetworks

Circle CI