wcc-auth 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/omniauth/strategies/watermark.rb +1 -0
- data/lib/wcc/auth/access_level.rb +2 -2
- data/lib/wcc/auth/version.rb +1 -1
- metadata +30 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cfc9a743cd01659828c3d7dc055c27538f67f53
|
|
4
|
+
data.tar.gz: 845b87ff6ac537b3d98d28a5b08899f255801d11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 316f009800967d2af42cbcfc4a230739d7a515210f9e4551a1c09000319237571db01cffa70a7fc507d712fec96b774501acf760ab5dfead5e7ed1a341e1bd55
|
|
7
|
+
data.tar.gz: 280785fdcf6473be2aa73343885735babee8997603ad44e923bb114e7c0a36a7c0228221c2e94ab87cb4c032fbd835eb970a410e920948ea27f1b9d25f6bec02
|
data/README.md
CHANGED
|
@@ -11,14 +11,14 @@ any Ruby project. Currently, the only tested path is Rails with Devise.
|
|
|
11
11
|
Add this line to your application's Gemfile:
|
|
12
12
|
|
|
13
13
|
```ruby
|
|
14
|
-
gem 'wcc-auth', '~> 0.3.
|
|
14
|
+
gem 'wcc-auth', '~> 0.3.2'
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
If you are using a Rails app with Devise you can use a special require
|
|
18
18
|
hook that will setup all the Devise specific configuration for you.
|
|
19
19
|
|
|
20
20
|
```ruby
|
|
21
|
-
gem 'wcc-auth', '~> 0.3.
|
|
21
|
+
gem 'wcc-auth', '~> 0.3.2', require: 'wcc/auth/devise'
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Configuration
|
|
@@ -54,6 +54,7 @@ end
|
|
|
54
54
|
```ruby
|
|
55
55
|
class User < ActiveRecord::Base
|
|
56
56
|
include WCC::Auth::Providers::ActiveRecord
|
|
57
|
+
devise :omniauthable
|
|
57
58
|
|
|
58
59
|
# ...
|
|
59
60
|
|
|
@@ -17,10 +17,10 @@ module WCC::Auth
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def self.[](index_or_slug, db=ACCESS_LEVELS)
|
|
20
|
-
all(db).
|
|
20
|
+
all(db).find do |al|
|
|
21
21
|
al.level.to_s === index_or_slug.to_s ||
|
|
22
22
|
al.slug === index_or_slug.to_s
|
|
23
|
-
end
|
|
23
|
+
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def self.all(db=ACCESS_LEVELS)
|
data/lib/wcc/auth/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wcc-auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Travis Petticrew
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cancancan
|
|
@@ -158,45 +158,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
158
158
|
version: '0'
|
|
159
159
|
requirements: []
|
|
160
160
|
rubyforge_project:
|
|
161
|
-
rubygems_version: 2.
|
|
161
|
+
rubygems_version: 2.4.2
|
|
162
162
|
signing_key:
|
|
163
163
|
specification_version: 4
|
|
164
|
-
summary:
|
|
165
|
-
Watermark'
|
|
164
|
+
summary: "# WCC::Auth Provides the necessary tools for handling authentication through
|
|
165
|
+
Watermark's OAuth provider as well as authorizing the user has access to specific
|
|
166
166
|
features within the application. There are special hooks for Rails apps using Devise,
|
|
167
167
|
but the primitive structures could be used on any Ruby project. Currently, the only
|
|
168
|
-
tested path is Rails with Devise. ## Installation Add this line to your application'
|
|
169
|
-
Gemfile: ```ruby gem '
|
|
170
|
-
|
|
171
|
-
configuration for you. ```ruby gem '
|
|
168
|
+
tested path is Rails with Devise. ## Installation Add this line to your application's
|
|
169
|
+
Gemfile: ```ruby gem 'wcc-auth', '~> 0.3.2' ``` If you are using a Rails app with
|
|
170
|
+
Devise you can use a special require hook that will setup all the Devise specific
|
|
171
|
+
configuration for you. ```ruby gem 'wcc-auth', '~> 0.3.2', require: 'wcc/auth/devise'
|
|
172
172
|
``` ## Configuration There are a few steps to setup your app. These instructions
|
|
173
|
-
are specific to a Rails app. #### Add the configuration block to an initializer
|
|
174
|
-
order to configure the gem you must run the `WCC::Auth.setup` block. See below
|
|
175
|
-
an example: ```ruby WCC::Auth.setup do |config| config.app_name = "app-name"
|
|
176
|
-
= Rails.env config.app_id = '
|
|
177
|
-
= '
|
|
178
|
-
# Add this include to your ApplicationController class
|
|
179
|
-
include WCC::Auth::ControllerHelpers
|
|
180
|
-
class User < ActiveRecord::Base include
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
are specific to a Rails app. #### Add the configuration block to an initializer
|
|
174
|
+
\ In order to configure the gem you must run the `WCC::Auth.setup` block. See below
|
|
175
|
+
for an example: ```ruby WCC::Auth.setup do |config| config.app_name = \"app-name\"
|
|
176
|
+
config.environment = Rails.env config.app_id = 'app-client-id-from-oauth-provider'
|
|
177
|
+
config.app_secret = 'app-client-secret-from-oauth-provider' end ``` #### Setup
|
|
178
|
+
your controllers ```ruby # Add this include to your ApplicationController class
|
|
179
|
+
ApplicationController < ActionController::Base include WCC::Auth::ControllerHelpers
|
|
180
|
+
end ``` #### Setup your user model ```ruby class User < ActiveRecord::Base include
|
|
181
|
+
WCC::Auth::Providers::ActiveRecord devise :omniauthable # ... end ``` #### Setup
|
|
182
|
+
authorization (optional) If you would like to use the `TieredAbility` class included
|
|
183
|
+
with `WCC::Auth` just create an Ability class that extends the `WCC::Auth::TieredAbility`
|
|
183
184
|
class. The authenticated user will include an info variables called `access_level_id`.
|
|
184
185
|
This corresponds to a `WCC::Auth::AccessLevel`. The access levels are broken down
|
|
185
186
|
into 5 tiers with the following rules: * **No access** -- This is the default level
|
|
186
187
|
* **Basic** -- This is provides read-only access * **Contribute** -- Read-write
|
|
187
|
-
for only data the user owns * **Manage** -- Read-write for other'
|
|
188
|
+
for only data the user owns * **Manage** -- Read-write for other's data * **App
|
|
188
189
|
Admin** -- Can change app configuration * **System Admin** -- Has full access to
|
|
189
190
|
all features always Each tier inherits all priveleges of the lower tiers. The rules
|
|
190
191
|
here are guidelines for the app to follow. It is ultimately up to the client application
|
|
191
192
|
to decide what each of these tiers means for it. Do your best to adhere to these
|
|
192
|
-
rules. Here is an example Ability class using the DSL provided by `WCC::Auth`.
|
|
193
|
-
class Ability < WCC::Auth::TieredAbility at_level(:contribute) do |user|
|
|
194
|
-
Person can :manage, Task, created_by_id: user.id can :manage, Comment,
|
|
195
|
-
user.id cannot :destroy, Task end at_level(:appadmin) do |user|
|
|
196
|
-
cannot :create, TaskGroup end at_level(:sysadmin) do |user|
|
|
197
|
-
end end ``` ## Contributing 1. Fork it 2. Create your feature
|
|
198
|
-
-b my-new-feature`) 3. Commit your changes (`git commit -am
|
|
199
|
-
4. Push to the branch (`git push origin my-new-feature`) 5.
|
|
193
|
+
rules. Here is an example Ability class using the DSL provided by `WCC::Auth`.
|
|
194
|
+
\ ```ruby class Ability < WCC::Auth::TieredAbility at_level(:contribute) do |user|
|
|
195
|
+
can :read, Person can :manage, Task, created_by_id: user.id can :manage, Comment,
|
|
196
|
+
created_by_id: user.id cannot :destroy, Task end at_level(:appadmin) do |user|
|
|
197
|
+
can :manage, :all cannot :create, TaskGroup end at_level(:sysadmin) do |user|
|
|
198
|
+
can :manage, :all end end ``` ## Contributing 1. Fork it 2. Create your feature
|
|
199
|
+
branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am
|
|
200
|
+
'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5.
|
|
201
|
+
Create new Pull Request"
|
|
200
202
|
test_files:
|
|
201
203
|
- spec/spec_helper.rb
|
|
202
204
|
- spec/wcc/auth/access_level_spec.rb
|