ls-omniauth 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +99 -0
- data/Rakefile +22 -0
- data/app/controllers/ls_omniauth/omniauth_controller.rb +60 -0
- data/app/helpers/ls_omniauth/omniauth_helper.rb +72 -0
- data/app/models/ls_omniauth/abstract_session.rb +17 -0
- data/app/models/ls_omniauth/auth_sessions.rb +10 -0
- data/app/models/ls_omniauth/config.rb +10 -0
- data/config/initializers/load_lsomniauth_config.rb +6 -0
- data/config/initializers/ls-omniauth.rb +11 -0
- data/config/routes.rb +6 -0
- data/lib/ls-omniauth.rb +4 -0
- data/lib/ls-omniauth/engine.rb +7 -0
- data/lib/ls-omniauth/version.rb +3 -0
- data/spec/controllers/ls_omniauth/omniauth_controller_spec.rb +56 -0
- data/spec/dummy/README.rdoc +5 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/private_controller.rb +5 -0
- data/spec/dummy/app/controllers/public_controller.rb +5 -0
- data/spec/dummy/app/controllers/secure_application_controller.rb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +63 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/ls-omniauth.yml +9 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/log/development.log +7 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/controllers/private_controller_spec.rb +39 -0
- data/spec/dummy/spec/controllers/public_controller_spec.rb +10 -0
- data/spec/dummy/spec/spec_helper.rb +27 -0
- data/spec/helpers/omniauth_helper_spec.rb +12 -0
- data/spec/ls_omniauth_spec.rb +6 -0
- data/spec/models/ls_omniauth/config_spec.rb +69 -0
- data/spec/spec_helper.rb +16 -0
- metadata +229 -0
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PrivateController, type: :controller do
|
4
|
+
describe "GET index" do
|
5
|
+
context "user is not logged in" do
|
6
|
+
it "redirects" do
|
7
|
+
get :index
|
8
|
+
expect(response).to redirect_to("/auth/sign_in")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "user is logged in but not in valid group" do
|
13
|
+
it "returns a 302" do
|
14
|
+
LsOmniauth::AuthSessions.new(session).auth.set('user@domain.com')
|
15
|
+
get :index
|
16
|
+
assert_response 401
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when running in dev mode" do
|
20
|
+
before(:each) {
|
21
|
+
expect(LS_OMNIAUTH.config).to receive(:[]).with(:dev_mode).and_return(true)
|
22
|
+
}
|
23
|
+
it "returns a 200" do
|
24
|
+
get :index
|
25
|
+
|
26
|
+
assert_response 200
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "user is logged in and is in valid group" do
|
32
|
+
it "returns a 200" do
|
33
|
+
LsOmniauth::AuthSessions.new(session).auth.set('dan.rabinowitz@hungrymachine.com')
|
34
|
+
get :index
|
35
|
+
assert_response 200
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path("../../config/environment.rb", __FILE__)
|
2
|
+
require 'rspec/rails'
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] = "test"
|
5
|
+
|
6
|
+
Rails.backtrace_cleaner.remove_silencers!
|
7
|
+
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
10
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
11
|
+
# loaded once.
|
12
|
+
#
|
13
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
# config.filter_run :focus
|
18
|
+
|
19
|
+
# Run specs in random order to surface order dependencies. If you find an
|
20
|
+
# order dependency and want to debug it, you can fix the order by providing
|
21
|
+
# the seed, which is printed after each run.
|
22
|
+
# --seed 1234
|
23
|
+
config.order = 'random'
|
24
|
+
|
25
|
+
config.infer_spec_type_from_file_location!
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LsOmniauth::OmniauthHelper, type: :helper do
|
4
|
+
describe "require_authentication" do
|
5
|
+
context "a user is logged in" do
|
6
|
+
it "returns true" do
|
7
|
+
LsOmniauth::AuthSessions.new(session).auth.set('user@domain.com')
|
8
|
+
expect(require_authentication).to eq(true)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LsOmniauth::Config do
|
4
|
+
let(:client_id) { "client_id" }
|
5
|
+
let(:client_secret) { "client_secret" }
|
6
|
+
let(:dev_mode) { true }
|
7
|
+
let(:environment) { double('Environment', production?: false)}
|
8
|
+
subject { LsOmniauth::Config.new({'client_id' => client_id, :client_secret => client_secret, :foo => "bar", :dev_mode => dev_mode, :environment => environment}) }
|
9
|
+
|
10
|
+
it "acts like a HWIA" do
|
11
|
+
expect(subject[:client_id]).to eq(client_id)
|
12
|
+
expect(subject['client_secret']).to eq(client_secret)
|
13
|
+
expect(subject[:foo]).to eq("bar")
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#valid?' do
|
17
|
+
context 'when client_id is nil' do
|
18
|
+
let(:client_id) { nil }
|
19
|
+
|
20
|
+
it 'returns false' do
|
21
|
+
expect(subject.valid?).to eq(false)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when client_secret is nil' do
|
26
|
+
let(:client_secret) { nil }
|
27
|
+
|
28
|
+
it 'returns false' do
|
29
|
+
expect(subject.valid?).to eq(false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when client_secret and client_id are present' do
|
34
|
+
it 'returns true' do
|
35
|
+
expect(subject.valid?).to eq(true)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#running_in_dev_mode?' do
|
41
|
+
context 'when dev_mode key is not true' do
|
42
|
+
let(:dev_mode) { false }
|
43
|
+
|
44
|
+
it 'returns false' do
|
45
|
+
expect(subject.running_in_dev_mode?).to eq(false)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when dev_mode key is true' do
|
50
|
+
let(:dev_mode) { true }
|
51
|
+
|
52
|
+
context 'and Rails is in production mode' do
|
53
|
+
before(:each) { expect(LS_OMNIAUTH).to receive(:environment).and_return(double('Environment', production?: true) ) }
|
54
|
+
|
55
|
+
it 'returns false' do
|
56
|
+
expect(subject.running_in_dev_mode?).to eq(false)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'and Rails is not in production mode' do
|
61
|
+
before(:each) { expect(LS_OMNIAUTH).to receive(:environment).and_return(double('Environment', production?: false) ) }
|
62
|
+
|
63
|
+
it 'returns false' do
|
64
|
+
expect(subject.running_in_dev_mode?).to eq(true)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
|
6
|
+
Rails.backtrace_cleaner.remove_silencers!
|
7
|
+
|
8
|
+
# Load support files
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :rspec
|
13
|
+
config.use_transactional_fixtures = true
|
14
|
+
config.infer_base_class_for_anonymous_controllers = false
|
15
|
+
config.order = "random"
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ls-omniauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul De Goes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rb-fsevent
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: omniauth
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: omniauth-google-oauth2
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A Gem for simplifying OpenId Authentication
|
112
|
+
email:
|
113
|
+
- paul.degoes@hungrymachine.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- MIT-LICENSE
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- app/controllers/ls_omniauth/omniauth_controller.rb
|
122
|
+
- app/helpers/ls_omniauth/omniauth_helper.rb
|
123
|
+
- app/models/ls_omniauth/abstract_session.rb
|
124
|
+
- app/models/ls_omniauth/auth_sessions.rb
|
125
|
+
- app/models/ls_omniauth/config.rb
|
126
|
+
- config/initializers/load_lsomniauth_config.rb
|
127
|
+
- config/initializers/ls-omniauth.rb
|
128
|
+
- config/routes.rb
|
129
|
+
- lib/ls-omniauth.rb
|
130
|
+
- lib/ls-omniauth/engine.rb
|
131
|
+
- lib/ls-omniauth/version.rb
|
132
|
+
- spec/controllers/ls_omniauth/omniauth_controller_spec.rb
|
133
|
+
- spec/dummy/README.rdoc
|
134
|
+
- spec/dummy/Rakefile
|
135
|
+
- spec/dummy/app/controllers/application_controller.rb
|
136
|
+
- spec/dummy/app/controllers/private_controller.rb
|
137
|
+
- spec/dummy/app/controllers/public_controller.rb
|
138
|
+
- spec/dummy/app/controllers/secure_application_controller.rb
|
139
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
140
|
+
- spec/dummy/config.ru
|
141
|
+
- spec/dummy/config/application.rb
|
142
|
+
- spec/dummy/config/boot.rb
|
143
|
+
- spec/dummy/config/environment.rb
|
144
|
+
- spec/dummy/config/environments/development.rb
|
145
|
+
- spec/dummy/config/environments/production.rb
|
146
|
+
- spec/dummy/config/environments/test.rb
|
147
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
148
|
+
- spec/dummy/config/initializers/inflections.rb
|
149
|
+
- spec/dummy/config/initializers/mime_types.rb
|
150
|
+
- spec/dummy/config/initializers/secret_token.rb
|
151
|
+
- spec/dummy/config/initializers/session_store.rb
|
152
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
153
|
+
- spec/dummy/config/locales/en.yml
|
154
|
+
- spec/dummy/config/ls-omniauth.yml
|
155
|
+
- spec/dummy/config/routes.rb
|
156
|
+
- spec/dummy/log/development.log
|
157
|
+
- spec/dummy/public/404.html
|
158
|
+
- spec/dummy/public/422.html
|
159
|
+
- spec/dummy/public/500.html
|
160
|
+
- spec/dummy/public/favicon.ico
|
161
|
+
- spec/dummy/script/rails
|
162
|
+
- spec/dummy/spec/controllers/private_controller_spec.rb
|
163
|
+
- spec/dummy/spec/controllers/public_controller_spec.rb
|
164
|
+
- spec/dummy/spec/spec_helper.rb
|
165
|
+
- spec/helpers/omniauth_helper_spec.rb
|
166
|
+
- spec/ls_omniauth_spec.rb
|
167
|
+
- spec/models/ls_omniauth/config_spec.rb
|
168
|
+
- spec/spec_helper.rb
|
169
|
+
homepage:
|
170
|
+
licenses: []
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.4.5.1
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: A Gem for simplifying OpenId Authentication
|
192
|
+
test_files:
|
193
|
+
- spec/controllers/ls_omniauth/omniauth_controller_spec.rb
|
194
|
+
- spec/dummy/app/controllers/application_controller.rb
|
195
|
+
- spec/dummy/app/controllers/private_controller.rb
|
196
|
+
- spec/dummy/app/controllers/public_controller.rb
|
197
|
+
- spec/dummy/app/controllers/secure_application_controller.rb
|
198
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
199
|
+
- spec/dummy/config/application.rb
|
200
|
+
- spec/dummy/config/boot.rb
|
201
|
+
- spec/dummy/config/environment.rb
|
202
|
+
- spec/dummy/config/environments/development.rb
|
203
|
+
- spec/dummy/config/environments/production.rb
|
204
|
+
- spec/dummy/config/environments/test.rb
|
205
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
206
|
+
- spec/dummy/config/initializers/inflections.rb
|
207
|
+
- spec/dummy/config/initializers/mime_types.rb
|
208
|
+
- spec/dummy/config/initializers/secret_token.rb
|
209
|
+
- spec/dummy/config/initializers/session_store.rb
|
210
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
211
|
+
- spec/dummy/config/locales/en.yml
|
212
|
+
- spec/dummy/config/ls-omniauth.yml
|
213
|
+
- spec/dummy/config/routes.rb
|
214
|
+
- spec/dummy/config.ru
|
215
|
+
- spec/dummy/log/development.log
|
216
|
+
- spec/dummy/public/404.html
|
217
|
+
- spec/dummy/public/422.html
|
218
|
+
- spec/dummy/public/500.html
|
219
|
+
- spec/dummy/public/favicon.ico
|
220
|
+
- spec/dummy/Rakefile
|
221
|
+
- spec/dummy/README.rdoc
|
222
|
+
- spec/dummy/script/rails
|
223
|
+
- spec/dummy/spec/controllers/private_controller_spec.rb
|
224
|
+
- spec/dummy/spec/controllers/public_controller_spec.rb
|
225
|
+
- spec/dummy/spec/spec_helper.rb
|
226
|
+
- spec/helpers/omniauth_helper_spec.rb
|
227
|
+
- spec/ls_omniauth_spec.rb
|
228
|
+
- spec/models/ls_omniauth/config_spec.rb
|
229
|
+
- spec/spec_helper.rb
|