omniauth 2.0.4 → 2.1.1
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/workflows/jruby.yml +30 -0
- data/.github/workflows/main.yml +1 -23
- data/.github/workflows/truffle_ruby.yml +26 -0
- data/.gitignore +1 -0
- data/Gemfile +7 -8
- data/README.md +97 -49
- data/SECURITY.md +1 -0
- data/lib/omniauth/builder.rb +2 -3
- data/lib/omniauth/strategy.rb +1 -0
- data/lib/omniauth/version.rb +1 -1
- data/omniauth.gemspec +1 -1
- metadata +7 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb3de3ad6a305065fef63ef3a4344db5bcb3b27694b9283b34df9b60db53071
|
4
|
+
data.tar.gz: 2f2534e820313a07c1ff46e515b9e07124de20324df8c76735dd121c17c02bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05402733493a06ee4e3c26b30431d0a89c4883350ce4cedad9af29151d6310f0a106f79291c4d634ba955e4618b9be7c796942b08adcee4b6730396f1c1a7af
|
7
|
+
data.tar.gz: 052fca22fac4152907799ab29e112230ad972f227e49616f5537c12a4d000e702c1bbb3b184f0ee29f09a96a1d7a6fe4dbd82e32c5e167269048979993236f3f
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: JRuby
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ master ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ master ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-18.04
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu, macos]
|
15
|
+
jruby: [jruby] # TODO: Add back jruby-head once we figure out why there's a bundler mismatch
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.jruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Install dependencies
|
24
|
+
env:
|
25
|
+
JRUBY_OPTS: --debug
|
26
|
+
run: bundle install
|
27
|
+
- name: Run tests
|
28
|
+
env:
|
29
|
+
JRUBY_OPTS: --debug
|
30
|
+
run: bundle exec rake
|
data/.github/workflows/main.yml
CHANGED
@@ -20,7 +20,7 @@ jobs:
|
|
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, head, debug]
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v2
|
26
26
|
- name: Set up Ruby
|
@@ -32,28 +32,6 @@ jobs:
|
|
32
32
|
run: bundle install
|
33
33
|
- name: Run tests
|
34
34
|
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
35
|
frozen-string-compat:
|
58
36
|
runs-on: ubuntu-18.04
|
59
37
|
steps:
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: TruffleRuby
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ master ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ master ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-18.04
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu, macos]
|
15
|
+
ruby: [truffleruby, truffleruby-head]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle install
|
25
|
+
- name: Run tests
|
26
|
+
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
|
|
@@ -13,17 +13,16 @@ end
|
|
13
13
|
|
14
14
|
group :test do
|
15
15
|
gem 'coveralls_reborn', '~> 0.19.0', require: false
|
16
|
-
gem 'hashie', '>= 3.4.6', '~> 4.0.0', :
|
17
|
-
gem 'json', '~> 2.3.0', :
|
18
|
-
gem 'mime-types', '~> 3.1', :
|
19
|
-
gem 'rack', '>= 2.0.6', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
|
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]
|
20
19
|
gem 'rack-test'
|
21
|
-
gem 'rest-client', '~> 2.0.0', :
|
20
|
+
gem 'rest-client', '~> 2.0.0', platforms: [:jruby_18]
|
22
21
|
gem 'rspec', '~> 3.5'
|
23
22
|
gem 'rack-freeze'
|
24
|
-
gem 'rubocop', '>= 0.58.2', '< 0.69.0', :
|
23
|
+
gem 'rubocop', '>= 0.58.2', '< 0.69.0', platforms: %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
25
24
|
gem 'simplecov-lcov'
|
26
|
-
gem 'tins', '~> 1.13', :
|
25
|
+
gem 'tins', '~> 1.13', platforms: %i[jruby_18 jruby_19 ruby_19]
|
27
26
|
end
|
28
27
|
|
29
28
|
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.1)
|
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,7 +245,11 @@ 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
255
|
OmniAuth is tested under 2.5, 2.6, 2.7, truffleruby, and JRuby.
|
data/SECURITY.md
CHANGED
data/lib/omniauth/builder.rb
CHANGED
@@ -26,7 +26,7 @@ module OmniAuth
|
|
26
26
|
@options = options
|
27
27
|
end
|
28
28
|
|
29
|
-
def provider(klass, *args, &block)
|
29
|
+
def provider(klass, *args, **opts, &block)
|
30
30
|
if klass.is_a?(Class)
|
31
31
|
middleware = klass
|
32
32
|
else
|
@@ -37,8 +37,7 @@ module OmniAuth
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
use middleware, *args, &block
|
40
|
+
use middleware, *args, **options.merge(opts), &block
|
42
41
|
end
|
43
42
|
|
44
43
|
def call(env)
|
data/lib/omniauth/strategy.rb
CHANGED
data/lib/omniauth/version.rb
CHANGED
data/omniauth.gemspec
CHANGED
@@ -6,7 +6,7 @@ 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
12
|
spec.add_development_dependency 'rake', '~> 12.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|
@@ -32,20 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
- - "<"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '3'
|
35
|
+
version: 2.2.3
|
39
36
|
type: :runtime
|
40
37
|
prerelease: false
|
41
38
|
version_requirements: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - ">="
|
44
41
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
- - "<"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '3'
|
42
|
+
version: 2.2.3
|
49
43
|
- !ruby/object:Gem::Dependency
|
50
44
|
name: bundler
|
51
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +93,9 @@ extra_rdoc_files: []
|
|
99
93
|
files:
|
100
94
|
- ".github/FUNDING.yml"
|
101
95
|
- ".github/ISSUE_TEMPLATE.md"
|
96
|
+
- ".github/workflows/jruby.yml"
|
102
97
|
- ".github/workflows/main.yml"
|
98
|
+
- ".github/workflows/truffle_ruby.yml"
|
103
99
|
- ".gitignore"
|
104
100
|
- ".rspec"
|
105
101
|
- ".rubocop.yml"
|
@@ -144,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
140
|
- !ruby/object:Gem::Version
|
145
141
|
version: 1.3.5
|
146
142
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
148
144
|
signing_key:
|
149
145
|
specification_version: 4
|
150
146
|
summary: A generalized Rack framework for multiple-provider authentication.
|