omniauth-elitmus 0.2.0 → 0.2.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/rubyonrails.yml +6 -21
- data/.rubocop.yml +22 -0
- data/Gemfile +6 -4
- data/Gemfile.lock +171 -0
- data/Rakefile +10 -1
- data/lib/omniauth/elitmus/version.rb +3 -1
- data/lib/omniauth/elitmus.rb +2 -0
- data/lib/omniauth/strategies/elitmus.rb +63 -56
- data/lib/omniauth-elitmus.rb +3 -1
- data/omniauth-elitmus.gemspec +15 -13
- data/test/helper.rb +10 -10
- data/test/support/shared_example.rb +16 -14
- data/test/test.rb +27 -27
- metadata +13 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bed8eb52063dadd06f0b71219cf5b0217b6fd0bdd089d1c0bdd08e1f7a7c509
|
|
4
|
+
data.tar.gz: 3b8ad318cb177a44d5caa0619a65308f4be820eaff56369aa00101055878b083
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 627cab09fb250d8ed67581b029541fa58d59ea69021870928f3a2c4eeb45283146d1de69503ab7cbc6e923524b12144762317ff31fdefe974c377820068a3ef2
|
|
7
|
+
data.tar.gz: c3c1f735331208fe04135e64bf18314d9b4b725da561e5d72d1a55d9b0309eac5dd7f275f5443beaca5bcdafcc7643ef707d13a2c421eff5f6415bb6b4e2acdb
|
|
@@ -13,32 +13,16 @@ on:
|
|
|
13
13
|
jobs:
|
|
14
14
|
test:
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
|
-
services:
|
|
17
|
-
postgres:
|
|
18
|
-
image: postgres:11-alpine
|
|
19
|
-
ports:
|
|
20
|
-
- "5432:5432"
|
|
21
|
-
env:
|
|
22
|
-
POSTGRES_DB: rails_test
|
|
23
|
-
POSTGRES_USER: rails
|
|
24
|
-
POSTGRES_PASSWORD: password
|
|
25
|
-
env:
|
|
26
|
-
RAILS_ENV: test
|
|
27
|
-
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
|
|
28
16
|
steps:
|
|
29
17
|
- name: Checkout code
|
|
30
18
|
uses: actions/checkout@v4
|
|
31
|
-
# Add or replace dependency steps here
|
|
32
19
|
- name: Install Ruby and gems
|
|
33
|
-
uses: ruby/setup-ruby@
|
|
20
|
+
uses: ruby/setup-ruby@v1
|
|
34
21
|
with:
|
|
22
|
+
ruby-version: '4.0.5'
|
|
35
23
|
bundler-cache: true
|
|
36
|
-
# Add or replace database setup steps here
|
|
37
|
-
- name: Set up database schema
|
|
38
|
-
run: bin/rails db:schema:load
|
|
39
|
-
# Add or replace test runners here
|
|
40
24
|
- name: Run tests
|
|
41
|
-
run:
|
|
25
|
+
run: bundle exec rake test
|
|
42
26
|
|
|
43
27
|
lint:
|
|
44
28
|
runs-on: ubuntu-latest
|
|
@@ -46,8 +30,9 @@ jobs:
|
|
|
46
30
|
- name: Checkout code
|
|
47
31
|
uses: actions/checkout@v4
|
|
48
32
|
- name: Install Ruby and gems
|
|
49
|
-
uses: ruby/setup-ruby@
|
|
33
|
+
uses: ruby/setup-ruby@v1
|
|
50
34
|
with:
|
|
35
|
+
ruby-version: '4.0.5'
|
|
51
36
|
bundler-cache: true
|
|
52
37
|
- name: Generate binstubs
|
|
53
38
|
run: bundle binstubs bundler-audit brakeman rubocop
|
|
@@ -55,6 +40,6 @@ jobs:
|
|
|
55
40
|
- name: Security audit dependencies
|
|
56
41
|
run: bin/bundler-audit --update
|
|
57
42
|
- name: Security audit application code
|
|
58
|
-
run: bin/brakeman -q -w2
|
|
43
|
+
run: bin/brakeman -q -w2 --force
|
|
59
44
|
- name: Lint Ruby files
|
|
60
45
|
run: bin/rubocop --parallel
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
TargetRubyVersion: 3.1
|
|
4
|
+
Exclude:
|
|
5
|
+
- 'bin/**/*'
|
|
6
|
+
- 'coverage/**/*'
|
|
7
|
+
- 'vendor/**/*'
|
|
8
|
+
|
|
9
|
+
Naming/FileName:
|
|
10
|
+
Exclude:
|
|
11
|
+
- 'lib/omniauth-elitmus.rb'
|
|
12
|
+
|
|
13
|
+
Style/Documentation:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
Gemspec/DevelopmentDependencies:
|
|
17
|
+
Enabled: false
|
|
18
|
+
|
|
19
|
+
Metrics/BlockLength:
|
|
20
|
+
Exclude:
|
|
21
|
+
- 'test/**/*'
|
|
22
|
+
- '*.gemspec'
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in ..gemspec
|
|
4
6
|
gemspec
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
gem '
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem 'brakeman'
|
|
10
|
+
gem 'bundler-audit'
|
|
11
|
+
gem 'rubocop'
|
|
8
12
|
end
|
|
9
|
-
|
|
10
|
-
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
omniauth-elitmus (0.2.1)
|
|
5
|
+
omniauth-oauth2 (~> 1.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
anonymous_loader (0.1.3)
|
|
11
|
+
version_gem (~> 1.1, >= 1.1.14)
|
|
12
|
+
ast (2.4.3)
|
|
13
|
+
auth-sanitizer (0.2.3)
|
|
14
|
+
version_gem (~> 1.1, >= 1.1.14)
|
|
15
|
+
base64 (0.3.0)
|
|
16
|
+
bigdecimal (4.1.2)
|
|
17
|
+
brakeman (8.0.6)
|
|
18
|
+
racc
|
|
19
|
+
bundler-audit (0.9.3)
|
|
20
|
+
bundler (>= 1.2.0)
|
|
21
|
+
thor (~> 1.0)
|
|
22
|
+
docile (1.4.1)
|
|
23
|
+
faraday (2.14.3)
|
|
24
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
25
|
+
json
|
|
26
|
+
logger
|
|
27
|
+
faraday-net_http (3.4.4)
|
|
28
|
+
net-http (~> 0.5)
|
|
29
|
+
hashie (5.1.0)
|
|
30
|
+
logger
|
|
31
|
+
json (2.21.2)
|
|
32
|
+
jwt (3.2.0)
|
|
33
|
+
base64
|
|
34
|
+
language_server-protocol (3.17.0.6)
|
|
35
|
+
lint_roller (1.1.0)
|
|
36
|
+
logger (1.7.0)
|
|
37
|
+
minitest (5.27.0)
|
|
38
|
+
mocha (2.8.2)
|
|
39
|
+
ruby2_keywords (>= 0.0.5)
|
|
40
|
+
multi_xml (0.9.1)
|
|
41
|
+
bigdecimal (>= 3.1, < 5)
|
|
42
|
+
net-http (0.9.1)
|
|
43
|
+
uri (>= 0.11.1)
|
|
44
|
+
oauth2 (2.0.25)
|
|
45
|
+
anonymous_loader (~> 0.1, >= 0.1.3)
|
|
46
|
+
auth-sanitizer (~> 0.2, >= 0.2.3)
|
|
47
|
+
faraday (>= 0.17.3, < 4.0)
|
|
48
|
+
jwt (>= 1.0, < 4.0)
|
|
49
|
+
logger (~> 1.2)
|
|
50
|
+
multi_xml (~> 0.5)
|
|
51
|
+
rack (>= 1.2, < 4)
|
|
52
|
+
snaky_hash (~> 2.0, >= 2.0.7)
|
|
53
|
+
version_gem (~> 1.1, >= 1.1.14)
|
|
54
|
+
omniauth (2.1.4)
|
|
55
|
+
hashie (>= 3.4.6)
|
|
56
|
+
logger
|
|
57
|
+
rack (>= 2.2.3)
|
|
58
|
+
rack-protection
|
|
59
|
+
omniauth-oauth2 (1.9.0)
|
|
60
|
+
oauth2 (>= 2.0.2, < 3)
|
|
61
|
+
omniauth (~> 2.0)
|
|
62
|
+
parallel (2.1.0)
|
|
63
|
+
parser (3.3.12.0)
|
|
64
|
+
ast (~> 2.4.1)
|
|
65
|
+
racc
|
|
66
|
+
prism (1.9.0)
|
|
67
|
+
racc (1.8.1)
|
|
68
|
+
rack (3.2.7)
|
|
69
|
+
rack-protection (4.2.1)
|
|
70
|
+
base64 (>= 0.1.0)
|
|
71
|
+
logger (>= 1.6.0)
|
|
72
|
+
rack (>= 3.0.0, < 4)
|
|
73
|
+
rainbow (3.1.1)
|
|
74
|
+
rake (13.4.2)
|
|
75
|
+
regexp_parser (2.12.0)
|
|
76
|
+
rubocop (1.89.0)
|
|
77
|
+
json (~> 2.3)
|
|
78
|
+
language_server-protocol (~> 3.17.0.2)
|
|
79
|
+
lint_roller (~> 1.1.0)
|
|
80
|
+
parallel (>= 1.10)
|
|
81
|
+
parser (>= 3.3.0.2)
|
|
82
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
83
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
84
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
85
|
+
ruby-progressbar (~> 1.7)
|
|
86
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
87
|
+
rubocop-ast (1.50.0)
|
|
88
|
+
parser (>= 3.3.7.2)
|
|
89
|
+
prism (~> 1.7)
|
|
90
|
+
ruby-progressbar (1.13.0)
|
|
91
|
+
ruby2_keywords (0.0.5)
|
|
92
|
+
simplecov (0.22.0)
|
|
93
|
+
docile (~> 1.1)
|
|
94
|
+
simplecov-html (~> 0.11)
|
|
95
|
+
simplecov_json_formatter (~> 0.1)
|
|
96
|
+
simplecov-html (0.13.2)
|
|
97
|
+
simplecov_json_formatter (0.1.4)
|
|
98
|
+
snaky_hash (2.0.7)
|
|
99
|
+
hashie (>= 0.1.0, < 6)
|
|
100
|
+
version_gem (~> 1.1, >= 1.1.14)
|
|
101
|
+
thor (1.5.0)
|
|
102
|
+
unicode-display_width (3.2.0)
|
|
103
|
+
unicode-emoji (~> 4.1)
|
|
104
|
+
unicode-emoji (4.2.0)
|
|
105
|
+
uri (1.1.1)
|
|
106
|
+
version_gem (1.1.15)
|
|
107
|
+
|
|
108
|
+
PLATFORMS
|
|
109
|
+
ruby
|
|
110
|
+
x86_64-linux
|
|
111
|
+
|
|
112
|
+
DEPENDENCIES
|
|
113
|
+
brakeman
|
|
114
|
+
bundler-audit
|
|
115
|
+
minitest (~> 5.25)
|
|
116
|
+
mocha (~> 2.1)
|
|
117
|
+
omniauth-elitmus!
|
|
118
|
+
rake (~> 13.0)
|
|
119
|
+
rubocop
|
|
120
|
+
simplecov (~> 0.22)
|
|
121
|
+
|
|
122
|
+
CHECKSUMS
|
|
123
|
+
anonymous_loader (0.1.3) sha256=084a18e2439144d955447dc11dfc982f41fcd1583ad32d4d55151325dc44cb55
|
|
124
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
125
|
+
auth-sanitizer (0.2.3) sha256=db10aac92cfbe4c64ab637eebcbe1d67395d1694798041362173370f59933e3c
|
|
126
|
+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
127
|
+
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
|
|
128
|
+
brakeman (8.0.6) sha256=759cc69341115e6c2dcd47b6fd8649a0b9bd540e3585ac8a0a94e31c66fee386
|
|
129
|
+
bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9
|
|
130
|
+
docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
|
|
131
|
+
faraday (2.14.3) sha256=1882247e6766615c8220b4392bf1d27f6ebb63d8e28267587cef1fb0bf37f278
|
|
132
|
+
faraday-net_http (3.4.4) sha256=0e78af151747ed1b00f33e25973b4bc220d7f16c00c39676817c8b12331eb588
|
|
133
|
+
hashie (5.1.0) sha256=c266471896f323c446ea8207f8ffac985d2718df0a0ba98651a3057096ca3870
|
|
134
|
+
json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
|
|
135
|
+
jwt (3.2.0) sha256=5419b1fe37b1da0982bd07051f573a8b8789ab724c2aa7e785e4784a3ed217d7
|
|
136
|
+
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
|
|
137
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
138
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
139
|
+
minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
|
|
140
|
+
mocha (2.8.2) sha256=1f77e729db47e72b4ef776461ce20caeec2572ffdf23365b0a03608fee8f4eee
|
|
141
|
+
multi_xml (0.9.1) sha256=7ce766b59c17241ed62976caeae1fae9b2431b263398c35396239a68c4a64e57
|
|
142
|
+
net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
|
|
143
|
+
oauth2 (2.0.25) sha256=2f736a2f93c2caa67c1b08dc3c9889bb907d62643f3183fefaa1723cba6a82ac
|
|
144
|
+
omniauth (2.1.4) sha256=42a05b0496f0d22e1dd85d42aaf602f064e36bb47a6826a27ab55e5ba608763c
|
|
145
|
+
omniauth-elitmus (0.2.1)
|
|
146
|
+
omniauth-oauth2 (1.9.0) sha256=ed15f6d9d20991807ce114cc5b9c1453bce3645b64e51c68c90cff5ff153fee8
|
|
147
|
+
parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
|
|
148
|
+
parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
|
|
149
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
150
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
151
|
+
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
|
|
152
|
+
rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac
|
|
153
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
154
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
155
|
+
regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
|
|
156
|
+
rubocop (1.89.0) sha256=4dee8e3ee9c45e474834efd9e8d6fd031e8331c8dacdff0de4ad65ae0a6faae7
|
|
157
|
+
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
|
|
158
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
159
|
+
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
|
|
160
|
+
simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
|
|
161
|
+
simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
|
|
162
|
+
simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
|
|
163
|
+
snaky_hash (2.0.7) sha256=7d02c70012a3f932e48860cd024577908300c9aa615e0cb9b450aaa749cbcb4d
|
|
164
|
+
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
|
|
165
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
166
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
167
|
+
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
|
|
168
|
+
version_gem (1.1.15) sha256=a73241587b29252e3567e0c818ded80730eb754d43b508f6ce4db22ca9ba27d0
|
|
169
|
+
|
|
170
|
+
BUNDLED WITH
|
|
171
|
+
4.0.10
|
data/Rakefile
CHANGED
data/lib/omniauth/elitmus.rb
CHANGED
|
@@ -1,61 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'omniauth/strategies/oauth2'
|
|
2
4
|
require 'uri'
|
|
3
5
|
|
|
4
6
|
module OmniAuth
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
7
|
+
module Strategies
|
|
8
|
+
class Elitmus < OmniAuth::Strategies::OAuth2
|
|
9
|
+
# class NoAuthorizationCodeError < StandardError; en
|
|
10
|
+
DEFAULT_SCOPE = 'public'
|
|
11
|
+
|
|
12
|
+
# OATUH2_PROVIDER_URL = "https://www.elitmus.com"
|
|
13
|
+
option :name, :elitmus
|
|
14
|
+
|
|
15
|
+
option :client_options, {
|
|
16
|
+
site: 'https://www.elitmus.com'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
option :authorize_options, %i[scope auth_type disable_external_sso]
|
|
20
|
+
|
|
21
|
+
uid { raw_info['id'] }
|
|
22
|
+
|
|
23
|
+
info do
|
|
24
|
+
prune!({
|
|
25
|
+
'email' => raw_info['email'],
|
|
26
|
+
'name' => raw_info['name']
|
|
27
|
+
})
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
extra do
|
|
31
|
+
hash = {}
|
|
32
|
+
hash['raw_info'] = raw_info unless skip_info?
|
|
33
|
+
prune! hash
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def raw_info
|
|
37
|
+
@raw_info ||= access_token.get('/api/v1/me').parsed
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def authorize_params
|
|
41
|
+
super.tap do |params|
|
|
42
|
+
%w[scope auth_type disable_external_sso].each do |v|
|
|
43
|
+
params[v.to_sym] = request.params[v] if request.params[v]
|
|
44
|
+
end
|
|
45
|
+
params[:scope] ||= DEFAULT_SCOPE
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def callback_url
|
|
50
|
+
# NOTE: intentionally NOT calling `super` here. OmniAuth's default
|
|
51
|
+
# callback_url is `full_host + callback_path + query_string`, where
|
|
52
|
+
# query_string is whatever happens to be on the CURRENT request. That
|
|
53
|
+
# makes redirect_uri drift between the /authorize request (which may
|
|
54
|
+
# carry extra params like disable_external_sso) and the token-exchange
|
|
55
|
+
# request (which additionally has code/state on it) - and OAuth2
|
|
56
|
+
# requires both to match exactly, so any drift breaks the exchange.
|
|
57
|
+
options[:callback_url] || (full_host + callback_path)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def prune!(hash)
|
|
61
|
+
hash.delete_if do |_, value|
|
|
62
|
+
prune!(value) if value.is_a?(Hash)
|
|
63
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
61
68
|
end
|
data/lib/omniauth-elitmus.rb
CHANGED
data/omniauth-elitmus.gemspec
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
|
3
4
|
require 'omniauth/elitmus/version'
|
|
4
5
|
|
|
5
6
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
7
|
+
spec.name = 'omniauth-elitmus'
|
|
7
8
|
spec.version = Omniauth::Elitmus::VERSION
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
9
|
+
spec.authors = ['Shireesh Jayashetty']
|
|
10
|
+
spec.email = ['shireesh@elitmus.com']
|
|
10
11
|
spec.summary = 'eLitmus OAuth2 Strategy for OmniAuth'
|
|
11
|
-
spec.homepage =
|
|
12
|
-
spec.license =
|
|
12
|
+
spec.homepage = 'https://github.com/elitmus/omniauth-elitmus'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
|
+
spec.required_ruby_version = '>= 3.1.5'
|
|
13
15
|
|
|
14
16
|
spec.files = `git ls-files`.split("\n")
|
|
15
|
-
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
17
|
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
17
|
-
spec.require_paths = [
|
|
18
|
+
spec.require_paths = ['lib']
|
|
18
19
|
|
|
19
|
-
spec.
|
|
20
|
+
spec.add_dependency 'omniauth-oauth2', '~> 1.8'
|
|
20
21
|
|
|
21
22
|
spec.add_development_dependency 'minitest', '~> 5.25'
|
|
22
|
-
spec.add_development_dependency 'mocha', '~>1
|
|
23
|
-
spec.add_development_dependency
|
|
24
|
-
spec.add_development_dependency 'simplecov'
|
|
23
|
+
spec.add_development_dependency 'mocha', '~> 2.1'
|
|
24
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.22'
|
|
26
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
25
27
|
end
|
data/test/helper.rb
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'bundler/setup'
|
|
2
4
|
require 'minitest/autorun'
|
|
3
|
-
require 'mocha/
|
|
4
|
-
# require "codeclimate-test-reporter"
|
|
5
|
-
# CodeClimate::TestReporter.start
|
|
6
|
-
|
|
5
|
+
require 'mocha/minitest'
|
|
7
6
|
require 'simplecov'
|
|
8
7
|
SimpleCov.start
|
|
9
8
|
|
|
@@ -12,22 +11,23 @@ require 'omniauth/strategies/elitmus'
|
|
|
12
11
|
OmniAuth.config.test_mode = true
|
|
13
12
|
|
|
14
13
|
module BlockTestHelper
|
|
15
|
-
def test(name, &
|
|
14
|
+
def test(name, &)
|
|
16
15
|
method_name = "test_#{name.gsub(/\s+/, '_')}"
|
|
17
|
-
raise "Method already defined: #{method_name}" if
|
|
18
|
-
|
|
16
|
+
raise "Method already defined: #{method_name}" if method_defined?(method_name.to_sym)
|
|
17
|
+
|
|
18
|
+
define_method(method_name, &)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
module CustomAssertions
|
|
23
23
|
def assert_has_key(key, hash, msg = nil)
|
|
24
24
|
msg = message(msg) { "Expected #{hash.inspect} to have key #{key.inspect}" }
|
|
25
|
-
assert hash.
|
|
25
|
+
assert hash.key?(key), msg
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def refute_has_key(key, hash, msg = nil)
|
|
29
29
|
msg = message(msg) { "Expected #{hash.inspect} not to have key #{key.inspect}" }
|
|
30
|
-
refute hash.
|
|
30
|
+
refute hash.key?(key), msg
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -59,4 +59,4 @@ class StrategyTestCase < TestCase
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
Dir[File.expand_path('
|
|
62
|
+
Dir[File.expand_path('support/**/*', __dir__)].each(&method(:require))
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# NOTE: it would be useful if this lived in omniauth-oauth2 eventually
|
|
2
4
|
module OAuth2StrategyTests
|
|
3
5
|
def self.included(base)
|
|
4
6
|
base.class_eval do
|
|
@@ -8,33 +10,33 @@ module OAuth2StrategyTests
|
|
|
8
10
|
include TokenParamsTests
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
|
-
|
|
13
|
+
|
|
12
14
|
module ClientTests
|
|
13
15
|
extend BlockTestHelper
|
|
14
|
-
|
|
16
|
+
|
|
15
17
|
test 'should be initialized with symbolized client_options' do
|
|
16
|
-
@options = { :
|
|
18
|
+
@options = { client_options: { 'authorize_url' => 'https://example.com' } }
|
|
17
19
|
assert_equal 'https://example.com', strategy.client.options[:authorize_url]
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
module AuthorizeParamsTests
|
|
22
24
|
extend BlockTestHelper
|
|
23
|
-
|
|
25
|
+
|
|
24
26
|
test 'should include any authorize params passed in the :authorize_params option' do
|
|
25
|
-
@options = { :
|
|
27
|
+
@options = { authorize_params: { foo: 'bar', baz: 'zip' } }
|
|
26
28
|
assert_equal 'bar', strategy.authorize_params['foo']
|
|
27
29
|
assert_equal 'zip', strategy.authorize_params['baz']
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
test 'should include top-level options that are marked as :authorize_options' do
|
|
31
|
-
@options = { :
|
|
33
|
+
@options = { authorize_options: %i[scope foo], scope: 'bar', foo: 'baz' }
|
|
32
34
|
assert_equal 'bar', strategy.authorize_params['scope']
|
|
33
35
|
assert_equal 'baz', strategy.authorize_params['foo']
|
|
34
36
|
end
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
test 'should exclude top-level options that are not passed' do
|
|
37
|
-
@options = { :
|
|
39
|
+
@options = { authorize_options: [:bar] }
|
|
38
40
|
refute_has_key :bar, strategy.authorize_params
|
|
39
41
|
refute_has_key 'bar', strategy.authorize_params
|
|
40
42
|
end
|
|
@@ -51,7 +53,7 @@ module OAuth2StrategyTests
|
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
test 'should not store state in the session when present in authorize params vs. a random one' do
|
|
54
|
-
@options = { :
|
|
56
|
+
@options = { authorize_params: { state: 'bar' } }
|
|
55
57
|
refute_empty strategy.authorize_params['state']
|
|
56
58
|
refute_equal 'bar', strategy.authorize_params[:state]
|
|
57
59
|
refute_empty strategy.session['omniauth.state']
|
|
@@ -69,17 +71,17 @@ module OAuth2StrategyTests
|
|
|
69
71
|
|
|
70
72
|
module TokenParamsTests
|
|
71
73
|
extend BlockTestHelper
|
|
72
|
-
|
|
74
|
+
|
|
73
75
|
test 'should include any authorize params passed in the :token_params option' do
|
|
74
|
-
@options = { :
|
|
76
|
+
@options = { token_params: { foo: 'bar', baz: 'zip' } }
|
|
75
77
|
assert_equal 'bar', strategy.token_params['foo']
|
|
76
78
|
assert_equal 'zip', strategy.token_params['baz']
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
test 'should include top-level options that are marked as :token_options' do
|
|
80
|
-
@options = { :
|
|
82
|
+
@options = { token_options: %i[scope foo], scope: 'bar', foo: 'baz' }
|
|
81
83
|
assert_equal 'bar', strategy.token_params['scope']
|
|
82
84
|
assert_equal 'baz', strategy.token_params['foo']
|
|
83
85
|
end
|
|
84
86
|
end
|
|
85
|
-
end
|
|
87
|
+
end
|
data/test/test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'helper'
|
|
2
4
|
require 'omniauth-elitmus'
|
|
3
5
|
|
|
@@ -11,46 +13,44 @@ class ClientTest < StrategyTestCase
|
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
test 'has correct default authorize url' do
|
|
14
|
-
assert_equal '
|
|
16
|
+
assert_equal 'oauth/authorize', strategy.client.options[:authorize_url]
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
test 'has correct default token url' do
|
|
18
|
-
assert_equal '
|
|
20
|
+
assert_equal 'oauth/token', strategy.client.options[:token_url]
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
test 'should be initialized with only site option in symbolized client_options' do
|
|
22
|
-
@options = { :
|
|
24
|
+
@options = { client_options: { 'site' => 'https://codephode.com' } }
|
|
23
25
|
assert_equal 'https://codephode.com', strategy.client.site
|
|
24
|
-
assert_equal '
|
|
25
|
-
assert_equal '
|
|
26
|
+
assert_equal 'oauth/authorize', strategy.client.options[:authorize_url]
|
|
27
|
+
assert_equal 'oauth/token', strategy.client.options[:token_url]
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
test 'should be initialized with site and authorize_url in symbolized client_options' do
|
|
29
|
-
@options = { :
|
|
31
|
+
@options = { client_options: { 'site' => 'https://codephode.com', 'authorize_url' => '/custom/auth' } }
|
|
30
32
|
assert_equal 'https://codephode.com', strategy.client.site
|
|
31
33
|
assert_equal '/custom/auth', strategy.client.options[:authorize_url]
|
|
32
|
-
assert_equal '
|
|
34
|
+
assert_equal 'oauth/token', strategy.client.options[:token_url]
|
|
33
35
|
end
|
|
34
36
|
|
|
35
|
-
|
|
36
37
|
test 'should be initialized with site and token_url in symbolized client_options' do
|
|
37
|
-
@options = { :
|
|
38
|
+
@options = { client_options: { 'site' => 'https://codephode.com', 'token_url' => '/custom/token' } }
|
|
38
39
|
assert_equal 'https://codephode.com', strategy.client.site
|
|
39
|
-
assert_equal '
|
|
40
|
+
assert_equal 'oauth/authorize', strategy.client.options[:authorize_url]
|
|
40
41
|
assert_equal '/custom/token', strategy.client.options[:token_url]
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
test 'should be initialized with symbolized client_options' do
|
|
44
|
-
@options = { :
|
|
45
|
+
@options = { client_options: { 'site' => 'https://staging.shrey.com', 'authorize_url' => '/custom/auth', 'token_url' => '/custom/token' } }
|
|
45
46
|
assert_equal 'https://staging.shrey.com', strategy.client.site
|
|
46
47
|
assert_equal '/custom/auth', strategy.client.options[:authorize_url]
|
|
47
48
|
assert_equal '/custom/token', strategy.client.options[:token_url]
|
|
48
49
|
end
|
|
49
|
-
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
class CallbackUrlTest < StrategyTestCase
|
|
53
|
-
test
|
|
53
|
+
test 'returns the default callback url' do
|
|
54
54
|
url_base = 'http://myconsumerapp.authrequest.com'
|
|
55
55
|
@request.stubs(:url).returns("#{url_base}/some/page")
|
|
56
56
|
strategy.stubs(:script_name).returns('') # as not to depend on Rack env
|
|
@@ -58,7 +58,7 @@ class CallbackUrlTest < StrategyTestCase
|
|
|
58
58
|
assert_equal "#{url_base}/auth/elitmus/callback", strategy.callback_url
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
test
|
|
61
|
+
test 'returns path from callback_path option' do
|
|
62
62
|
# @options = { :callback_path => "/auth/some/custom/path/callback"}
|
|
63
63
|
url_base = 'http://myconsumerapp.authrequest.com'
|
|
64
64
|
@request.stubs(:url).returns("#{url_base}/page/path")
|
|
@@ -67,18 +67,16 @@ class CallbackUrlTest < StrategyTestCase
|
|
|
67
67
|
assert_equal "#{url_base}/auth/some/custom/path/callback", strategy.callback_url
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
test
|
|
70
|
+
test 'returns url from callback_url option' do
|
|
71
71
|
url = 'http://myconsumerapp.authrequest.com/auth/elitmus/callback'
|
|
72
|
-
@options = { :
|
|
72
|
+
@options = { callback_url: url }
|
|
73
73
|
assert_equal url, strategy.callback_url
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
class AuthorizeParamsTest < StrategyTestCase
|
|
78
|
-
|
|
79
|
-
|
|
80
78
|
test 'should include top-level options with their default values if marked as :authorize_options' do
|
|
81
|
-
@options = { :
|
|
79
|
+
@options = { authorize_options: %i[scope foo], foo: 'baz' }
|
|
82
80
|
assert_equal 'public', strategy.authorize_params['scope']
|
|
83
81
|
assert_equal 'baz', strategy.authorize_params['foo']
|
|
84
82
|
end
|
|
@@ -94,6 +92,12 @@ class AuthorizeParamsTest < StrategyTestCase
|
|
|
94
92
|
assert_equal 'reauthenticate', strategy.authorize_params[:auth_type]
|
|
95
93
|
end
|
|
96
94
|
|
|
95
|
+
test 'includes disable_external_sso parameter from request when present' do
|
|
96
|
+
@request.stubs(:params).returns({ 'disable_external_sso' => 'true' })
|
|
97
|
+
assert strategy.authorize_params.is_a?(Hash)
|
|
98
|
+
assert_equal 'true', strategy.authorize_params[:disable_external_sso]
|
|
99
|
+
end
|
|
100
|
+
|
|
97
101
|
test 'overrides default scope with parameter passed from request' do
|
|
98
102
|
@request.stubs(:params).returns({ 'scope' => 'admin' })
|
|
99
103
|
assert strategy.authorize_params.is_a?(Hash)
|
|
@@ -113,7 +117,7 @@ class UidTest < StrategyTestCase
|
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
class InfoTestOptionalDataPresent < StrategyTestCase
|
|
116
|
-
|
|
120
|
+
def setup
|
|
117
121
|
super
|
|
118
122
|
@raw_info ||= { 'name' => 'Fred Smith' }
|
|
119
123
|
strategy.stubs(:raw_info).returns(@raw_info)
|
|
@@ -127,7 +131,6 @@ class InfoTestOptionalDataPresent < StrategyTestCase
|
|
|
127
131
|
@raw_info['email'] = 'fred@smith.com'
|
|
128
132
|
assert_equal 'fred@smith.com', strategy.info['email']
|
|
129
133
|
end
|
|
130
|
-
|
|
131
134
|
end
|
|
132
135
|
|
|
133
136
|
class InfoTestOptionalDataNotPresent < StrategyTestCase
|
|
@@ -175,18 +178,16 @@ class RawInfoTest < StrategyTestCase
|
|
|
175
178
|
super
|
|
176
179
|
@access_token = stub('OAuth2::AccessToken')
|
|
177
180
|
@appsecret_proof = 'appsecret_proof'
|
|
178
|
-
@options = {:
|
|
181
|
+
@options = { appsecret_proof: @appsecret_proof }
|
|
179
182
|
end
|
|
180
183
|
|
|
181
184
|
test 'should not include raw_info in extras hash when skip_info is specified' do
|
|
182
|
-
@options = { :
|
|
183
|
-
strategy.stubs(:raw_info).returns({:
|
|
185
|
+
@options = { skip_info: true }
|
|
186
|
+
strategy.stubs(:raw_info).returns({ foo: 'bar' })
|
|
184
187
|
refute_has_key 'raw_info', strategy.extra
|
|
185
188
|
end
|
|
186
189
|
end
|
|
187
190
|
|
|
188
|
-
|
|
189
|
-
|
|
190
191
|
class CredentialsTest < StrategyTestCase
|
|
191
192
|
def setup
|
|
192
193
|
super
|
|
@@ -253,5 +254,4 @@ class ExtraTest < StrategyTestCase
|
|
|
253
254
|
test 'contains raw info' do
|
|
254
255
|
assert_equal({ 'raw_info' => @raw_info }, strategy.extra)
|
|
255
256
|
end
|
|
256
|
-
|
|
257
257
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-elitmus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shireesh Jayashetty
|
|
@@ -43,14 +43,14 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1
|
|
46
|
+
version: '2.1'
|
|
47
47
|
type: :development
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1
|
|
53
|
+
version: '2.1'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: rake
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -69,16 +69,16 @@ dependencies:
|
|
|
69
69
|
name: simplecov
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0'
|
|
74
|
+
version: '0.22'
|
|
75
75
|
type: :development
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '0'
|
|
81
|
+
version: '0.22'
|
|
82
82
|
email:
|
|
83
83
|
- shireesh@elitmus.com
|
|
84
84
|
executables: []
|
|
@@ -88,9 +88,11 @@ files:
|
|
|
88
88
|
- ".github/workflows/generator-generic-ossf-slsa3-publish.yml"
|
|
89
89
|
- ".github/workflows/rubyonrails.yml"
|
|
90
90
|
- ".gitignore"
|
|
91
|
+
- ".rubocop.yml"
|
|
91
92
|
- ".tool-versions"
|
|
92
93
|
- ".travis.yml"
|
|
93
94
|
- Gemfile
|
|
95
|
+
- Gemfile.lock
|
|
94
96
|
- LICENSE.txt
|
|
95
97
|
- README.md
|
|
96
98
|
- Rakefile
|
|
@@ -105,7 +107,8 @@ files:
|
|
|
105
107
|
homepage: https://github.com/elitmus/omniauth-elitmus
|
|
106
108
|
licenses:
|
|
107
109
|
- MIT
|
|
108
|
-
metadata:
|
|
110
|
+
metadata:
|
|
111
|
+
rubygems_mfa_required: 'true'
|
|
109
112
|
rdoc_options: []
|
|
110
113
|
require_paths:
|
|
111
114
|
- lib
|
|
@@ -113,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
113
116
|
requirements:
|
|
114
117
|
- - ">="
|
|
115
118
|
- !ruby/object:Gem::Version
|
|
116
|
-
version:
|
|
119
|
+
version: 3.1.5
|
|
117
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
121
|
requirements:
|
|
119
122
|
- - ">="
|
|
@@ -123,7 +126,4 @@ requirements: []
|
|
|
123
126
|
rubygems_version: 4.0.10
|
|
124
127
|
specification_version: 4
|
|
125
128
|
summary: eLitmus OAuth2 Strategy for OmniAuth
|
|
126
|
-
test_files:
|
|
127
|
-
- test/helper.rb
|
|
128
|
-
- test/support/shared_example.rb
|
|
129
|
-
- test/test.rb
|
|
129
|
+
test_files: []
|