omniauth_configure 0.1.0 → 0.2.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDljYTI3MmY5YWRjOTAzMTRkNWFjZmNlNDZiM2E0Zjk5Y2JhOWYyNQ==
5
+ data.tar.gz: !binary |-
6
+ NTM5ZTA5Yjk3ZTQ1MTNiYTQ1YWJkMjFkZTlhMzgwMDMzM2I4MGI1NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDA4OTllNTUwNjQwYWVkMmUzZWVkMGNmOWYwMDkyZGViNmI2NjY0Yzc3MjA1
10
+ NWUwZTlhZjk3OGMxMmQwYjJhZjE4YjQ1YjExZTg1NjQ2OWVlMWI4Mjc2Zjg0
11
+ YTM5MjVmMmViNTBiNmY3ZmM1MDRmOTZmZDJlODgxZWRkMjVhOWE=
12
+ data.tar.gz: !binary |-
13
+ YjJmNzMzODZmMTAzYzlkYzJlYTU5MzBiM2U1MGMyZTBiY2NjNjAxOTIyYzJm
14
+ ODNjYWZkOGQ4MTE1NDc3ZjY5YWQ4YzVkYmI1ZDA0NTMyYWM2ZTFmM2QyMTZl
15
+ NjNjZDMzYzA5MDZlNmRiYTM5NzA2MjkyMzkzZmE2YzdiYWMwOTY=
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## 0.2.0
2
+
3
+ * Use all configuration options when configuring a strategy instead of
4
+ only client_id, client_secret, and specific client_options.
5
+
6
+ ## 0.1.0
7
+
8
+ * Allow omniauth to be configured through a centralized file on the server.
9
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # OmnAuth Configure
1
+ # OmniAuth Configure
2
2
 
3
3
  Centralize OmniAuth strategy configurations on the server. This has a couple
4
4
  advantages over storing configuration details (e.g. client secret and urls) in
@@ -11,27 +11,35 @@ source control or the environment for the user running the application server.
11
11
 
12
12
  1. Add the `omniauth_configure` gem to the Gemfile
13
13
 
14
- ## Congiguration
14
+ ## Configuration
15
+
16
+ A configuration contains details about applications and strategies which
17
+ use omniauth. Applications are top level keys (e.g. nucats_assist, nitro)
18
+ with the exception of the 'defaults'. The 'defaults' top level key is used to
19
+ keep global options for strategies. When a strategy is configured on a per
20
+ application level, the default options for that strategy are inherited first
21
+ and the application specific strategy options are applied on top of them.
15
22
 
16
23
  ```
17
24
  # /etc/nubic/omniauth/local.yml
18
25
 
19
26
  defaults:
20
27
  nucats_membership:
21
- site: http://membership-staging.nubic.northwestern.edu
22
- authorize_url: /auth
23
- token_url: /token
28
+ client_options:
29
+ site: http://membership-staging.nubic.northwestern.edu
30
+ authorize_url: /auth
31
+ token_url: /token
24
32
  nucats_assist:
25
33
  nucats_membership:
26
34
  client_id: abc123
27
35
  client_secret: def456
28
- facebok:
36
+ facebook:
29
37
  client_id: asdf213
30
38
  client_secret: jimbo
31
39
  nitro:
32
40
  nucats_membership:
33
41
  client_id: xyz987
34
- client_secret:ufw654
42
+ client_secret: ufw654
35
43
  ```
36
44
 
37
45
  ## Rack
@@ -40,7 +48,7 @@ nitro:
40
48
  # server.ru
41
49
 
42
50
  OmniauthConfigure.configure {
43
- app :example
51
+ app :nucats_assist
44
52
  strategies :nucats_membership
45
53
  central '/etc/nubic/omniauth/local.yml'
46
54
  }
@@ -54,8 +62,12 @@ OmniauthConfigure::Rack.use_in(self)
54
62
  # config/environments/development.rb
55
63
 
56
64
  OmniAuthConfigure.configure {
57
- app :example
65
+ app :nucats_assist
58
66
  strategies :nucats_membership
59
67
  central '/etc/nubic/omniauth/local.yml'
60
68
  }
61
69
  ```
70
+
71
+ For Devise configuration see the [Devise wiki page about omniauth](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview)
72
+
73
+
@@ -1,5 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'yaml'
3
+ require 'active_support'
3
4
 
4
5
  module OmniAuthConfigure
5
6
  class CentralParameters
@@ -23,9 +24,9 @@ module OmniAuthConfigure
23
24
  unless entries.key?(app)
24
25
  entries[app] = {}
25
26
  entries[app][provider] =
26
- {}.merge((raw_values[:default] || {})[provider] || {}).
27
- merge((raw_values[:defaults] || {})[provider] || {}).
28
- merge((raw_values[app] || {})[provider] || {})
27
+ {}.deep_merge((raw_values[:default] || {})[provider] || {}).
28
+ deep_merge((raw_values[:defaults] || {})[provider] || {}).
29
+ deep_merge((raw_values[app] || {})[provider] || {})
29
30
  end
30
31
  entries[app][provider]
31
32
  end
@@ -23,19 +23,11 @@ module OmniAuthConfigure::Rack
23
23
 
24
24
  p = effective_configuration.parameters_for(app, klass)
25
25
 
26
- middleware.args [:client_id, :client_secret]
26
+ arg_keys = p.keys.sort
27
27
 
28
- cid = p[:client_id]
29
- cs = p[:client_secret]
30
- s = p[:site]
31
- au = p[:authorize_url]
32
- tu = p[:token_url]
28
+ middleware.args arg_keys
33
29
 
34
- args = [cid, cs]
35
- if s || au || tu
36
- middleware.args [:client_id, :client_secret, :client_options]
37
- args << {:site => s, :authorize_url => au, :token_url => tu }
38
- end
30
+ args = p.values_at(*arg_keys)
39
31
  args << {} # Last argument to provider strategy is empty hash
40
32
 
41
33
  builder.use middleware, *args, &block
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module OmniAuthConfigure
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -16,5 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.add_runtime_dependency 'omniauth', '~> 1.2'
17
17
  s.add_development_dependency 'rspec'
18
18
  s.add_development_dependency 'rake'
19
+ s.add_runtime_dependency 'activesupport'
19
20
  end
20
21
 
@@ -22,7 +22,7 @@ describe OmniAuthConfigure::Configuration do
22
22
  end
23
23
 
24
24
  it 'aquires the default parameters' do
25
- expect(northwestern[:site]).to eq('http://northwestern.edu')
25
+ expect(northwestern[:client_options][:site]).to eq('http://northwestern.edu')
26
26
  end
27
27
 
28
28
  it 'aquires the parameters' do
@@ -31,7 +31,7 @@ describe OmniAuthConfigure::Configuration do
31
31
  end
32
32
 
33
33
  it 'aquires the overridden parameters' do
34
- expect(northwestern[:token_url]).to eq('/override/token')
34
+ expect(northwestern[:client_options][:token_url]).to eq('/override/token')
35
35
  end
36
36
  end
37
37
 
@@ -23,7 +23,7 @@ describe OmniAuthConfigure::Rack do
23
23
 
24
24
  OmniAuthConfigure::Rack.use_in(builder)
25
25
  expect(builder.uses[0].first).to eq(OmniAuth::Strategies::Northwestern)
26
- expect(builder.uses[0].first.args).to eq([:client_id, :client_secret, :client_options])
26
+ expect(builder.uses[0].first.args).to eq([:client_id, :client_options, :client_secret])
27
27
 
28
28
  expect(builder.uses[1].first).to eq(OmniAuth::Strategies::Facebook)
29
29
  expect(builder.uses[1].first.args).to eq([:client_id, :client_secret])
@@ -1,13 +1,15 @@
1
1
  defaults:
2
2
  northwestern:
3
- site: http://northwestern.edu
4
- authorize_url: /oauth/auth
5
- token_url: /oauth/token
3
+ client_options:
4
+ site: http://northwestern.edu
5
+ authorize_url: /oauth/auth
6
+ token_url: /oauth/token
6
7
  patient_tracker:
7
8
  northwestern:
8
9
  client_id: c1980
9
10
  client_secret: kareem
10
- token_url: /override/token
11
+ client_options:
12
+ token_url: /override/token
11
13
  facebook:
12
14
  client_id: c1995
13
15
  client_secret: seagal
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth_configure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Dzak
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,20 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
66
  - - ! '>='
60
67
  - !ruby/object:Gem::Version
@@ -66,6 +73,7 @@ extensions: []
66
73
  extra_rdoc_files: []
67
74
  files:
68
75
  - .gitignore
76
+ - CHANGELOG.md
69
77
  - Gemfile
70
78
  - README.md
71
79
  - Rakefile
@@ -82,32 +90,25 @@ files:
82
90
  - spec/spec_helper.rb
83
91
  homepage:
84
92
  licenses: []
93
+ metadata: {}
85
94
  post_install_message:
86
95
  rdoc_options: []
87
96
  require_paths:
88
97
  - lib
89
98
  required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
99
  requirements:
92
100
  - - ! '>='
93
101
  - !ruby/object:Gem::Version
94
102
  version: '0'
95
- segments:
96
- - 0
97
- hash: -1431042663031854455
98
103
  required_rubygems_version: !ruby/object:Gem::Requirement
99
- none: false
100
104
  requirements:
101
105
  - - ! '>='
102
106
  - !ruby/object:Gem::Version
103
107
  version: '0'
104
- segments:
105
- - 0
106
- hash: -1431042663031854455
107
108
  requirements: []
108
109
  rubyforge_project:
109
- rubygems_version: 1.8.25
110
+ rubygems_version: 2.2.2
110
111
  signing_key:
111
- specification_version: 3
112
+ specification_version: 4
112
113
  summary: Allows centralized OmniAuth strategy configurations
113
114
  test_files: []