• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 14 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

making cross tenant data leaks a thing of the past.

Build Status

Multitenant

When building multitenant applications, never let an unscoped Model.all accidentally leak data to an unintended audience.

Usage

class User < ActiveRecord::Base
  belongs_to :tenant
  belongs_to_multitenant
  
  validates :email, uniqueness: true                    # application-wide uniqueness
  validates :alias, uniqueness: { scope: :tenant_id }   # tenant-wide uniqueness
end

Multitenant.with_tenant current_tenant do
  # queries within this block are automatically
  # scoped to the current tenant
  User.all

  # new objects created within this block are automatically
  # assigned to the current tenant
  User.create :name => 'Bob'
end

Features

  • Rails 3 compatible
  • Restrict database queries to only lookup objects for the current tenant
  • Auto assign newly created objects to the current tenant

Contributing

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Credits

Thanks to Lars Klevan for inspiring this project.

Copyright

Copyright (c) 2011 Ryan Sonnek. See LICENSE.txt for further details.

More Repositories

1

backgrounded

simple background execution of model methods
Ruby
129
star
2

bundler-updater

Interactively update your outdated gems
Ruby
102
star
3

email_prefixer

Ruby
41
star
4

email_preview

preview emails from within your web browser
Ruby
28
star
5

callback_skipper

skip activerecord callbacks
Ruby
18
star
6

factory_girl_rspec

integrate factory_girl directly into the RSpec DSL
Ruby
16
star
7

good_touch

Update timestamps without invoking ActiveRecord callbacks
Ruby
12
star
8

guard-jslint-on-rails

jslint-on-rails guard plugin
Ruby
12
star
9

rails-console-tweaks

Tweak rails console with more useful defaults
Ruby
9
star
10

iphoto_backup

export photos out of iPhoto for backups/archiving
Ruby
8
star
11

dotfiles

my dot files
Emacs Lisp
8
star
12

gitx

Git eXtensions for improved development workflows
Ruby
8
star
13

detect_browser_os

Ruby
7
star
14

delicious-chrome-extension

Google Chrome extension that integrates with Delicious bookmarks
JavaScript
7
star
15

zillow-chrome-extension

google chrome extension integrating with the Zillow real estate API along with google maps
JavaScript
7
star
16

bundler-reorganizer

Ruby
6
star
17

acts_as_stripped

simple utility to strip whitespace from model's string attributes
Ruby
6
star
18

twitteralerts

demo of twitter style alert messages for Ruby on Rails
Ruby
4
star
19

power-card-viewer

iPhone app for browsing DnD 4e power cards
JavaScript
4
star
20

testdox-maven-plugin

maven plugin for generating testdox report
Java
3
star
21

growl-air

growl-like notifications for adobe air applications
JavaScript
3
star
22

sublime-spec-focuser

Sublime Text plugin for toggling focus on currently selected spec
Python
3
star
23

canvas-mapper

4e mapping utility built on Javascript and Canvas
JavaScript
3
star
24

css_browser_selector

Gives the ability to write specific CSS code for each operating system and each browser from the backend or through JS.
Ruby
3
star
25

webstart-maven-plugin

Java
3
star
26

has_preferences

Ruby
2
star
27

wicketstuff-rome

Wicket component for integrating with ROME RSS/Atom feeds
2
star
28

shard

open gaming engine
Java
2
star
29

jruby-redcloth

Ruby
2
star
30

rspec-respect_selector_limit

RSpec matcher for validating number of CSS selectors
Ruby
2
star
31

jquery-relative-timestamp

clientside rendering of relative timestamps
2
star
32

wicketstuff-scriptaculous

Wicket integration with the Scriptaculous javascript library
2
star
33

backgrounded_mail

send email in background
Ruby
2
star
34

backgrounded-resque

Backgrounded handler for enqueing jobs into resque
Ruby
2
star
35

wicketstuff-hibernate-behavior

Wicket component for autowiring based on Hibernate annotations
1
star
36

jquery-disable

jquery extension to enable/disable elements
JavaScript
1
star
37

true_test

Ruby
1
star
38

ensure_connected

ensure database connection is valid before performing work
Ruby
1
star
39

email-validator

validate email attribute on activerecord object
Ruby
1
star
40

wireframe.github.com

JavaScript
1
star
41

yard-restfuldoc-plugin

YARD Documentation plugin for generating docs for REST API's
Ruby
1
star
42

rspec-lintable

Ruby
1
star
43

mailinator-chrome-extension

Google Chrome extension for generating one-time use email addresses
JavaScript
1
star
44

tokentracker

realtime collaboration app for tracking board game tokens
JavaScript
1
star