milia 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79734aeaf103cdc61a4ebce073a840cac3e359ab
4
- data.tar.gz: d521ade804dda61d0743cfd7f9427bdace6c226f
3
+ metadata.gz: b17d04a8171ccbdc169aa06e5f1d28c5e850c3e2
4
+ data.tar.gz: c5d93e06cbd053b83c4704ba0fabcd6b1c809c7e
5
5
  SHA512:
6
- metadata.gz: 1fe1f3293e03e3af8f1689f51bc860a2d0a8592e51735c762db25b1b3a8e4ee547dc16bd26ec0bbbbbc4749c608fc62c651e513ac2c4b3adf3b8d7f4fe572030
7
- data.tar.gz: 806f8f3bf695d6f2cd9ecde69af8f5e4099d6791b09432a96001344a9ccb672e879748ed2f8a04939ba7b6e7fa2e93626c77db182dc51c7cfa2d682d9e893b07
6
+ metadata.gz: 76db8065475838404861cada72daaad22cd582c3233ff455ce411a3daf512de8bad59c71788684db5e6cb524758af7620d15013c7efe4df502b62811bc00b81a
7
+ data.tar.gz: 1fa75ebac26ede1a0f394e3fac189e20753af27bcd44d6247377856d1ab1838c4a6f10be693d091ac7a3698fb95cd80cad791a544fc13f0652e434313e424889
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ gemfile: test/Gemfile
3
+ before_install: cd test
4
+ script: bundle exec rake
data/README.md CHANGED
@@ -1,29 +1,38 @@
1
- # milia
1
+ # milia
2
+ [![Build Status](https://travis-ci.org/jekuno/milia.svg?branch=master)](https://travis-ci.org/jekuno/milia)
2
3
 
3
- Milia is a multi-tenanting gem for hosted Rails 4.2.x applications which use
4
- the devise gem for user authentication and registrations. Milia comes with
5
- tailoring for common use cases needing multi-tenanting with user authentication.
4
+ Milia is a multi-tenanting gem for Ruby on Rails applications.
5
+
6
+ * Milia is a solid choice for (SaaS) applications which are used by more than one tenant (i.e. companies or organizations) and is tailored for common use cases of multi-tenanted applications.
7
+ * Milia allows to save the data of all tenants in the same database and enforces row based separation of the tenant data.
8
+ * Milia uses the devise gem for user authentication and registration.
9
+
10
+ You are viewing the documentation of the milia branch for **Rails 4.2.x** applications.
11
+ Milia also supports **Rails 5.x**. Please consider the according [README](../rails5-support/README.md) of the [Rails5 branch](../../tree/rails5-support/).
6
12
 
7
13
  ## Basic concepts for the milia multi-tenanting gem
8
14
 
9
- ### multi-tenanting highlights
10
-
11
- * should be transparent to the main application code
12
- * should be symbiotic with user authentication
13
- * should raise exceptions upon attempted illegal access
14
- * should force tenanting (not allow sloppy access to all tenant records)
15
- * should allow application flexibility upon new tenant sign-up,
16
- usage of eula information, etc
17
- * should be as non-invasive (as possible) to Rails code
18
- * row-based tenanting is used
19
- * default_scope is used to enforce tenanting
20
-
21
- The author used schema-based tenanting in the past but found it deficient for
22
- the following reasons: most DBMS are optimized to handle enormous number of
23
- rows but not an enormous number of schema (tables). Schema-based tenancy took a
24
- performance hit, was seriously time-consuming to backup and restore, was invasive
25
- into the Rails code structure (monkey patching), was complex to implement, and
26
- couldn't use Rails migration tools as-is.
15
+ ### Milia highlights
16
+
17
+ * Transparent to the main application code
18
+ * Symbiotic with user authentication
19
+ * Raises exceptions upon attempted illegal access
20
+ * Enforces tenanting (not allow sloppy access to all tenant records)
21
+ * Allows application flexibility upon new tenant sign-up, usage of eula information, etc
22
+ * As non-invasive (as possible) to Rails code
23
+ * Uses row-based tenanting
24
+ * Uses default_scope to enforce tenanting
25
+
26
+ ### Row based vs. schema based tenanting
27
+ * Milia uses row based tenanting.
28
+ * The author used schema-based tenanting in the past but found it deficient for the following reasons. Schema-based tenancy
29
+ * is not what DBMS are optimized for (most DBMS are optimized to handle enormous number of rows but not an enormous number of schema (tables)),
30
+ * took a performance hit,
31
+ * was seriously time-consuming to backup and restore,
32
+ * was invasive into the Rails code structure (monkey patching),
33
+ * was complex to implement, and
34
+ * couldn't use Rails migration tools as-is.
35
+ * Heroku also [strongly recommends against](https://devcenter.heroku.com/articles/heroku-postgresql#multiple-schemas) using schema based tenanting.
27
36
 
28
37
  ### tenants/users vs organizations/members
29
38
 
@@ -93,7 +102,7 @@ Further details about this process can be found via the sources listed below:
93
102
  this sample on github, however, will always be for the latest release or latest beta (whichever is most recent).
94
103
  * find it at: https://github.com/dsaronin/sample-milia-app
95
104
 
96
- ### Available docmentation resources for milia
105
+ ### Available documentation resources for milia
97
106
 
98
107
  * doc/sample.sh -- this document will ALWAYS be the most recent
99
108
  (for example in the edge branch: "newdev")
@@ -819,13 +828,13 @@ tenanted areas even if no records are returned. This is a potential security
819
828
  breach. Further details can be found in various discussions about the
820
829
  behavior of databases such as POSTGRES.
821
830
 
822
- The milia workaround is to add an additional .where( where_restrict_tenants(klass1, klass2,...))
831
+ The milia workaround is to add an additional .where( where_restrict_tenant(klass1, klass2,...))
823
832
  for each of the subordinate models in the join.
824
833
 
825
- ### usage of where_restrict_tenants
834
+ ### usage of where_restrict_tenant
826
835
 
827
836
  ```ruby
828
- Comment.joins(stuff).where( where_restrict_tenants(Post, Author) ).all
837
+ Comment.joins(stuff).where( where_restrict_tenant(Post, Author) ).all
829
838
  ```
830
839
 
831
840
  ## no tenant authorization required controller actions: root_path
@@ -99,11 +99,10 @@ module Milia
99
99
  # -- sets current tenant
100
100
  # ------------------------------------------------------------------------------
101
101
  def authenticate_tenant!()
102
- unless authenticate_user!
102
+ unless authenticate_user!(force: true)
103
103
  email = ( params.nil? || params[:user].nil? ? "<email missing>" : params[:user][:email] )
104
104
  flash[:error] = "cannot sign in as #{email}; check email/password"
105
105
  logger.info("MILIA >>>>> [failed auth user] ") unless logger.nil?
106
- return false # abort the before_filter chain
107
106
  end
108
107
 
109
108
  trace_tenanting( "authenticate_tenant!" )
@@ -1,3 +1,3 @@
1
1
  module Milia
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: ../../milia
12
12
  specs:
13
- milia (1.2.0)
13
+ milia (1.2.1)
14
14
  devise (~> 3.4)
15
15
  rails (~> 4.2)
16
16
 
@@ -14,10 +14,10 @@ module Miliatest
14
14
  # uncomment to ensure a common layout for devise forms
15
15
 
16
16
  config.to_prepare do # Devise
17
- Devise::SessionsController.layout "sign"
18
- Devise::RegistrationsController.layout "sign"
19
- Devise::ConfirmationsController.layout "sign"
20
- Devise::PasswordsController.layout "sign"
17
+ Devise::SessionsController.layout "sign"
18
+ Devise::RegistrationsController.layout "sign"
19
+ Devise::ConfirmationsController.layout "sign"
20
+ Devise::PasswordsController.layout "sign"
21
21
  end # Devise
22
22
 
23
23
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
@@ -1,6 +1,6 @@
1
1
  Miliatest::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
-
3
+
4
4
  # devise says to define default url
5
5
  config.action_mailer.default_url_options = { :host => 'secure.simple-milia-app.com', :protocol => 'https' }
6
6
 
@@ -35,7 +35,7 @@ Miliatest::Application.configure do
35
35
  # config.action_dispatch.rack_cache = true
36
36
 
37
37
  # Disable Rails's static asset server (Apache or nginx will already do this).
38
- config.serve_static_assets = false
38
+ config.serve_static_files = false
39
39
 
40
40
  # Compress JavaScripts and CSS.
41
41
  config.assets.js_compressor = :uglifier
@@ -1,6 +1,6 @@
1
1
  Miliatest::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
-
3
+
4
4
  # devise says to define default url
5
5
  config.action_mailer.default_url_options = { :host => "www.example.com" }
6
6
 
@@ -17,7 +17,7 @@ Miliatest::Application.configure do
17
17
  config.eager_load = false
18
18
 
19
19
  # Configure static asset server for tests with Cache-Control for performance.
20
- config.serve_static_assets = true
20
+ config.serve_static_files = true
21
21
  config.static_cache_control = "public, max-age=3600"
22
22
 
23
23
  # Show full error reports and disable caching.
@@ -34,7 +34,7 @@ Miliatest::Application.configure do
34
34
  # The :test delivery method accumulates sent emails in the
35
35
  # ActionMailer::Base.deliveries array.
36
36
  config.action_mailer.delivery_method = :test
37
-
37
+
38
38
  config.active_record.logger = nil
39
39
 
40
40
  # Print deprecation notices to the stderr.
@@ -1,7 +1,7 @@
1
1
  require 'ctlr_test_helper'
2
2
 
3
3
  class HomeControllerTest < ActionController::TestCase
4
-
4
+
5
5
  context 'home ctlr' do
6
6
  setup do
7
7
  Tenant.set_current_tenant( tenants( :tenant_1 ).id )
@@ -20,11 +20,10 @@ class HomeControllerTest < ActionController::TestCase
20
20
  end # should do
21
21
 
22
22
  should 'not get show without login' do
23
- assert_raise(ArgumentError, 'uncaught throw :warden'){
24
- get :show
25
- }
26
- assert_response :success
27
- end # should do
23
+ get :show
24
+ # redirects to sign in page
25
+ assert_redirected_to new_user_session_path
26
+ end # should do
28
27
 
29
28
  should 'reset tenant' do
30
29
  assert Tenant.current_tenant_id
@@ -70,9 +69,9 @@ class HomeControllerTest < ActionController::TestCase
70
69
 
71
70
  should 'prep signup view' do
72
71
  assert_nil @controller.instance_eval( "@tenant" )
73
- @controller.prep_signup_view(
74
- { name: 'Mangoland' },
75
- {email: 'billybob@bob.com', password: 'monkeymocha', password_confirmation: 'monkeymocha'}
72
+ @controller.prep_signup_view(
73
+ { name: 'Mangoland' },
74
+ {email: 'billybob@bob.com', password: 'monkeymocha', password_confirmation: 'monkeymocha'}
76
75
  )
77
76
  assert_equal 'Mangoland', @controller.instance_eval( "@tenant" ).name
78
77
  end # should do
@@ -2,7 +2,10 @@ require 'test_helper'
2
2
 
3
3
  class ActiveSupport::TestCase
4
4
 
5
+ end
6
+
7
+
8
+ class ActionController::TestCase
5
9
  include Devise::TestHelpers
6
10
 
7
11
  end # class
8
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - daudi amani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -121,6 +121,7 @@ files:
121
121
  - ".ruby-gemset"
122
122
  - ".ruby-version"
123
123
  - ".slugignore"
124
+ - ".travis.yml"
124
125
  - Gemfile
125
126
  - LICENSE.txt
126
127
  - README.md