omniauth 2.0.4 → 2.1.4
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/.github/dependabot.yml +18 -0
- data/.github/workflows/jruby.yml +28 -0
- data/.github/workflows/main.yml +11 -36
- data/.github/workflows/truffle_ruby.yml +24 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -8
- data/README.md +98 -50
- data/SECURITY.md +1 -0
- data/lib/omniauth/builder.rb +6 -3
- data/lib/omniauth/form.rb +2 -1
- data/lib/omniauth/strategies/developer.rb +1 -1
- data/lib/omniauth/strategy.rb +13 -4
- data/lib/omniauth/version.rb +1 -1
- data/lib/omniauth.rb +14 -1
- data/omniauth.gemspec +2 -1
- metadata +22 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6adedf2d934dc7dd0ced2227b34493689ea641352aa48b4951a7bd7eb315ed12
|
|
4
|
+
data.tar.gz: b34447ed4ba1ed3ab8fc22d6a23bf97157fc5a463ede72189af1ac80a39f4328
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 055d23e2630406e528178af7f933662c832c8427df39c8dacc5d7a59a6379657792b29fbdcaf80a6259c65f3d96331c3f2caf0d9710e4bd331bb4355c0e40692
|
|
7
|
+
data.tar.gz: d64fa86620a4f17dfe2a7735ff9600020aa6be03650fdc6b321f470a8c21ee0069ce4735888ee72e55d2b63b45466db1b4c108e8bd7f1969d777eedbc38139ef
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: bundler
|
|
9
|
+
directory: '/'
|
|
10
|
+
schedule:
|
|
11
|
+
interval: weekly
|
|
12
|
+
open-pull-requests-limit: 99
|
|
13
|
+
|
|
14
|
+
- package-ecosystem: github-actions
|
|
15
|
+
directory: '/'
|
|
16
|
+
schedule:
|
|
17
|
+
interval: daily
|
|
18
|
+
open-pull-requests-limit: 99
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: JRuby
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ master ]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ${{ matrix.os }}-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu, macos]
|
|
15
|
+
jruby: [jruby, jruby-head]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: ${{ matrix.jruby }}
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
env:
|
|
24
|
+
JRUBY_OPTS: --debug
|
|
25
|
+
- name: Run tests
|
|
26
|
+
env:
|
|
27
|
+
JRUBY_OPTS: --debug
|
|
28
|
+
run: bundle exec rake
|
data/.github/workflows/main.yml
CHANGED
|
@@ -15,75 +15,50 @@ on:
|
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
17
|
test:
|
|
18
|
-
runs-on:
|
|
18
|
+
runs-on: ${{ matrix.os }}-latest
|
|
19
19
|
strategy:
|
|
20
20
|
fail-fast: false
|
|
21
21
|
matrix:
|
|
22
22
|
os: [ubuntu, macos]
|
|
23
|
-
ruby: [2.5, 2.6, 2.7,
|
|
23
|
+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, head, debug]
|
|
24
|
+
exclude:
|
|
25
|
+
- os: macos
|
|
26
|
+
ruby: 2.5
|
|
24
27
|
steps:
|
|
25
|
-
- uses: actions/checkout@
|
|
28
|
+
- uses: actions/checkout@v3
|
|
26
29
|
- name: Set up Ruby
|
|
27
30
|
uses: ruby/setup-ruby@v1
|
|
28
31
|
with:
|
|
29
32
|
ruby-version: ${{ matrix.ruby }}
|
|
30
33
|
bundler-cache: true
|
|
31
|
-
- name: Install dependencies
|
|
32
|
-
run: bundle install
|
|
33
34
|
- name: Run tests
|
|
34
35
|
run: bundle exec rake
|
|
35
|
-
test-jruby:
|
|
36
|
-
runs-on: ubuntu-18.04
|
|
37
|
-
strategy:
|
|
38
|
-
fail-fast: false
|
|
39
|
-
matrix:
|
|
40
|
-
os: [ubuntu, macos]
|
|
41
|
-
jruby: [jruby] # TODO: Add back jruby-head once we figure out why there's a bundler mismatch
|
|
42
|
-
steps:
|
|
43
|
-
- uses: actions/checkout@v2
|
|
44
|
-
- name: Set up Ruby
|
|
45
|
-
uses: ruby/setup-ruby@v1
|
|
46
|
-
with:
|
|
47
|
-
ruby-version: ${{ matrix.jruby }}
|
|
48
|
-
bundler-cache: true
|
|
49
|
-
- name: Install dependencies
|
|
50
|
-
env:
|
|
51
|
-
JRUBY_OPTS: --debug
|
|
52
|
-
run: bundle install
|
|
53
|
-
- name: Run tests
|
|
54
|
-
env:
|
|
55
|
-
JRUBY_OPTS: --debug
|
|
56
|
-
run: bundle exec rake
|
|
57
36
|
frozen-string-compat:
|
|
58
|
-
runs-on: ubuntu-
|
|
37
|
+
runs-on: ubuntu-latest
|
|
59
38
|
steps:
|
|
60
|
-
- uses: actions/checkout@
|
|
39
|
+
- uses: actions/checkout@v3
|
|
61
40
|
- name: Set up Ruby
|
|
62
41
|
uses: ruby/setup-ruby@v1
|
|
63
42
|
with:
|
|
64
43
|
ruby-version: 2.6
|
|
65
44
|
bundler-cache: true
|
|
66
|
-
- name: Install dependencies
|
|
67
|
-
run: bundle install
|
|
68
45
|
- name: Run tests
|
|
69
46
|
env:
|
|
70
47
|
RUBYOPT: "--enable-frozen-string-literal"
|
|
71
48
|
run: bundle exec rake
|
|
72
49
|
coveralls:
|
|
73
|
-
runs-on: ubuntu-
|
|
50
|
+
runs-on: ubuntu-latest
|
|
74
51
|
steps:
|
|
75
|
-
- uses: actions/checkout@
|
|
52
|
+
- uses: actions/checkout@v3
|
|
76
53
|
- name: Set up Ruby
|
|
77
54
|
uses: ruby/setup-ruby@v1
|
|
78
55
|
with:
|
|
79
56
|
ruby-version: 2.6
|
|
80
57
|
bundler-cache: true
|
|
81
|
-
- name: Install dependencies
|
|
82
|
-
run: bundle install
|
|
83
58
|
- name: Run tests
|
|
84
59
|
run: bundle exec rake
|
|
85
60
|
- name: Coveralls GitHub Action
|
|
86
|
-
uses: coverallsapp/github-action@
|
|
61
|
+
uses: coverallsapp/github-action@v2
|
|
87
62
|
with:
|
|
88
63
|
github-token: ${{ secrets.github_token }}
|
|
89
64
|
path-to-lcov: './coverage/lcov/omniauth.lcov'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: TruffleRuby
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ master ]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ${{ matrix.os }}-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu, macos]
|
|
15
|
+
ruby: [truffleruby, truffleruby-head]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
gem 'jruby-openssl', '~> 0.10.5', :
|
|
3
|
+
gem 'jruby-openssl', '~> 0.10.5', platforms: :jruby
|
|
4
4
|
gem 'rake', '>= 12.0'
|
|
5
5
|
gem 'yard', '>= 0.9.11'
|
|
6
6
|
|
|
@@ -12,18 +12,13 @@ group :development do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
group :test do
|
|
15
|
+
gem 'cgi'
|
|
15
16
|
gem 'coveralls_reborn', '~> 0.19.0', require: false
|
|
16
|
-
gem 'hashie', '>= 3.4.6', '~> 4.0.0', :platforms => [:jruby_18]
|
|
17
|
-
gem 'json', '~> 2.3.0', :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]
|
|
20
17
|
gem 'rack-test'
|
|
21
|
-
gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
|
|
22
18
|
gem 'rspec', '~> 3.5'
|
|
23
19
|
gem 'rack-freeze'
|
|
24
|
-
gem 'rubocop', '>= 0.58.2', '< 0.69.0', :
|
|
20
|
+
gem 'rubocop', '>= 0.58.2', '< 0.69.0', platforms: %i[ruby_22 ruby_23 ruby_24]
|
|
25
21
|
gem 'simplecov-lcov'
|
|
26
|
-
gem 'tins', '~> 1.13', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
gemspec
|
data/README.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# OmniAuth: Standardized Multi-Provider Authentication
|
|
2
2
|
|
|
3
3
|
[][gem]
|
|
4
|
-
[][githubactions]
|
|
5
|
+
[][githubactionstruffle]
|
|
6
|
+
[][githubactionsjruby]
|
|
5
7
|
[][codeclimate]
|
|
6
8
|
[][coveralls]
|
|
7
9
|
|
|
8
10
|
[gem]: https://rubygems.org/gems/omniauth
|
|
9
|
-
[
|
|
11
|
+
[githubactions]: https://github.com/omniauth/omniauth/actions/workflows/main.yml
|
|
12
|
+
[githubactionstruffle]: https://github.com/omniauth/omniauth/actions/workflows/truffle_ruby.yml
|
|
13
|
+
[githubactionsjruby]: https://github.com/omniauth/omniauth/actions/workflows/jruby.yml
|
|
10
14
|
[codeclimate]: https://codeclimate.com/github/omniauth/omniauth
|
|
11
15
|
[coveralls]: https://coveralls.io/r/omniauth/omniauth
|
|
12
16
|
|
|
13
|
-
This is the documentation for the
|
|
17
|
+
This is the documentation for the in-development branch of OmniAuth.
|
|
18
|
+
You can find the documentation for the latest stable release [here](https://github.com/omniauth/omniauth/tree/v2.1.4)
|
|
14
19
|
|
|
15
20
|
## An Introduction
|
|
16
21
|
OmniAuth is a library that standardizes multi-provider authentication for
|
|
@@ -83,34 +88,7 @@ environment of a request to `/auth/:provider/callback`. This hash
|
|
|
83
88
|
contains as much information about the user as OmniAuth was able to
|
|
84
89
|
glean from the utilized strategy. You should set up an endpoint in your
|
|
85
90
|
application that matches to the callback URL and then performs whatever
|
|
86
|
-
steps are necessary for your application.
|
|
87
|
-
you would add a line in your `routes.rb` file like this:
|
|
88
|
-
|
|
89
|
-
```ruby
|
|
90
|
-
post '/auth/:provider/callback', to: 'sessions#create'
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
And you might then have a `SessionsController` with code that looks
|
|
94
|
-
something like this:
|
|
95
|
-
|
|
96
|
-
```ruby
|
|
97
|
-
class SessionsController < ApplicationController
|
|
98
|
-
# If you're using a strategy that POSTs during callback, you'll need to skip the authenticity token check for the callback action only.
|
|
99
|
-
skip_before_action :verify_authenticity_token, only: :create
|
|
100
|
-
|
|
101
|
-
def create
|
|
102
|
-
@user = User.find_or_create_from_auth_hash(auth_hash)
|
|
103
|
-
self.current_user = @user
|
|
104
|
-
redirect_to '/'
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
protected
|
|
108
|
-
|
|
109
|
-
def auth_hash
|
|
110
|
-
request.env['omniauth.auth']
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
```
|
|
91
|
+
steps are necessary for your application.
|
|
114
92
|
|
|
115
93
|
The `omniauth.auth` key in the environment hash provides an
|
|
116
94
|
Authentication Hash which will contain information about the just
|
|
@@ -124,35 +102,74 @@ environment information on the callback request. It is entirely up to
|
|
|
124
102
|
you how you want to implement the particulars of your application's
|
|
125
103
|
authentication flow.
|
|
126
104
|
|
|
127
|
-
|
|
105
|
+
## rack_csrf
|
|
128
106
|
|
|
129
|
-
|
|
130
|
-
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.
|
|
107
|
+
`omniauth` is not OOTB-compatible with [rack_csrf](https://github.com/baldowl/rack_csrf). In order to do so, the following code needs to be added to the application bootstrapping code:
|
|
131
108
|
|
|
132
|
-
|
|
109
|
+
```ruby
|
|
110
|
+
OmniAuth::AuthenticityTokenProtection.default_options(key: "csrf.token", authenticity_param: "_csrf")
|
|
111
|
+
```
|
|
133
112
|
|
|
134
|
-
|
|
113
|
+
## Rails (without Devise)
|
|
114
|
+
To get started, add the following gems
|
|
115
|
+
|
|
116
|
+
**Gemfile**:
|
|
135
117
|
```ruby
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# If blank, `omniauth.origin` is set to HTTP_REFERER
|
|
118
|
+
gem 'omniauth'
|
|
119
|
+
gem "omniauth-rails_csrf_protection"
|
|
139
120
|
```
|
|
140
121
|
|
|
141
|
-
|
|
122
|
+
Then insert OmniAuth as a middleware
|
|
123
|
+
|
|
124
|
+
**config/initializers/omniauth.rb**:
|
|
142
125
|
```ruby
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
|
127
|
+
provider :developer if Rails.env.development?
|
|
128
|
+
end
|
|
146
129
|
```
|
|
147
130
|
|
|
148
|
-
|
|
131
|
+
Additional providers can be added here in the future. Next we wire it
|
|
132
|
+
all up using routes, a controller and a login view.
|
|
133
|
+
|
|
134
|
+
**config/routes.rb**:
|
|
135
|
+
|
|
149
136
|
```ruby
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: false
|
|
137
|
+
get 'auth/:provider/callback', to: 'sessions#create'
|
|
138
|
+
get '/login', to: 'sessions#new'
|
|
153
139
|
```
|
|
154
140
|
|
|
155
|
-
|
|
141
|
+
**app/controllers/sessions_controller.rb**:
|
|
142
|
+
```ruby
|
|
143
|
+
class SessionsController < ApplicationController
|
|
144
|
+
def new
|
|
145
|
+
render :new
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def create
|
|
149
|
+
user_info = request.env['omniauth.auth']
|
|
150
|
+
raise user_info # Your own session management should be placed here.
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**app/views/sessions/new.html.erb**:
|
|
156
|
+
```erb
|
|
157
|
+
<%= form_tag('/auth/developer', method: 'post', data: {turbo: false}) do %>
|
|
158
|
+
<button type='submit'>Login with Developer</button>
|
|
159
|
+
<% end %>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Now if you visit `/login` and click the Login button, you should see the
|
|
163
|
+
OmniAuth developer login screen. After submitting it, you are returned to your
|
|
164
|
+
application at `Sessions#create`. The raise should now display all the Omniauth
|
|
165
|
+
details you have available to integrate it into your own user management.
|
|
166
|
+
|
|
167
|
+
If you want out of the box usermanagement, you should consider using Omniauth
|
|
168
|
+
through Devise. Please visit the [Devise Github page](https://github.com/heartcombo/devise#omniauth)
|
|
169
|
+
for more information.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Rails API
|
|
156
173
|
The following middleware are (by default) included for session management in
|
|
157
174
|
Rails applications. When using OmniAuth with a Rails API, you'll need to add
|
|
158
175
|
one of these required middleware back in:
|
|
@@ -191,6 +208,33 @@ to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
|
|
|
191
208
|
OmniAuth.config.logger = Rails.logger
|
|
192
209
|
```
|
|
193
210
|
|
|
211
|
+
## Origin Param
|
|
212
|
+
The `origin` url parameter is typically used to inform where a user came from
|
|
213
|
+
and where, should you choose to use it, they'd want to return to.
|
|
214
|
+
Omniauth supports the following settings which can be configured on a provider level:
|
|
215
|
+
|
|
216
|
+
**Default**:
|
|
217
|
+
```ruby
|
|
218
|
+
provider :twitter, ENV['KEY'], ENV['SECRET']
|
|
219
|
+
POST /auth/twitter/?origin=[URL]
|
|
220
|
+
# If the `origin` parameter is blank, `omniauth.origin` is set to HTTP_REFERER
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Using a differently named origin parameter**:
|
|
224
|
+
```ruby
|
|
225
|
+
provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: 'return_to'
|
|
226
|
+
POST /auth/twitter/?return_to=[URL]
|
|
227
|
+
# If the `return_to` parameter is blank, `omniauth.origin` is set to HTTP_REFERER
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Disabled**:
|
|
231
|
+
```ruby
|
|
232
|
+
provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: false
|
|
233
|
+
POST /auth/twitter
|
|
234
|
+
# This means the origin should be handled by your own application.
|
|
235
|
+
# Note that `omniauth.origin` will always be blank.
|
|
236
|
+
```
|
|
237
|
+
|
|
194
238
|
## Resources
|
|
195
239
|
The [OmniAuth Wiki](https://github.com/omniauth/omniauth/wiki) has
|
|
196
240
|
actively maintained in-depth documentation for OmniAuth. It should be
|
|
@@ -201,10 +245,14 @@ OmniAuth, how it works, and how to use it.
|
|
|
201
245
|
|
|
202
246
|
Available as part of the Tidelift Subscription.
|
|
203
247
|
|
|
204
|
-
The maintainers of OmniAuth and thousands of other packages are working with
|
|
248
|
+
The maintainers of OmniAuth and thousands of other packages are working with
|
|
249
|
+
Tidelift to deliver commercial support and maintenance for the open source
|
|
250
|
+
packages you use to build your applications. Save time, reduce risk, and
|
|
251
|
+
improve code health, while paying the maintainers of the exact packages you use.
|
|
252
|
+
[Learn more.](https://tidelift.com/subscription/pkg/rubygems-omniauth?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
205
253
|
|
|
206
254
|
## Supported Ruby Versions
|
|
207
|
-
OmniAuth is tested under 2.5, 2.6, 2.7, truffleruby, and JRuby.
|
|
255
|
+
OmniAuth is tested under 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, truffleruby, and JRuby.
|
|
208
256
|
|
|
209
257
|
## Versioning
|
|
210
258
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
data/SECURITY.md
CHANGED
data/lib/omniauth/builder.rb
CHANGED
|
@@ -12,6 +12,10 @@ module OmniAuth
|
|
|
12
12
|
OmniAuth.config.before_request_phase = block
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def after_request_phase(&block)
|
|
16
|
+
OmniAuth.config.after_request_phase = block
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def before_callback_phase(&block)
|
|
16
20
|
OmniAuth.config.before_callback_phase = block
|
|
17
21
|
end
|
|
@@ -26,7 +30,7 @@ module OmniAuth
|
|
|
26
30
|
@options = options
|
|
27
31
|
end
|
|
28
32
|
|
|
29
|
-
def provider(klass, *args, &block)
|
|
33
|
+
def provider(klass, *args, **opts, &block)
|
|
30
34
|
if klass.is_a?(Class)
|
|
31
35
|
middleware = klass
|
|
32
36
|
else
|
|
@@ -37,8 +41,7 @@ module OmniAuth
|
|
|
37
41
|
end
|
|
38
42
|
end
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
use middleware, *args, &block
|
|
44
|
+
use middleware, *args, **options.merge(opts), &block
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
def call(env)
|
data/lib/omniauth/form.rb
CHANGED
|
@@ -7,6 +7,7 @@ module OmniAuth
|
|
|
7
7
|
def initialize(options = {})
|
|
8
8
|
options[:title] ||= 'Authentication Info Required'
|
|
9
9
|
options[:header_info] ||= ''
|
|
10
|
+
options[:method] ||= 'post'
|
|
10
11
|
self.options = options
|
|
11
12
|
|
|
12
13
|
@html = +'' # unary + string allows it to be mutable if strings are frozen
|
|
@@ -75,7 +76,7 @@ module OmniAuth
|
|
|
75
76
|
</head>
|
|
76
77
|
<body>
|
|
77
78
|
<h1>#{title}</h1>
|
|
78
|
-
<form method='
|
|
79
|
+
<form method='#{options[:method]}' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'>
|
|
79
80
|
HTML
|
|
80
81
|
self
|
|
81
82
|
end
|
|
@@ -35,7 +35,7 @@ module OmniAuth
|
|
|
35
35
|
option :uid_field, :email
|
|
36
36
|
|
|
37
37
|
def request_phase
|
|
38
|
-
form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path)
|
|
38
|
+
form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path, :method => 'get')
|
|
39
39
|
options.fields.each do |field|
|
|
40
40
|
form.text_field field.to_s.capitalize.tr('_', ' '), field.to_s
|
|
41
41
|
end
|
data/lib/omniauth/strategy.rb
CHANGED
|
@@ -240,7 +240,7 @@ module OmniAuth
|
|
|
240
240
|
OmniAuth.config.request_validation_phase.call(env) if OmniAuth.config.request_validation_phase
|
|
241
241
|
OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
|
|
242
242
|
|
|
243
|
-
if options.form.respond_to?(:call)
|
|
243
|
+
result = if options.form.respond_to?(:call)
|
|
244
244
|
log :debug, 'Rendering form from supplied Rack endpoint.'
|
|
245
245
|
options.form.call(env)
|
|
246
246
|
elsif options.form
|
|
@@ -257,6 +257,9 @@ module OmniAuth
|
|
|
257
257
|
|
|
258
258
|
request_phase
|
|
259
259
|
end
|
|
260
|
+
|
|
261
|
+
OmniAuth.config.after_request_phase.call(env) if OmniAuth.config.after_request_phase
|
|
262
|
+
result
|
|
260
263
|
rescue OmniAuth::AuthenticityError => e
|
|
261
264
|
fail!(:authenticity_error, e)
|
|
262
265
|
end
|
|
@@ -330,12 +333,17 @@ module OmniAuth
|
|
|
330
333
|
end
|
|
331
334
|
end
|
|
332
335
|
|
|
333
|
-
redirect(callback_url)
|
|
336
|
+
result = redirect(callback_url)
|
|
337
|
+
|
|
338
|
+
OmniAuth.config.after_request_phase.call(env) if OmniAuth.config.after_request_phase
|
|
339
|
+
result
|
|
334
340
|
end
|
|
335
341
|
|
|
336
342
|
def mock_callback_call
|
|
337
343
|
setup_phase
|
|
338
|
-
|
|
344
|
+
|
|
345
|
+
origin = session.delete('omniauth.origin')
|
|
346
|
+
@env['omniauth.origin'] ||= origin
|
|
339
347
|
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
|
|
340
348
|
@env['omniauth.params'] = session.delete('omniauth.params') || {}
|
|
341
349
|
|
|
@@ -481,7 +489,7 @@ module OmniAuth
|
|
|
481
489
|
OmniAuth.config.full_host.call(env)
|
|
482
490
|
else
|
|
483
491
|
# in Rack 1.3.x, request.url explodes if scheme is nil
|
|
484
|
-
if request.scheme && request.url.
|
|
492
|
+
if request.scheme && URI.parse(request.url).absolute?
|
|
485
493
|
uri = URI.parse(request.url.gsub(/\?.*$/, ''))
|
|
486
494
|
uri.path = ''
|
|
487
495
|
# sometimes the url is actually showing http inside rails because the
|
|
@@ -498,6 +506,7 @@ module OmniAuth
|
|
|
498
506
|
end
|
|
499
507
|
|
|
500
508
|
def script_name
|
|
509
|
+
return '' if @env.nil?
|
|
501
510
|
@env['SCRIPT_NAME'] || ''
|
|
502
511
|
end
|
|
503
512
|
|
data/lib/omniauth/version.rb
CHANGED
data/lib/omniauth.rb
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# TODO: Fixed in https://github.com/rack/rack/pull/1610 for Rack 3
|
|
2
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
|
3
|
+
require 'delegate'
|
|
4
|
+
end
|
|
1
5
|
require 'rack'
|
|
2
6
|
require 'singleton'
|
|
3
7
|
require 'logger'
|
|
@@ -38,6 +42,7 @@ module OmniAuth
|
|
|
38
42
|
:failure_raise_out_environments => ['development'],
|
|
39
43
|
:request_validation_phase => OmniAuth::AuthenticityTokenProtection,
|
|
40
44
|
:before_request_phase => nil,
|
|
45
|
+
:after_request_phase => nil,
|
|
41
46
|
:before_callback_phase => nil,
|
|
42
47
|
:before_options_phase => nil,
|
|
43
48
|
:form_css => Form::DEFAULT_CSS,
|
|
@@ -93,6 +98,14 @@ module OmniAuth
|
|
|
93
98
|
end
|
|
94
99
|
end
|
|
95
100
|
|
|
101
|
+
def after_request_phase(&block)
|
|
102
|
+
if block_given?
|
|
103
|
+
@after_request_phase = block
|
|
104
|
+
else
|
|
105
|
+
@after_request_phase
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
96
109
|
def add_mock(provider, original = {})
|
|
97
110
|
# Create key-stringified new hash from given auth hash
|
|
98
111
|
mock = {}
|
|
@@ -122,7 +135,7 @@ module OmniAuth
|
|
|
122
135
|
camelizations[name.to_s] = camelized.to_s
|
|
123
136
|
end
|
|
124
137
|
|
|
125
|
-
attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :request_validation_phase
|
|
138
|
+
attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :after_request_phase, :request_validation_phase
|
|
126
139
|
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css,
|
|
127
140
|
:test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning
|
|
128
141
|
end
|
data/omniauth.gemspec
CHANGED
|
@@ -6,9 +6,10 @@ require 'omniauth/version'
|
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
8
|
spec.add_dependency 'hashie', ['>= 3.4.6']
|
|
9
|
-
spec.add_dependency 'rack',
|
|
9
|
+
spec.add_dependency 'rack', '>= 2.2.3'
|
|
10
10
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
11
11
|
spec.add_dependency 'rack-protection'
|
|
12
|
+
spec.add_dependency 'logger'
|
|
12
13
|
spec.add_development_dependency 'rake', '~> 12.0'
|
|
13
14
|
spec.authors = ['Michael Bleigh', 'Erik Michaels-Ober', 'Tom Milewski']
|
|
14
15
|
spec.description = 'A generalized Rack framework for multiple-provider authentication.'
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Bleigh
|
|
8
8
|
- Erik Michaels-Ober
|
|
9
9
|
- Tom Milewski
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: hashie
|
|
@@ -32,20 +31,14 @@ dependencies:
|
|
|
32
31
|
requirements:
|
|
33
32
|
- - ">="
|
|
34
33
|
- !ruby/object:Gem::Version
|
|
35
|
-
version:
|
|
36
|
-
- - "<"
|
|
37
|
-
- !ruby/object:Gem::Version
|
|
38
|
-
version: '3'
|
|
34
|
+
version: 2.2.3
|
|
39
35
|
type: :runtime
|
|
40
36
|
prerelease: false
|
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
38
|
requirements:
|
|
43
39
|
- - ">="
|
|
44
40
|
- !ruby/object:Gem::Version
|
|
45
|
-
version:
|
|
46
|
-
- - "<"
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '3'
|
|
41
|
+
version: 2.2.3
|
|
49
42
|
- !ruby/object:Gem::Dependency
|
|
50
43
|
name: bundler
|
|
51
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -74,6 +67,20 @@ dependencies:
|
|
|
74
67
|
- - ">="
|
|
75
68
|
- !ruby/object:Gem::Version
|
|
76
69
|
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: logger
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :runtime
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
77
84
|
- !ruby/object:Gem::Dependency
|
|
78
85
|
name: rake
|
|
79
86
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -99,7 +106,10 @@ extra_rdoc_files: []
|
|
|
99
106
|
files:
|
|
100
107
|
- ".github/FUNDING.yml"
|
|
101
108
|
- ".github/ISSUE_TEMPLATE.md"
|
|
109
|
+
- ".github/dependabot.yml"
|
|
110
|
+
- ".github/workflows/jruby.yml"
|
|
102
111
|
- ".github/workflows/main.yml"
|
|
112
|
+
- ".github/workflows/truffle_ruby.yml"
|
|
103
113
|
- ".gitignore"
|
|
104
114
|
- ".rspec"
|
|
105
115
|
- ".rubocop.yml"
|
|
@@ -129,7 +139,6 @@ homepage: https://github.com/omniauth/omniauth
|
|
|
129
139
|
licenses:
|
|
130
140
|
- MIT
|
|
131
141
|
metadata: {}
|
|
132
|
-
post_install_message:
|
|
133
142
|
rdoc_options: []
|
|
134
143
|
require_paths:
|
|
135
144
|
- lib
|
|
@@ -144,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
144
153
|
- !ruby/object:Gem::Version
|
|
145
154
|
version: 1.3.5
|
|
146
155
|
requirements: []
|
|
147
|
-
rubygems_version: 3.
|
|
148
|
-
signing_key:
|
|
156
|
+
rubygems_version: 3.6.9
|
|
149
157
|
specification_version: 4
|
|
150
158
|
summary: A generalized Rack framework for multiple-provider authentication.
|
|
151
159
|
test_files: []
|