wcc-auth 0.3.2 → 0.3.3

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: b1e50254917d5510fdf6c8faafe55212618eec83
4
- data.tar.gz: c36503c98bdf1a2bfdfc3f71e91ca05082f6dee9
3
+ metadata.gz: 4cfc9a743cd01659828c3d7dc055c27538f67f53
4
+ data.tar.gz: 845b87ff6ac537b3d98d28a5b08899f255801d11
5
5
  SHA512:
6
- metadata.gz: 84de7ee3f83e943439303e7b5991140eddf211e49d11ede4bb4207d6b7824e7b01891a32b167908729e44a9e96a205588337cf0e0b4e8e5976e253977a22a715
7
- data.tar.gz: f0a58d742eadef87c1bd77cb8701759dda8bac0ae5c418c5fe7a46db54d24fe3e2d94f955def564c259b260831fd1dbc5ba171db48c81b8d6905a45bd3b09c35
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.0'
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.0', require: 'wcc/auth/devise'
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
 
@@ -19,6 +19,7 @@ class OmniAuth::Strategies::Watermark < OmniAuth::Strategies::OAuth2
19
19
  last_name: raw_info["last_name"],
20
20
  access_level_id: raw_info["access_level_id"],
21
21
  arena_id: raw_info["arena_id"],
22
+ applications: raw_info["applications"]
22
23
  }
23
24
  end
24
25
 
@@ -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).select do |al|
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.last
23
+ end
24
24
  end
25
25
 
26
26
  def self.all(db=ACCESS_LEVELS)
@@ -1,5 +1,5 @@
1
1
  module WCC
2
2
  module Auth
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
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.2
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: 2014-09-11 00:00:00.000000000 Z
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.2.2
161
+ rubygems_version: 2.4.2
162
162
  signing_key:
163
163
  specification_version: 4
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
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''s
169
- Gemfile: ```ruby gem ''wcc-auth'', ''~> 0.3.0'' ``` If you are using a Rails app
170
- with 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.0'', require: ''wcc/auth/devise''
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 In
174
- order to configure the gem you must run the `WCC::Auth.setup` block. See below for
175
- an example: ```ruby WCC::Auth.setup do |config| config.app_name = "app-name" config.environment
176
- = Rails.env config.app_id = ''app-client-id-from-oauth-provider'' config.app_secret
177
- = ''app-client-secret-from-oauth-provider'' end ``` #### Setup your controllers ```ruby
178
- # Add this include to your ApplicationController class ApplicationController < ActionController::Base
179
- include WCC::Auth::ControllerHelpers end ``` #### Setup your user model ```ruby
180
- class User < ActiveRecord::Base include WCC::Auth::Providers::ActiveRecord # ... end
181
- ``` #### Setup authorization (optional) If you would like to use the `TieredAbility`
182
- class included with `WCC::Auth` just create an Ability class that extends the `WCC::Auth::TieredAbility`
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''s data * **App
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`. ```ruby
193
- class Ability < WCC::Auth::TieredAbility at_level(:contribute) do |user| can :read,
194
- Person can :manage, Task, created_by_id: user.id can :manage, Comment, created_by_id:
195
- user.id cannot :destroy, Task end at_level(:appadmin) do |user| can :manage, :all
196
- cannot :create, TaskGroup end at_level(:sysadmin) do |user| can :manage, :all
197
- end end ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout
198
- -b my-new-feature`) 3. Commit your changes (`git commit -am ''Add some feature''`)
199
- 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request'
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