omniauth 1.3.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06e30f31bdee870b242a81af5c01e813539e8030
4
- data.tar.gz: c417d4689e17580d7f018205c298f41d3ff3c644
2
+ SHA256:
3
+ metadata.gz: bda926095916de4b9694aaea0102e28ba4589485ac7299e14818d16c80114e2d
4
+ data.tar.gz: 933f85d44aa3ce65274350f6b460c0c1f48bfe0e7c6231091e0fe05cc07b741c
5
5
  SHA512:
6
- metadata.gz: 2b3928add7b13234a4272afa70076b7e13c76256f9ca55c40aa50fd435f108609621b7ae0954407880a51422f5354b40b4332478e6df7f15cfc5cb16167e476a
7
- data.tar.gz: a2706e7afe3eb62b911c151d216f2b22fa02b92f4c0e0aa08ad89fd627bb90ec8c5a2d8fc58b0bdbca87a664775ab7654ec3f83cf568581d3402d3d78b6189a0
6
+ metadata.gz: b67754b61bea388ad20c8a2e305fdcdb0310cc6cd910eec4b3fbb6d2e5b86c24d99970e79f2b9913f4cc575ec25572408c87a4236728214edb10a7d0fe926fc0
7
+ data.tar.gz: a089f325f9b80fdba2f0f0561e0d050b36d47f49e763e33e381d427d8592009fa4da80db50e47f2d172bf96fb6d8d46455b68ec0e3fae632b752a1decbf0941f
@@ -0,0 +1,2 @@
1
+ github: bobbymcwho
2
+ tidelift: rubygems/omniauth
@@ -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,89 @@
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: ubuntu-18.04
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ os: [ubuntu, macos]
23
+ ruby: [2.5, 2.6, 2.7, head, debug, truffleruby, truffleruby-head]
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+ bundler-cache: true
31
+ - name: Install dependencies
32
+ run: bundle install
33
+ - name: Run tests
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
+ frozen-string-compat:
58
+ runs-on: ubuntu-18.04
59
+ steps:
60
+ - uses: actions/checkout@v2
61
+ - name: Set up Ruby
62
+ uses: ruby/setup-ruby@v1
63
+ with:
64
+ ruby-version: 2.6
65
+ bundler-cache: true
66
+ - name: Install dependencies
67
+ run: bundle install
68
+ - name: Run tests
69
+ env:
70
+ RUBYOPT: "--enable-frozen-string-literal"
71
+ run: bundle exec rake
72
+ coveralls:
73
+ runs-on: ubuntu-18.04
74
+ steps:
75
+ - uses: actions/checkout@v2
76
+ - name: Set up Ruby
77
+ uses: ruby/setup-ruby@v1
78
+ with:
79
+ ruby-version: 2.6
80
+ bundler-cache: true
81
+ - name: Install dependencies
82
+ run: bundle install
83
+ - name: Run tests
84
+ run: bundle exec rake
85
+ - name: Coveralls GitHub Action
86
+ uses: coverallsapp/github-action@v1.1.2
87
+ with:
88
+ github-token: ${{ secrets.github_token }}
89
+ path-to-lcov: './coverage/lcov/omniauth.lcov'
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ doc/*
10
10
  log/*
11
11
  measurement/*
12
12
  pkg/*
13
+ .DS_Store
data/.rubocop.yml CHANGED
@@ -1,6 +1,24 @@
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
 
19
+ Metrics/BlockLength:
20
+ Enabled: false
21
+
4
22
  Metrics/BlockNesting:
5
23
  Max: 2
6
24
 
@@ -19,9 +37,6 @@ Metrics/ParameterLists:
19
37
  Metrics/AbcSize:
20
38
  Enabled: false
21
39
 
22
- Style/AccessModifierIndentation:
23
- EnforcedStyle: outdent
24
-
25
40
  Style/CollectionMethods:
26
41
  PreferredMethods:
27
42
  map: 'collect'
@@ -32,9 +47,6 @@ Style/CollectionMethods:
32
47
  Style/Documentation:
33
48
  Enabled: false
34
49
 
35
- Style/DotPosition:
36
- EnforcedStyle: trailing
37
-
38
50
  Style/DoubleNegation:
39
51
  Enabled: false
40
52
 
@@ -44,6 +56,9 @@ Style/EachWithObject:
44
56
  Style/Encoding:
45
57
  Enabled: false
46
58
 
59
+ Style/ExpandPathArguments:
60
+ Enabled: false
61
+
47
62
  Style/HashSyntax:
48
63
  EnforcedStyle: hash_rockets
49
64
 
@@ -52,6 +67,3 @@ Style/Lambda:
52
67
 
53
68
  Style/RaiseArgs:
54
69
  EnforcedStyle: compact
55
-
56
- Style/SpaceInsideHashLiteralBraces:
57
- EnforcedStyle: no_space
data/Gemfile CHANGED
@@ -1,24 +1,29 @@
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.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 'coveralls'
14
- gem 'hashie', '~> 2.0.5', :platforms => [:jruby_18, :ruby_18]
15
- gem 'json', '>= 1.8.1', :platforms => [:jruby_18, :jruby_19, :ruby_18, :ruby_19]
16
- gem 'mime-types', '~> 1.25', :platforms => [:jruby_18, :ruby_18]
15
+ 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]
17
20
  gem 'rack-test'
18
- gem 'rest-client', '~> 1.6.0', :platforms => [:jruby_18, :ruby_18]
19
- gem 'rspec', '~> 3.0'
20
- gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
21
- gem 'simplecov', '>= 0.9'
21
+ gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
22
+ gem 'rspec', '~> 3.5'
23
+ gem 'rack-freeze'
24
+ gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
25
+ gem 'simplecov-lcov'
26
+ gem 'tins', '~> 1.13', :platforms => %i[jruby_18 jruby_19 ruby_19]
22
27
  end
23
28
 
24
29
  gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc.
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,16 @@
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/intridea/omniauth.svg)][travis]
5
- [![Dependency Status](http://img.shields.io/gemnasium/intridea/omniauth.svg)][gemnasium]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/intridea/omniauth.svg)][codeclimate]
7
- [![Coverage Status](http://img.shields.io/coveralls/intridea/omniauth.svg)][coveralls]
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](https://api.codeclimate.com/v1/badges/ffd33970723587806744/maintainability)][codeclimate]
6
+ [![Coverage Status](http://img.shields.io/coveralls/omniauth/omniauth.svg)][coveralls]
9
7
 
10
8
  [gem]: https://rubygems.org/gems/omniauth
11
- [travis]: http://travis-ci.org/intridea/omniauth
12
- [gemnasium]: https://gemnasium.com/intridea/omniauth
13
- [codeclimate]: https://codeclimate.com/github/intridea/omniauth
14
- [coveralls]: https://coveralls.io/r/intridea/omniauth
9
+ [travis]: http://travis-ci.org/omniauth/omniauth
10
+ [codeclimate]: https://codeclimate.com/github/omniauth/omniauth
11
+ [coveralls]: https://coveralls.io/r/omniauth/omniauth
15
12
 
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.**
13
+ This is the documentation for the version [v2.0.4](https://github.com/omniauth/omniauth/tree/v2.0.4) of OmniAuth.
20
14
 
21
15
  ## An Introduction
22
16
  OmniAuth is a library that standardizes multi-provider authentication for
@@ -27,7 +21,7 @@ have been created for everything from Facebook to LDAP.
27
21
 
28
22
  In order to use OmniAuth in your applications, you will need to leverage
29
23
  one or more strategies. These strategies are generally released
30
- individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
24
+ individually as RubyGems, and you can see a [community maintained list](https://github.com/omniauth/omniauth/wiki/List-of-Strategies)
31
25
  on the wiki for this project.
32
26
 
33
27
  One strategy, called `Developer`, is included with OmniAuth and provides
@@ -39,8 +33,8 @@ development and easily swap in other strategies later.
39
33
  ## Getting Started
40
34
  Each OmniAuth strategy is a Rack Middleware. That means that you can use
41
35
  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 I might do
43
- this:
36
+ use the built-in Developer strategy in a Sinatra application you might
37
+ do this:
44
38
 
45
39
  ```ruby
46
40
  require 'sinatra'
@@ -52,7 +46,7 @@ class MyApplication < Sinatra::Base
52
46
  end
53
47
  ```
54
48
 
55
- Because OmniAuth is built for *multi-provider* authentication, I may
49
+ Because OmniAuth is built for *multi-provider* authentication, you may
56
50
  want to leave room to run multiple strategies. For this, the built-in
57
51
  `OmniAuth::Builder` class gives you an easy way to specify multiple
58
52
  strategies. Note that there is **no difference** between the following
@@ -89,18 +83,21 @@ environment of a request to `/auth/:provider/callback`. This hash
89
83
  contains as much information about the user as OmniAuth was able to
90
84
  glean from the utilized strategy. You should set up an endpoint in your
91
85
  application that matches to the callback URL and then performs whatever
92
- steps are necessary for your application. For example, in a Rails app I
93
- would add a line in my `routes.rb` file like this:
86
+ steps are necessary for your application. For example, in a Rails app
87
+ you would add a line in your `routes.rb` file like this:
94
88
 
95
89
  ```ruby
96
- get '/auth/:provider/callback', to: 'sessions#create'
90
+ post '/auth/:provider/callback', to: 'sessions#create'
97
91
  ```
98
92
 
99
- And I might then have a `SessionsController` with code that looks
93
+ And you might then have a `SessionsController` with code that looks
100
94
  something like this:
101
95
 
102
96
  ```ruby
103
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
+
104
101
  def create
105
102
  @user = User.find_or_create_from_auth_hash(auth_hash)
106
103
  self.current_user = @user
@@ -115,18 +112,76 @@ class SessionsController < ApplicationController
115
112
  end
116
113
  ```
117
114
 
118
- The `omniauth.auth` key in the environment hash gives me my
115
+ The `omniauth.auth` key in the environment hash provides an
119
116
  Authentication Hash which will contain information about the just
120
117
  authenticated user including a unique id, the strategy they just used
121
118
  for authentication, and personal details such as name and email address
122
119
  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/intridea/omniauth/wiki/Auth-Hash-Schema).
120
+ hash might contain, see the [Auth Hash Schema wiki page](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema).
124
121
 
125
122
  Note that OmniAuth does not perform any actions beyond setting some
126
123
  environment information on the callback request. It is entirely up to
127
124
  you how you want to implement the particulars of your application's
128
125
  authentication flow.
129
126
 
127
+ **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).
128
+
129
+ ## Configuring The `origin` Param
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.
131
+
132
+ There are three possible options:
133
+
134
+ Default Flow:
135
+ ```ruby
136
+ # /auth/twitter/?origin=[URL]
137
+ # No change
138
+ # If blank, `omniauth.origin` is set to HTTP_REFERER
139
+ ```
140
+
141
+ Renaming Origin Param:
142
+ ```ruby
143
+ # /auth/twitter/?return_to=[URL]
144
+ # If blank, `omniauth.origin` is set to HTTP_REFERER
145
+ provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: 'return_to'
146
+ ```
147
+
148
+ Disabling Origin Param:
149
+ ```ruby
150
+ # /auth/twitter
151
+ # Origin handled externally, if need be. `omniauth.origin` is not set
152
+ provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: false
153
+ ```
154
+
155
+ ## Integrating OmniAuth Into Your Rails API
156
+ The following middleware are (by default) included for session management in
157
+ Rails applications. When using OmniAuth with a Rails API, you'll need to add
158
+ one of these required middleware back in:
159
+
160
+ - `ActionDispatch::Session::CacheStore`
161
+ - `ActionDispatch::Session::CookieStore`
162
+ - `ActionDispatch::Session::MemCacheStore`
163
+
164
+ The trick to adding these back in is that, by default, they are passed
165
+ `session_options` when added (including the session key), so you can't just add
166
+ a `session_store.rb` initializer, add `use ActionDispatch::Session::CookieStore`
167
+ and have sessions functioning as normal.
168
+
169
+ To be clear: sessions may work, but your session options will be ignored
170
+ (i.e. the session key will default to `_session_id`). Instead of the
171
+ initializer, you'll have to set the relevant options somewhere
172
+ before your middleware is built (like `application.rb`) and pass them to your
173
+ preferred middleware, like this:
174
+
175
+ **application.rb:**
176
+
177
+ ```ruby
178
+ config.session_store :cookie_store, key: '_interslice_session'
179
+ config.middleware.use ActionDispatch::Cookies # Required for all session management
180
+ config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
181
+ ```
182
+
183
+ (Thanks @mltsy)
184
+
130
185
  ## Logging
131
186
  OmniAuth supports a configurable logger. By default, OmniAuth will log
132
187
  to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
@@ -137,13 +192,19 @@ OmniAuth.config.logger = Rails.logger
137
192
  ```
138
193
 
139
194
  ## Resources
140
- The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
195
+ The [OmniAuth Wiki](https://github.com/omniauth/omniauth/wiki) has
141
196
  actively maintained in-depth documentation for OmniAuth. It should be
142
197
  your first stop if you are wondering about a more in-depth look at
143
198
  OmniAuth, how it works, and how to use it.
144
199
 
200
+ ## OmniAuth for Enterprise
201
+
202
+ Available as part of the Tidelift Subscription.
203
+
204
+ The maintainers of OmniAuth and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/rubygems-omniauth?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
205
+
145
206
  ## Supported Ruby Versions
146
- OmniAuth is tested under 1.8.7, 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
207
+ OmniAuth is tested under 2.5, 2.6, 2.7, truffleruby, and JRuby.
147
208
 
148
209
  ## Versioning
149
210
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
@@ -158,10 +219,10 @@ Constraint][pvc] with two digits of precision. For example:
158
219
  spec.add_dependency 'omniauth', '~> 1.0'
159
220
 
160
221
  [semver]: http://semver.org/
161
- [pvc]: http://docs.rubygems.org/read/chapter/16#page74
222
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
162
223
 
163
224
  ## License
164
- Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
225
+ Copyright (c) 2010-2017 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
165
226
  details.
166
227
 
167
228
  [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
- $stderr.puts 'RuboCop is disabled'
13
+ warn 'RuboCop is disabled'
14
14
  end
15
15
  end
16
16
 
17
- task :default => [:spec, :rubocop]
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,17 @@
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.0.x | :white_check_mark: |
11
+ | <= 1.9.1 | :x: |
12
+
13
+ ## Security contact information
14
+
15
+ To report a security vulnerability, please use the
16
+ [Tidelift security contact](https://tidelift.com/security).
17
+ Tidelift will coordinate the fix and disclosure.
@@ -1,11 +1,11 @@
1
- require 'hashie/mash'
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 < Hashie::Mash
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 < Hashie::Mash
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
42
  !!name
44
43
  end
45
- alias_method :valid?, :name?
44
+ alias valid? name?
46
45
 
47
46
  def to_hash
48
47
  hash = super
@@ -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
@@ -1,24 +1,5 @@
1
1
  module OmniAuth
2
2
  class Builder < ::Rack::Builder
3
- def initialize(app, &block)
4
- @options = nil
5
- if rack14? || rack2?
6
- super
7
- else
8
- @app = app
9
- super(&block)
10
- @ins << @app
11
- end
12
- end
13
-
14
- def rack14?
15
- Rack.release.start_with?('1.') && (Rack.release.split('.')[1].to_i >= 4)
16
- end
17
-
18
- def rack2?
19
- Rack.release.start_with? '2.'
20
- end
21
-
22
3
  def on_failure(&block)
23
4
  OmniAuth.config.on_failure = block
24
5
  end
@@ -40,7 +21,8 @@ module OmniAuth
40
21
  end
41
22
 
42
23
  def options(options = false)
43
- return @options || {} if options == false
24
+ return @options ||= {} if options == false
25
+
44
26
  @options = options
45
27
  end
46
28
 
@@ -49,7 +31,7 @@ module OmniAuth
49
31
  middleware = klass
50
32
  else
51
33
  begin
52
- middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
34
+ middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s, false)
53
35
  rescue NameError
54
36
  raise(LoadError.new("Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."))
55
37
  end
@@ -22,22 +22,33 @@ module OmniAuth
22
22
  end
23
23
 
24
24
  def raise_out!
25
- fail(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type']))
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
+
31
+ new_path = "#{env['SCRIPT_NAME']}#{strategy_path_prefix}/failure?message=#{Rack::Utils.escape(message_key)}#{origin_query_param}#{strategy_name_query_param}"
31
32
  Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish
32
33
  end
33
34
 
35
+ def strategy_path_prefix
36
+ if env['omniauth.error.strategy']
37
+ env['omniauth.error.strategy'].path_prefix
38
+ else
39
+ OmniAuth.config.path_prefix
40
+ end
41
+ end
42
+
34
43
  def strategy_name_query_param
35
44
  return '' unless env['omniauth.error.strategy']
45
+
36
46
  "&strategy=#{env['omniauth.error.strategy'].name}"
37
47
  end
38
48
 
39
49
  def origin_query_param
40
50
  return '' unless env['omniauth.origin']
51
+
41
52
  "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
42
53
  end
43
54
  end
@@ -56,7 +56,7 @@ input {
56
56
  }
57
57
 
58
58
  input#identifier, input#openid_url {
59
- background: url(http://openid.net/login-bg.gif) no-repeat;
59
+ background: url(https://openid.net/images/login-bg.gif) no-repeat;
60
60
  background-position: 0 50%;
61
61
  padding-left: 18px;
62
62
  }