devise-remote-user 0.4.0 → 0.4.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: 5ea43fa1645bacbef76625f16da7ddb09df554f9
4
- data.tar.gz: 3b45eb2d414829ad1e12a168132437e5085b0e57
3
+ metadata.gz: d130e55069c15e3ae651fbd092c6a18a05c158a4
4
+ data.tar.gz: 9d611dc308392e070c1c787afba128a75744efd2
5
5
  SHA512:
6
- metadata.gz: 0ad42b730848ab59b73bfc1b26ae04c20f43109ca35550565a0f3bec067119310c38693c27e4bcea70dffdb54ec033c9bb67c31ef6dcba2a044d075cd7aff88d
7
- data.tar.gz: 7b988dedda661d1056357674a25adf692025f5796bcdadbd8738239c43902c1b69b439ca90c74d96b7005f5d3f7e3d27f6356610578f6fee9b1a6f01d840c871
6
+ metadata.gz: 63fd339cc6677a7163a6f29a64e7034b0100ad6a4a118a3bc8fd258570ba2c6da0db9c137758ea8441843ce20caea13e2804baaddf1752b4a7d5a85857835c17
7
+ data.tar.gz: 53575355c94a924900b5c706f8aa294cdc2fdf93575eb2865c60ccc44c757232472cc4d995b2aafbf4a1b3de7de0bdc5f409d20375bc2144b22d447cde71dcfa
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem "coveralls", require: false
data/README.md CHANGED
@@ -3,6 +3,11 @@ devise-remote-user
3
3
 
4
4
  A devise extension for remote user authentication.
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/devise-remote-user.svg)](http://badge.fury.io/rb/devise-remote-user)
7
+ [![Build Status](https://travis-ci.org/duke-libraries/devise-remote-user.svg?branch=master)](https://travis-ci.org/duke-libraries/devise-remote-user)
8
+ [![Coverage Status](https://coveralls.io/repos/duke-libraries/devise-remote-user/badge.png?branch=master)](https://coveralls.io/r/duke-libraries/devise-remote-user?branch=master)
9
+ [![Code Climate](https://codeclimate.com/github/duke-libraries/devise-remote-user/badges/gpa.svg)](https://codeclimate.com/github/duke-libraries/devise-remote-user)
10
+
6
11
  ## Installation
7
12
 
8
13
  Add to Gemfile:
@@ -24,7 +29,7 @@ Sorry, there are no generators yet, so ...
24
29
 
25
30
  Configuration options:
26
31
 
27
- - `env_var` - String (default: `'REMOTE_USER'`). Request environment key for the remote user id.
32
+ - `env_key` - String (default: `'REMOTE_USER'`). Request environment key for the remote user id.
28
33
  - `attribute_map` - Hash (default: `{}`). Map of User model attributes to request environment keys for updating the local user when auto-creation is enabled.
29
34
  - `auto_create` - Boolean (default: `false`). Whether to auto-create a local user from the remote user attributes. Note: Also requires adding the Warden callbacks as shown below.
30
35
  - `auto_update` - Boolean (default: `false`). Whether to auto-update authenticated user attributes from remote user attributes.
@@ -1,14 +1,15 @@
1
1
  module DeviseRemoteUser
2
2
 
3
3
  #
4
- # The Manager class is responsible for connecting the appliation's User
4
+ # The Manager class is responsible for connecting the appliation's User
5
5
  # class with remote user information in the request environment.
6
6
  #
7
7
  class Manager
8
8
 
9
- attr_reader :env
10
-
11
- def initialize(env)
9
+ attr_reader :klass, :env
10
+
11
+ def initialize(klass, env)
12
+ @klass = klass
12
13
  @env = env
13
14
  end
14
15
 
@@ -22,13 +23,13 @@ module DeviseRemoteUser
22
23
  end
23
24
 
24
25
  def find_user
25
- User.where(user_criterion).first
26
+ klass.where(user_criterion).first
26
27
  end
27
28
 
28
29
  def create_user
29
30
  random_password = SecureRandom.hex(16)
30
31
  attrs = user_criterion.merge({password: random_password, password_confirmation: random_password})
31
- User.create(attrs)
32
+ klass.create(attrs)
32
33
  end
33
34
 
34
35
  def update_user(user)
@@ -36,7 +37,7 @@ module DeviseRemoteUser
36
37
  end
37
38
 
38
39
  protected
39
-
40
+
40
41
  def remote_user_attributes
41
42
  DeviseRemoteUser.attribute_map.inject({}) { |h, (k, v)| h[k] = env[v] if env.has_key?(v); h }
42
43
  end
@@ -52,7 +53,7 @@ module DeviseRemoteUser
52
53
  def auth_key
53
54
  DeviseRemoteUser.auth_key || Devise.authentication_keys.first
54
55
  end
55
-
56
+
56
57
  end
57
58
 
58
59
  end
@@ -5,13 +5,11 @@ module Devise::Models
5
5
  module RemoteUserAuthenticatable
6
6
  extend ActiveSupport::Concern
7
7
 
8
- module ClassMethods
9
-
10
- def find_for_remote_user_authentication(env)
11
- manager = DeviseRemoteUser::Manager.new(env)
8
+ included do
9
+ def self.find_for_remote_user_authentication(env)
10
+ manager = DeviseRemoteUser::Manager.new(self, env)
12
11
  manager.find_or_create_user
13
12
  end
14
-
15
13
  end
16
14
 
17
15
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseRemoteUser
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
 
3
+ require "coveralls"
4
+ Coveralls.wear!("rails")
5
+
3
6
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
7
  require 'rspec/rails'
5
8
  require 'rspec/autorun'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-remote-user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails