omniauth 1.4.2 → 2.1.2
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 +5 -5
- data/.github/FUNDING.yml +2 -0
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/jruby.yml +28 -0
- data/.github/workflows/main.yml +61 -0
- data/.github/workflows/truffle_ruby.yml +24 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +18 -9
- data/Gemfile +10 -12
- data/README.md +146 -37
- data/Rakefile +38 -2
- data/SECURITY.md +18 -0
- data/lib/omniauth/auth_hash.rb +2 -3
- data/lib/omniauth/authenticity_token_protection.rb +32 -0
- data/lib/omniauth/builder.rb +5 -24
- data/lib/omniauth/failure_endpoint.rb +12 -1
- data/lib/omniauth/form.rb +4 -2
- data/lib/omniauth/key_store.rb +6 -9
- data/lib/omniauth/strategies/developer.rb +2 -2
- data/lib/omniauth/strategy.rb +115 -45
- data/lib/omniauth/test/strategy_test_case.rb +1 -1
- data/lib/omniauth/version.rb +1 -1
- data/lib/omniauth.rb +24 -8
- data/omniauth.gemspec +9 -6
- metadata +39 -31
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0de71776aec3f0b016291d25d87fed25bbfa49f5fcd0abcf0f7463be97111e92
|
4
|
+
data.tar.gz: dd52494efab1533e54f3a85ceab332db16e02ff6d633a00c99f52d7f089303ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16de198d83402c9613961994c0fe1f1c9fc709de6a546168830248c237e2fe61f0847e129f94a4bf51570cbb8beffa4e20b6542e23a342a17aa41bd8c2738200
|
7
|
+
data.tar.gz: f703bef08321f981909d950dba902989b5efb5d4c820b9f6b03c5695bbe56620e2656bfd75d527101ed3d7cdc78dd4c886f2e4991f12c01ea170e1ad900b3245
|
data/.github/FUNDING.yml
ADDED
@@ -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.
|
@@ -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
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ${{ matrix.os }}-latest
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
os: [ubuntu, macos]
|
23
|
+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head, debug]
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
bundler-cache: true
|
31
|
+
- name: Run tests
|
32
|
+
run: bundle exec rake
|
33
|
+
frozen-string-compat:
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v3
|
37
|
+
- name: Set up Ruby
|
38
|
+
uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: 2.6
|
41
|
+
bundler-cache: true
|
42
|
+
- name: Run tests
|
43
|
+
env:
|
44
|
+
RUBYOPT: "--enable-frozen-string-literal"
|
45
|
+
run: bundle exec rake
|
46
|
+
coveralls:
|
47
|
+
runs-on: ubuntu-latest
|
48
|
+
steps:
|
49
|
+
- uses: actions/checkout@v3
|
50
|
+
- name: Set up Ruby
|
51
|
+
uses: ruby/setup-ruby@v1
|
52
|
+
with:
|
53
|
+
ruby-version: 2.6
|
54
|
+
bundler-cache: true
|
55
|
+
- name: Run tests
|
56
|
+
run: bundle exec rake
|
57
|
+
- name: Coveralls GitHub Action
|
58
|
+
uses: coverallsapp/github-action@v2
|
59
|
+
with:
|
60
|
+
github-token: ${{ secrets.github_token }}
|
61
|
+
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/.rubocop.yml
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
|
4
|
+
Layout/AccessModifierIndentation:
|
5
|
+
EnforcedStyle: outdent
|
6
|
+
|
7
|
+
Layout/AlignHash:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/DotPosition:
|
11
|
+
EnforcedStyle: trailing
|
12
|
+
|
13
|
+
Layout/SpaceInsideHashLiteralBraces:
|
14
|
+
EnforcedStyle: no_space
|
15
|
+
|
1
16
|
Lint/HandleExceptions:
|
2
17
|
Enabled: false
|
3
18
|
|
@@ -22,9 +37,6 @@ Metrics/ParameterLists:
|
|
22
37
|
Metrics/AbcSize:
|
23
38
|
Enabled: false
|
24
39
|
|
25
|
-
Style/AccessModifierIndentation:
|
26
|
-
EnforcedStyle: outdent
|
27
|
-
|
28
40
|
Style/CollectionMethods:
|
29
41
|
PreferredMethods:
|
30
42
|
map: 'collect'
|
@@ -35,9 +47,6 @@ Style/CollectionMethods:
|
|
35
47
|
Style/Documentation:
|
36
48
|
Enabled: false
|
37
49
|
|
38
|
-
Style/DotPosition:
|
39
|
-
EnforcedStyle: trailing
|
40
|
-
|
41
50
|
Style/DoubleNegation:
|
42
51
|
Enabled: false
|
43
52
|
|
@@ -47,6 +56,9 @@ Style/EachWithObject:
|
|
47
56
|
Style/Encoding:
|
48
57
|
Enabled: false
|
49
58
|
|
59
|
+
Style/ExpandPathArguments:
|
60
|
+
Enabled: false
|
61
|
+
|
50
62
|
Style/HashSyntax:
|
51
63
|
EnforcedStyle: hash_rockets
|
52
64
|
|
@@ -55,6 +67,3 @@ Style/Lambda:
|
|
55
67
|
|
56
68
|
Style/RaiseArgs:
|
57
69
|
EnforcedStyle: compact
|
58
|
-
|
59
|
-
Style/SpaceInsideHashLiteralBraces:
|
60
|
-
EnforcedStyle: no_space
|
data/Gemfile
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'jruby-openssl',
|
4
|
-
gem 'rake', '
|
5
|
-
gem 'yard'
|
3
|
+
gem 'jruby-openssl', '~> 0.10.5', platforms: :jruby
|
4
|
+
gem 'rake', '>= 12.0'
|
5
|
+
gem 'yard', '>= 0.9.11'
|
6
6
|
|
7
7
|
group :development do
|
8
|
+
gem 'benchmark-ips'
|
8
9
|
gem 'kramdown'
|
10
|
+
gem 'memory_profiler'
|
9
11
|
gem 'pry'
|
10
12
|
end
|
11
13
|
|
12
14
|
group :test do
|
13
|
-
gem '
|
14
|
-
gem 'json', '~> 1.8', :platforms => [:jruby_18, :jruby_19, :ruby_19]
|
15
|
-
gem 'mime-types', '~> 1.25', :platforms => [:jruby_18]
|
16
|
-
gem 'rack', '>= 1.6.2', :platforms => [:jruby_18, :jruby_19, :ruby_19, :ruby_20, :ruby_21]
|
15
|
+
gem 'coveralls_reborn', '~> 0.19.0', require: false
|
17
16
|
gem 'rack-test'
|
18
|
-
gem '
|
19
|
-
gem '
|
20
|
-
gem 'rubocop', '>= 0.
|
21
|
-
gem 'simplecov'
|
22
|
-
gem 'tins', '~> 1.6.0', :platforms => [:jruby_18, :jruby_19, :ruby_19]
|
17
|
+
gem 'rspec', '~> 3.5'
|
18
|
+
gem 'rack-freeze'
|
19
|
+
gem 'rubocop', '>= 0.58.2', '< 0.69.0', platforms: %i[ruby_22 ruby_23 ruby_24]
|
20
|
+
gem 'simplecov-lcov'
|
23
21
|
end
|
24
22
|
|
25
23
|
gemspec
|
data/README.md
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
# OmniAuth: Standardized Multi-Provider Authentication
|
2
2
|
|
3
3
|
[][gem]
|
4
|
-
[][githubactions]
|
5
|
+
[][githubactionstruffle]
|
6
|
+
[][githubactionsjruby]
|
7
|
+
[][codeclimate]
|
7
8
|
[][coveralls]
|
8
|
-
[](https://hakiri.io/github/omniauth/omniauth/master)
|
9
9
|
|
10
10
|
[gem]: https://rubygems.org/gems/omniauth
|
11
|
-
[
|
12
|
-
[
|
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
|
13
14
|
[codeclimate]: https://codeclimate.com/github/omniauth/omniauth
|
14
15
|
[coveralls]: https://coveralls.io/r/omniauth/omniauth
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
upgrade. See [the wiki](https://github.com/omniauth/omniauth/wiki/Upgrading-to-1.0)
|
19
|
-
for more information.**
|
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.2)
|
20
19
|
|
21
20
|
## An Introduction
|
22
21
|
OmniAuth is a library that standardizes multi-provider authentication for
|
@@ -39,8 +38,8 @@ development and easily swap in other strategies later.
|
|
39
38
|
## Getting Started
|
40
39
|
Each OmniAuth strategy is a Rack Middleware. That means that you can use
|
41
40
|
it the same way that you use any other Rack middleware. For example, to
|
42
|
-
use the built-in Developer strategy in a Sinatra application
|
43
|
-
this:
|
41
|
+
use the built-in Developer strategy in a Sinatra application you might
|
42
|
+
do this:
|
44
43
|
|
45
44
|
```ruby
|
46
45
|
require 'sinatra'
|
@@ -52,7 +51,7 @@ class MyApplication < Sinatra::Base
|
|
52
51
|
end
|
53
52
|
```
|
54
53
|
|
55
|
-
Because OmniAuth is built for *multi-provider* authentication,
|
54
|
+
Because OmniAuth is built for *multi-provider* authentication, you may
|
56
55
|
want to leave room to run multiple strategies. For this, the built-in
|
57
56
|
`OmniAuth::Builder` class gives you an easy way to specify multiple
|
58
57
|
strategies. Note that there is **no difference** between the following
|
@@ -89,43 +88,116 @@ environment of a request to `/auth/:provider/callback`. This hash
|
|
89
88
|
contains as much information about the user as OmniAuth was able to
|
90
89
|
glean from the utilized strategy. You should set up an endpoint in your
|
91
90
|
application that matches to the callback URL and then performs whatever
|
92
|
-
steps are necessary for your application.
|
93
|
-
would add a line in my `routes.rb` file like this:
|
91
|
+
steps are necessary for your application.
|
94
92
|
|
93
|
+
The `omniauth.auth` key in the environment hash provides an
|
94
|
+
Authentication Hash which will contain information about the just
|
95
|
+
authenticated user including a unique id, the strategy they just used
|
96
|
+
for authentication, and personal details such as name and email address
|
97
|
+
as available. For an in-depth description of what the authentication
|
98
|
+
hash might contain, see the [Auth Hash Schema wiki page](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema).
|
99
|
+
|
100
|
+
Note that OmniAuth does not perform any actions beyond setting some
|
101
|
+
environment information on the callback request. It is entirely up to
|
102
|
+
you how you want to implement the particulars of your application's
|
103
|
+
authentication flow.
|
104
|
+
|
105
|
+
## rack_csrf
|
106
|
+
|
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:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
OmniAuth::AuthenticityTokenProtection.default_options(key: "csrf.token", authenticity_param: "_csrf")
|
111
|
+
```
|
112
|
+
|
113
|
+
## Rails (without Devise)
|
114
|
+
To get started, add the following gems
|
115
|
+
|
116
|
+
**Gemfile**:
|
117
|
+
```ruby
|
118
|
+
gem 'omniauth'
|
119
|
+
gem "omniauth-rails_csrf_protection"
|
120
|
+
```
|
121
|
+
|
122
|
+
Then insert OmniAuth as a middleware
|
123
|
+
|
124
|
+
**config/initializers/omniauth.rb**:
|
95
125
|
```ruby
|
96
|
-
|
126
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
127
|
+
provider :developer if Rails.env.development?
|
128
|
+
end
|
97
129
|
```
|
98
130
|
|
99
|
-
|
100
|
-
|
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**:
|
101
135
|
|
136
|
+
```ruby
|
137
|
+
get 'auth/:provider/callback', to: 'sessions#create'
|
138
|
+
get '/login', to: 'sessions#new'
|
139
|
+
```
|
140
|
+
|
141
|
+
**app/controllers/sessions_controller.rb**:
|
102
142
|
```ruby
|
103
143
|
class SessionsController < ApplicationController
|
104
|
-
def
|
105
|
-
|
106
|
-
self.current_user = @user
|
107
|
-
redirect_to '/'
|
144
|
+
def new
|
145
|
+
render :new
|
108
146
|
end
|
109
147
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
request.env['omniauth.auth']
|
148
|
+
def create
|
149
|
+
user_info = request.env['omniauth.auth']
|
150
|
+
raise user_info # Your own session management should be placed here.
|
114
151
|
end
|
115
152
|
end
|
116
153
|
```
|
117
154
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
+
```
|
124
161
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
173
|
+
The following middleware are (by default) included for session management in
|
174
|
+
Rails applications. When using OmniAuth with a Rails API, you'll need to add
|
175
|
+
one of these required middleware back in:
|
176
|
+
|
177
|
+
- `ActionDispatch::Session::CacheStore`
|
178
|
+
- `ActionDispatch::Session::CookieStore`
|
179
|
+
- `ActionDispatch::Session::MemCacheStore`
|
180
|
+
|
181
|
+
The trick to adding these back in is that, by default, they are passed
|
182
|
+
`session_options` when added (including the session key), so you can't just add
|
183
|
+
a `session_store.rb` initializer, add `use ActionDispatch::Session::CookieStore`
|
184
|
+
and have sessions functioning as normal.
|
185
|
+
|
186
|
+
To be clear: sessions may work, but your session options will be ignored
|
187
|
+
(i.e. the session key will default to `_session_id`). Instead of the
|
188
|
+
initializer, you'll have to set the relevant options somewhere
|
189
|
+
before your middleware is built (like `application.rb`) and pass them to your
|
190
|
+
preferred middleware, like this:
|
191
|
+
|
192
|
+
**application.rb:**
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
config.session_store :cookie_store, key: '_interslice_session'
|
196
|
+
config.middleware.use ActionDispatch::Cookies # Required for all session management
|
197
|
+
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
|
198
|
+
```
|
199
|
+
|
200
|
+
(Thanks @mltsy)
|
129
201
|
|
130
202
|
## Logging
|
131
203
|
OmniAuth supports a configurable logger. By default, OmniAuth will log
|
@@ -136,14 +208,51 @@ to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
|
|
136
208
|
OmniAuth.config.logger = Rails.logger
|
137
209
|
```
|
138
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
|
+
|
139
238
|
## Resources
|
140
239
|
The [OmniAuth Wiki](https://github.com/omniauth/omniauth/wiki) has
|
141
240
|
actively maintained in-depth documentation for OmniAuth. It should be
|
142
241
|
your first stop if you are wondering about a more in-depth look at
|
143
242
|
OmniAuth, how it works, and how to use it.
|
144
243
|
|
244
|
+
## OmniAuth for Enterprise
|
245
|
+
|
246
|
+
Available as part of the Tidelift Subscription.
|
247
|
+
|
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)
|
253
|
+
|
145
254
|
## Supported Ruby Versions
|
146
|
-
OmniAuth is tested under
|
255
|
+
OmniAuth is tested under 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, truffleruby, and JRuby.
|
147
256
|
|
148
257
|
## Versioning
|
149
258
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
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/SECURITY.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
Use this section to tell people about which versions of your project are
|
6
|
+
currently being supported with security updates.
|
7
|
+
|
8
|
+
| Version | Supported |
|
9
|
+
| ------- | ------------------ |
|
10
|
+
| 2.1.x | :white_check_mark: |
|
11
|
+
| 2.0.x | :white_check_mark: |
|
12
|
+
| <= 1.9.1 | :x: |
|
13
|
+
|
14
|
+
## Security contact information
|
15
|
+
|
16
|
+
To report a security vulnerability, please use the
|
17
|
+
[Tidelift security contact](https://tidelift.com/security).
|
18
|
+
Tidelift will coordinate the fix and disclosure.
|
data/lib/omniauth/auth_hash.rb
CHANGED
@@ -20,9 +20,7 @@ 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
|
|
@@ -36,6 +34,7 @@ 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
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rack-protection'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
class AuthenticityError < StandardError; end
|
5
|
+
class AuthenticityTokenProtection < Rack::Protection::AuthenticityToken
|
6
|
+
def initialize(options = {})
|
7
|
+
@options = default_options.merge(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.call(env)
|
11
|
+
new.call!(env)
|
12
|
+
end
|
13
|
+
|
14
|
+
def call!(env)
|
15
|
+
return if accepts?(env)
|
16
|
+
|
17
|
+
instrument env
|
18
|
+
react env
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :call, :call!
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def deny(_env)
|
26
|
+
OmniAuth.logger.send(:warn, "Attack prevented by #{self.class}")
|
27
|
+
raise AuthenticityError.new(options[:message])
|
28
|
+
end
|
29
|
+
|
30
|
+
alias default_reaction deny
|
31
|
+
end
|
32
|
+
end
|