omniauth 1.2.2 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of omniauth might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +43 -55
- data/.travis.yml +16 -28
- data/Gemfile +13 -19
- data/LICENSE.md +1 -1
- data/README.md +71 -20
- data/Rakefile +38 -2
- data/lib/omniauth/auth_hash.rb +7 -8
- data/lib/omniauth/builder.rb +3 -17
- data/lib/omniauth/failure_endpoint.rb +4 -2
- data/lib/omniauth/form.css +1 -1
- data/lib/omniauth/form.rb +2 -1
- data/lib/omniauth/key_store.rb +22 -0
- data/lib/omniauth/strategies/developer.rb +2 -2
- data/lib/omniauth/strategy.rb +72 -50
- data/lib/omniauth/test/strategy_test_case.rb +2 -2
- data/lib/omniauth/version.rb +1 -1
- data/lib/omniauth.rb +13 -17
- data/omniauth.gemspec +10 -8
- metadata +36 -41
- data/.gemtest +0 -0
- data/Gemfile.rack-1.3.x +0 -25
- data/Guardfile +0 -10
- data/spec/helper.rb +0 -55
- data/spec/omniauth/auth_hash_spec.rb +0 -111
- data/spec/omniauth/builder_spec.rb +0 -50
- data/spec/omniauth/failure_endpoint_spec.rb +0 -58
- data/spec/omniauth/form_spec.rb +0 -23
- data/spec/omniauth/strategies/developer_spec.rb +0 -73
- data/spec/omniauth/strategy_spec.rb +0 -768
- data/spec/omniauth_spec.rb +0 -145
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35d19268ad77477704f29c8bb7aa989bc4fd087dfc75cad3757f0dba77615ab0
|
4
|
+
data.tar.gz: 7d6405feca4e14d010330e2c577aa815b7593de7ebc2591e9b45c266af3e05b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f0a59be54f42f5c6747e9601599eee747d0220c8cfbfd3037e713840453c29598b325beae1e0ca8c41db8581d02cd1adada18d1dcfb5afe8cab2fb8c5c7e61
|
7
|
+
data.tar.gz: 945998eec68b09718830c23c75ca2cd1ad23da58f9541d38c39ec0c4c08b587cb35827390a003c3c1fb551793d2b5a1ade0cf354236035c6489b229fa66a699f
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Please complete all sections.
|
2
|
+
|
3
|
+
### Configuration
|
4
|
+
|
5
|
+
- Provider Gem: `omniauth-*`
|
6
|
+
- Ruby Version: ``
|
7
|
+
- Framework: ``
|
8
|
+
- Platform: ``
|
9
|
+
|
10
|
+
### Expected Behavior
|
11
|
+
|
12
|
+
Tell us what should happen.
|
13
|
+
|
14
|
+
### Actual Behavior
|
15
|
+
|
16
|
+
Tell us what happens instead.
|
17
|
+
|
18
|
+
### Steps to Reproduce
|
19
|
+
|
20
|
+
Please list all steps to reproduce the issue.
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,81 +1,69 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
3
|
-
- 'Gemfile'
|
4
|
-
- 'Rakefile'
|
5
|
-
- 'omniauth.gemspec'
|
2
|
+
TargetRubyVersion: 2.2
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
Max: 4
|
10
|
-
CountKeywordArgs: true
|
4
|
+
Layout/AccessModifierIndentation:
|
5
|
+
EnforcedStyle: outdent
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
Max: 15
|
7
|
+
Layout/AlignHash:
|
8
|
+
Enabled: false
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
Max: 2
|
10
|
+
Layout/DotPosition:
|
11
|
+
EnforcedStyle: trailing
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
PreferredMethods:
|
23
|
-
map: 'collect'
|
24
|
-
reduce: 'inject'
|
25
|
-
find: 'detect'
|
26
|
-
find_all: 'select'
|
13
|
+
Layout/SpaceInsideHashLiteralBraces:
|
14
|
+
EnforcedStyle: no_space
|
27
15
|
|
28
|
-
|
29
|
-
LineLength:
|
16
|
+
Lint/HandleExceptions:
|
30
17
|
Enabled: false
|
31
18
|
|
32
|
-
|
33
|
-
Documentation:
|
19
|
+
Metrics/BlockLength:
|
34
20
|
Enabled: false
|
35
21
|
|
36
|
-
|
37
|
-
|
38
|
-
EnforcedStyle: hash_rockets
|
39
|
-
|
40
|
-
# No spaces inside hash literals
|
41
|
-
SpaceInsideHashLiteralBraces:
|
42
|
-
EnforcedStyle: no_space
|
22
|
+
Metrics/BlockNesting:
|
23
|
+
Max: 2
|
43
24
|
|
44
|
-
|
45
|
-
|
25
|
+
Metrics/LineLength:
|
26
|
+
AllowURI: true
|
46
27
|
Enabled: false
|
47
28
|
|
48
|
-
|
49
|
-
|
50
|
-
|
29
|
+
Metrics/MethodLength:
|
30
|
+
CountComments: false
|
31
|
+
Max: 15
|
51
32
|
|
52
|
-
|
53
|
-
|
54
|
-
|
33
|
+
Metrics/ParameterLists:
|
34
|
+
Max: 4
|
35
|
+
CountKeywordArgs: true
|
55
36
|
|
56
|
-
|
57
|
-
Enabled:
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Enabled: false
|
58
39
|
|
59
|
-
|
60
|
-
|
61
|
-
|
40
|
+
Style/CollectionMethods:
|
41
|
+
PreferredMethods:
|
42
|
+
map: 'collect'
|
43
|
+
reduce: 'inject'
|
44
|
+
find: 'detect'
|
45
|
+
find_all: 'select'
|
62
46
|
|
63
|
-
|
64
|
-
|
65
|
-
IndentWhenRelativeTo: end
|
66
|
-
IndentOneStep: false
|
47
|
+
Style/Documentation:
|
48
|
+
Enabled: false
|
67
49
|
|
68
|
-
|
50
|
+
Style/DoubleNegation:
|
69
51
|
Enabled: false
|
70
52
|
|
71
|
-
|
53
|
+
Style/EachWithObject:
|
72
54
|
Enabled: false
|
73
55
|
|
74
|
-
|
75
|
-
|
56
|
+
Style/Encoding:
|
57
|
+
Enabled: false
|
76
58
|
|
77
|
-
|
59
|
+
Style/ExpandPathArguments:
|
78
60
|
Enabled: false
|
79
61
|
|
80
|
-
|
62
|
+
Style/HashSyntax:
|
63
|
+
EnforcedStyle: hash_rockets
|
64
|
+
|
65
|
+
Style/Lambda:
|
81
66
|
Enabled: false
|
67
|
+
|
68
|
+
Style/RaiseArgs:
|
69
|
+
EnforcedStyle: compact
|
data/.travis.yml
CHANGED
@@ -1,37 +1,25 @@
|
|
1
1
|
bundler_args: --without development
|
2
|
-
|
3
|
-
-
|
4
|
-
-
|
2
|
+
before_install:
|
3
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
4
|
+
- gem install bundler -v '1.17.3'
|
5
|
+
install:
|
6
|
+
- bundle _1.17.3_ install --jobs=3 --retry=3
|
7
|
+
cache: bundler
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
5
11
|
language: ruby
|
6
12
|
rvm:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
-
|
13
|
+
- jruby-9000
|
14
|
+
- 2.2.9
|
15
|
+
- 2.3.5
|
16
|
+
- 2.4.4
|
17
|
+
- 2.5.3
|
18
|
+
- jruby-head
|
13
19
|
- ruby-head
|
14
20
|
matrix:
|
15
|
-
include:
|
16
|
-
- rvm: jruby-18mode
|
17
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
18
|
-
gemfile: Gemfile
|
19
|
-
- rvm: jruby-18mode
|
20
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
21
|
-
gemfile: Gemfile.rack-1.3.x
|
22
|
-
- rvm: jruby-19mode
|
23
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
24
|
-
gemfile: Gemfile
|
25
|
-
- rvm: jruby-19mode
|
26
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
27
|
-
gemfile: Gemfile.rack-1.3.x
|
28
|
-
- rvm: jruby-head
|
29
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
30
|
-
gemfile: Gemfile
|
31
|
-
- rvm: jruby-head
|
32
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
33
|
-
gemfile: Gemfile.rack-1.3.x
|
34
21
|
allow_failures:
|
35
22
|
- rvm: jruby-head
|
36
23
|
- rvm: ruby-head
|
37
24
|
fast_finish: true
|
25
|
+
sudo: false
|
data/Gemfile
CHANGED
@@ -1,33 +1,27 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'jruby-openssl', :platforms => :jruby
|
4
|
-
gem 'rake'
|
5
|
-
gem 'yard'
|
3
|
+
gem 'jruby-openssl', '~> 0.9.19', :platforms => :jruby
|
4
|
+
gem 'rake', '>= 12.0'
|
5
|
+
gem 'yard', '>= 0.9.11'
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem '
|
9
|
-
platforms :ruby_19, :ruby_20 do
|
10
|
-
gem 'guard'
|
11
|
-
gem 'guard-bundler'
|
12
|
-
gem 'guard-rspec'
|
13
|
-
end
|
8
|
+
gem 'benchmark-ips'
|
14
9
|
gem 'kramdown'
|
15
|
-
gem '
|
10
|
+
gem 'memory_profiler'
|
16
11
|
gem 'pry'
|
17
|
-
gem 'pry-debugger', :platforms => [:mri_19, :mri_20]
|
18
|
-
gem 'pry-byebug', :platforms => [:mri_21]
|
19
|
-
gem 'rb-fsevent'
|
20
12
|
end
|
21
13
|
|
22
14
|
group :test do
|
23
15
|
gem 'coveralls', :require => false
|
24
|
-
gem '
|
25
|
-
gem '
|
16
|
+
gem 'hashie', '>= 3.4.6', '~> 4.0.0', :platforms => [:jruby_18]
|
17
|
+
gem 'json', '~> 2.0.3', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
18
|
+
gem 'mime-types', '~> 3.1', :platforms => [:jruby_18]
|
19
|
+
gem 'rack', '>= 2.0.6', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
|
26
20
|
gem 'rack-test'
|
27
|
-
gem 'rest-client', '~>
|
28
|
-
gem 'rspec', '~> 3.0'
|
29
|
-
gem 'rubocop', '>= 0.
|
30
|
-
gem '
|
21
|
+
gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
|
22
|
+
gem 'rspec', '~> 3.5.0'
|
23
|
+
gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
24
|
+
gem 'tins', '~> 1.13.0', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
31
25
|
end
|
32
26
|
|
33
27
|
gemspec
|
data/LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2017 Michael Bleigh and Intridea, Inc.
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,22 +1,15 @@
|
|
1
1
|
# OmniAuth: Standardized Multi-Provider Authentication
|
2
2
|
|
3
3
|
[![Gem Version](http://img.shields.io/gem/v/omniauth.svg)][gem]
|
4
|
-
[![Build Status](http://img.shields.io/travis/
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
8
|
-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/intridea/omniauth/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
4
|
+
[![Build Status](http://img.shields.io/travis/omniauth/omniauth.svg)][travis]
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/omniauth/omniauth.svg)][codeclimate]
|
6
|
+
[![Coverage Status](http://img.shields.io/coveralls/omniauth/omniauth.svg)][coveralls]
|
7
|
+
[![Security](https://hakiri.io/github/omniauth/omniauth/master.svg)](https://hakiri.io/github/omniauth/omniauth/master)
|
9
8
|
|
10
9
|
[gem]: https://rubygems.org/gems/omniauth
|
11
|
-
[travis]: http://travis-ci.org/
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[coveralls]: https://coveralls.io/r/intridea/omniauth
|
15
|
-
|
16
|
-
**OmniAuth 1.0 has several breaking changes from version 0.x. You can set
|
17
|
-
the dependency to `~> 0.3.2` if you do not wish to make the more difficult
|
18
|
-
upgrade. See [the wiki](https://github.com/intridea/omniauth/wiki/Upgrading-to-1.0)
|
19
|
-
for more information.**
|
10
|
+
[travis]: http://travis-ci.org/omniauth/omniauth
|
11
|
+
[codeclimate]: https://codeclimate.com/github/omniauth/omniauth
|
12
|
+
[coveralls]: https://coveralls.io/r/omniauth/omniauth
|
20
13
|
|
21
14
|
## An Introduction
|
22
15
|
OmniAuth is a library that standardizes multi-provider authentication for
|
@@ -27,7 +20,7 @@ have been created for everything from Facebook to LDAP.
|
|
27
20
|
|
28
21
|
In order to use OmniAuth in your applications, you will need to leverage
|
29
22
|
one or more strategies. These strategies are generally released
|
30
|
-
individually as RubyGems, and you can see a [community maintained list](https://github.com/
|
23
|
+
individually as RubyGems, and you can see a [community maintained list](https://github.com/omniauth/omniauth/wiki/List-of-Strategies)
|
31
24
|
on the wiki for this project.
|
32
25
|
|
33
26
|
One strategy, called `Developer`, is included with OmniAuth and provides
|
@@ -120,13 +113,71 @@ Authentication Hash which will contain information about the just
|
|
120
113
|
authenticated user including a unique id, the strategy they just used
|
121
114
|
for authentication, and personal details such as name and email address
|
122
115
|
as available. For an in-depth description of what the authentication
|
123
|
-
hash might contain, see the [Auth Hash Schema wiki page](https://github.com/
|
116
|
+
hash might contain, see the [Auth Hash Schema wiki page](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema).
|
124
117
|
|
125
118
|
Note that OmniAuth does not perform any actions beyond setting some
|
126
119
|
environment information on the callback request. It is entirely up to
|
127
120
|
you how you want to implement the particulars of your application's
|
128
121
|
authentication flow.
|
129
122
|
|
123
|
+
**Please note:** there is currently a CSRF vulnerability which affects OmniAuth (designated [CVE-2015-9284](https://nvd.nist.gov/vuln/detail/CVE-2015-9284)) that requires mitigation at the application level. More details on how to do this can be found on the [Wiki](https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284).
|
124
|
+
|
125
|
+
## Configuring The `origin` Param
|
126
|
+
The `origin` url parameter is typically used to inform where a user came from and where, should you choose to use it, they'd want to return to.
|
127
|
+
|
128
|
+
There are three possible options:
|
129
|
+
|
130
|
+
Default Flow:
|
131
|
+
```ruby
|
132
|
+
# /auth/twitter/?origin=[URL]
|
133
|
+
# No change
|
134
|
+
# If blank, `omniauth.origin` is set to HTTP_REFERER
|
135
|
+
```
|
136
|
+
|
137
|
+
Renaming Origin Param:
|
138
|
+
```ruby
|
139
|
+
# /auth/twitter/?return_to=[URL]
|
140
|
+
# If blank, `omniauth.origin` is set to HTTP_REFERER
|
141
|
+
provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: 'return_to'
|
142
|
+
```
|
143
|
+
|
144
|
+
Disabling Origin Param:
|
145
|
+
```ruby
|
146
|
+
# /auth/twitter
|
147
|
+
# Origin handled externally, if need be. `omniauth.origin` is not set
|
148
|
+
provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: false
|
149
|
+
```
|
150
|
+
|
151
|
+
## Integrating OmniAuth Into Your Rails API
|
152
|
+
The following middleware are (by default) included for session management in
|
153
|
+
Rails applications. When using OmniAuth with a Rails API, you'll need to add
|
154
|
+
one of these required middleware back in:
|
155
|
+
|
156
|
+
- `ActionDispatch::Session::CacheStore`
|
157
|
+
- `ActionDispatch::Session::CookieStore`
|
158
|
+
- `ActionDispatch::Session::MemCacheStore`
|
159
|
+
|
160
|
+
The trick to adding these back in is that, by default, they are passed
|
161
|
+
`session_options` when added (including the session key), so you can't just add
|
162
|
+
a `session_store.rb` initializer, add `use ActionDispatch::Session::CookieStore`
|
163
|
+
and have sessions functioning as normal.
|
164
|
+
|
165
|
+
To be clear: sessions may work, but your session options will be ignored
|
166
|
+
(i.e the session key will default to `_session_id`). Instead of the
|
167
|
+
initializer, you'll have to set the relevant options somewhere
|
168
|
+
before your middleware is built (like `application.rb`) and pass them to your
|
169
|
+
preferred middleware, like this:
|
170
|
+
|
171
|
+
**application.rb:**
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
config.session_store :cookie_store, key: '_interslice_session'
|
175
|
+
config.middleware.use ActionDispatch::Cookies # Required for all session management
|
176
|
+
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
|
177
|
+
```
|
178
|
+
|
179
|
+
(Thanks @mltsy)
|
180
|
+
|
130
181
|
## Logging
|
131
182
|
OmniAuth supports a configurable logger. By default, OmniAuth will log
|
132
183
|
to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
|
@@ -137,13 +188,13 @@ OmniAuth.config.logger = Rails.logger
|
|
137
188
|
```
|
138
189
|
|
139
190
|
## Resources
|
140
|
-
The [OmniAuth Wiki](https://github.com/
|
191
|
+
The [OmniAuth Wiki](https://github.com/omniauth/omniauth/wiki) has
|
141
192
|
actively maintained in-depth documentation for OmniAuth. It should be
|
142
193
|
your first stop if you are wondering about a more in-depth look at
|
143
194
|
OmniAuth, how it works, and how to use it.
|
144
195
|
|
145
196
|
## Supported Ruby Versions
|
146
|
-
OmniAuth is tested under 1.
|
197
|
+
OmniAuth is tested under 2.1.10, 2.2.6, 2.3.3, 2.4.0, 2.5.0, and JRuby.
|
147
198
|
|
148
199
|
## Versioning
|
149
200
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
@@ -158,10 +209,10 @@ Constraint][pvc] with two digits of precision. For example:
|
|
158
209
|
spec.add_dependency 'omniauth', '~> 1.0'
|
159
210
|
|
160
211
|
[semver]: http://semver.org/
|
161
|
-
[pvc]: http://
|
212
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
162
213
|
|
163
214
|
## License
|
164
|
-
Copyright (c) 2010-
|
215
|
+
Copyright (c) 2010-2017 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
|
165
216
|
details.
|
166
217
|
|
167
218
|
[license]: LICENSE.md
|
data/Rakefile
CHANGED
@@ -10,8 +10,44 @@ begin
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
rescue LoadError
|
12
12
|
task :rubocop do
|
13
|
-
|
13
|
+
warn 'RuboCop is disabled'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
task :default => [
|
17
|
+
task :default => %i[spec rubocop]
|
18
|
+
|
19
|
+
namespace :perf do
|
20
|
+
task :setup do
|
21
|
+
require 'omniauth'
|
22
|
+
require 'rack/test'
|
23
|
+
app = Rack::Builder.new do |b|
|
24
|
+
b.use Rack::Session::Cookie, :secret => 'abc123'
|
25
|
+
b.use OmniAuth::Strategies::Developer
|
26
|
+
b.run lambda { |_env| [200, {}, ['Not Found']] }
|
27
|
+
end.to_app
|
28
|
+
@app = Rack::MockRequest.new(app)
|
29
|
+
|
30
|
+
def call_app(path = ENV['GET_PATH'] || '/')
|
31
|
+
result = @app.get(path)
|
32
|
+
raise "Did not succeed #{result.body}" unless result.status == 200
|
33
|
+
|
34
|
+
result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :ips => :setup do
|
39
|
+
require 'benchmark/ips'
|
40
|
+
Benchmark.ips do |x|
|
41
|
+
x.report('ips') { call_app }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
task :mem => :setup do
|
46
|
+
require 'memory_profiler'
|
47
|
+
num = Integer(ENV['CNT'] || 1)
|
48
|
+
report = MemoryProfiler.report do
|
49
|
+
num.times { call_app }
|
50
|
+
end
|
51
|
+
report.pretty_print
|
52
|
+
end
|
53
|
+
end
|
data/lib/omniauth/auth_hash.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'omniauth/key_store'
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
# The AuthHash is a normalized schema returned by all OmniAuth
|
5
5
|
# strategies. It maps as much user information as the provider
|
6
6
|
# is able to provide into the InfoHash (stored as the `'info'`
|
7
7
|
# key).
|
8
|
-
class AuthHash <
|
8
|
+
class AuthHash < OmniAuth::KeyStore
|
9
9
|
def self.subkey_class
|
10
10
|
Hashie::Mash
|
11
11
|
end
|
@@ -20,13 +20,11 @@ module OmniAuth
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def regular_writer(key, value)
|
23
|
-
if key.to_s == 'info' && !value.is_a?(InfoHash)
|
24
|
-
value = InfoHash.new(value)
|
25
|
-
end
|
23
|
+
value = InfoHash.new(value) if key.to_s == 'info' && value.is_a?(::Hash) && !value.is_a?(InfoHash)
|
26
24
|
super
|
27
25
|
end
|
28
26
|
|
29
|
-
class InfoHash <
|
27
|
+
class InfoHash < OmniAuth::KeyStore
|
30
28
|
def self.subkey_class
|
31
29
|
Hashie::Mash
|
32
30
|
end
|
@@ -36,13 +34,14 @@ module OmniAuth
|
|
36
34
|
return "#{first_name} #{last_name}".strip if first_name? || last_name?
|
37
35
|
return nickname if nickname?
|
38
36
|
return email if email?
|
37
|
+
|
39
38
|
nil
|
40
39
|
end
|
41
40
|
|
42
41
|
def name?
|
43
|
-
!!name
|
42
|
+
!!name
|
44
43
|
end
|
45
|
-
|
44
|
+
alias valid? name?
|
46
45
|
|
47
46
|
def to_hash
|
48
47
|
hash = super
|
data/lib/omniauth/builder.rb
CHANGED
@@ -1,20 +1,5 @@
|
|
1
1
|
module OmniAuth
|
2
2
|
class Builder < ::Rack::Builder
|
3
|
-
def initialize(app, &block)
|
4
|
-
@options = nil
|
5
|
-
if rack14?
|
6
|
-
super
|
7
|
-
else
|
8
|
-
@app = app
|
9
|
-
super(&block)
|
10
|
-
@ins << @app
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def rack14?
|
15
|
-
Rack.release.split('.')[1].to_i >= 4
|
16
|
-
end
|
17
|
-
|
18
3
|
def on_failure(&block)
|
19
4
|
OmniAuth.config.on_failure = block
|
20
5
|
end
|
@@ -36,7 +21,8 @@ module OmniAuth
|
|
36
21
|
end
|
37
22
|
|
38
23
|
def options(options = false)
|
39
|
-
return @options
|
24
|
+
return @options ||= {} if options == false
|
25
|
+
|
40
26
|
@options = options
|
41
27
|
end
|
42
28
|
|
@@ -45,7 +31,7 @@ module OmniAuth
|
|
45
31
|
middleware = klass
|
46
32
|
else
|
47
33
|
begin
|
48
|
-
middleware = OmniAuth::Strategies.const_get(
|
34
|
+
middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s)
|
49
35
|
rescue NameError
|
50
36
|
raise(LoadError.new("Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."))
|
51
37
|
end
|
@@ -22,22 +22,24 @@ module OmniAuth
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def raise_out!
|
25
|
-
|
25
|
+
raise(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type']))
|
26
26
|
end
|
27
27
|
|
28
28
|
def redirect_to_failure
|
29
29
|
message_key = env['omniauth.error.type']
|
30
|
-
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}"
|
30
|
+
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{Rack::Utils.escape(message_key)}#{origin_query_param}#{strategy_name_query_param}"
|
31
31
|
Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish
|
32
32
|
end
|
33
33
|
|
34
34
|
def strategy_name_query_param
|
35
35
|
return '' unless env['omniauth.error.strategy']
|
36
|
+
|
36
37
|
"&strategy=#{env['omniauth.error.strategy'].name}"
|
37
38
|
end
|
38
39
|
|
39
40
|
def origin_query_param
|
40
41
|
return '' unless env['omniauth.origin']
|
42
|
+
|
41
43
|
"&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
|
42
44
|
end
|
43
45
|
end
|
data/lib/omniauth/form.css
CHANGED
data/lib/omniauth/form.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module OmniAuth
|
2
|
-
class Form
|
2
|
+
class Form
|
3
3
|
DEFAULT_CSS = File.read(File.expand_path('../form.css', __FILE__))
|
4
4
|
|
5
5
|
attr_accessor :options
|
@@ -82,6 +82,7 @@ module OmniAuth
|
|
82
82
|
|
83
83
|
def footer
|
84
84
|
return self if @footer
|
85
|
+
|
85
86
|
@html << "\n<button type='submit'>Connect</button>" unless @with_custom_button
|
86
87
|
@html << <<-HTML
|
87
88
|
</form>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
# Generic helper hash that allows method access on deeply nested keys.
|
5
|
+
class KeyStore < ::Hashie::Mash
|
6
|
+
# Disables warnings on Hashie 3.5.0+ for overwritten keys
|
7
|
+
def self.override_logging
|
8
|
+
require 'hashie/version'
|
9
|
+
return unless Gem::Version.new(Hashie::VERSION) >= Gem::Version.new('3.5.0')
|
10
|
+
|
11
|
+
if respond_to?(:disable_warnings)
|
12
|
+
disable_warnings
|
13
|
+
else
|
14
|
+
define_method(:log_built_in_message) { |*| }
|
15
|
+
private :log_built_in_message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Disable on loading of the class
|
20
|
+
override_logging
|
21
|
+
end
|
22
|
+
end
|
@@ -31,13 +31,13 @@ module OmniAuth
|
|
31
31
|
class Developer
|
32
32
|
include OmniAuth::Strategy
|
33
33
|
|
34
|
-
option :fields, [
|
34
|
+
option :fields, %i[name email]
|
35
35
|
option :uid_field, :email
|
36
36
|
|
37
37
|
def request_phase
|
38
38
|
form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path)
|
39
39
|
options.fields.each do |field|
|
40
|
-
form.text_field field.to_s.capitalize.
|
40
|
+
form.text_field field.to_s.capitalize.tr('_', ' '), field.to_s
|
41
41
|
end
|
42
42
|
form.button 'Sign In'
|
43
43
|
form.to_response
|