omniauth-globus 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/.rubocop.yml +209 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +98 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/lib/omniauth/globus/version.rb +7 -0
- data/lib/omniauth/globus.rb +3 -0
- data/lib/omniauth/strategies/globus.rb +154 -0
- data/lib/omniauth-globus.rb +1 -0
- data/omniauth-globus.gemspec +35 -0
- data/spec/fixtures/access_token.json +9 -0
- data/spec/fixtures/request_info.json +213 -0
- data/spec/omniauth/strategies/globus_spec.rb +514 -0
- data/spec/rubocop_spec.rb +9 -0
- data/spec/spec_helper.rb +25 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9104c94aa76173b5aaa26efb5577358bfb57e8fcc5fafeb7f044d413a01af40e
|
4
|
+
data.tar.gz: 03156dd1bba125b360eef9dcf311b9fd9791fc08e0e4aefe092169eface776c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c77a6c4c3866b0ad92a1ad31097d92b80dbfca091c617986e9bb27909bb8accd891bf79d3af38f79ac25ffeea33b46ed7fab2f9b707cbbb78d9ccb5e319404f
|
7
|
+
data.tar.gz: bd04da0ef51a21c19c55dbc6fc7a88252b2be8e28f9afc3fdf19592ea19484c8da242f1312f0f4b1759d6de0af62a3fcab8f2733bd0737ae70f80b285dec3d8d
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# from https://github.com/rails/rails/blob/master/.rubocop.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
6
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
7
|
+
DisabledByDefault: true
|
8
|
+
|
9
|
+
# Prefer &&/|| over and/or.
|
10
|
+
Style/AndOr:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
# Do not use braces for hash literals when they are the last argument of a
|
14
|
+
# method call.
|
15
|
+
Style/BracesAroundHashParameters:
|
16
|
+
Enabled: true
|
17
|
+
EnforcedStyle: context_dependent
|
18
|
+
|
19
|
+
# Align `when` with `case`.
|
20
|
+
Layout/CaseIndentation:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
# Align comments with method definitions.
|
24
|
+
Layout/CommentIndentation:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Layout/ElseAlignment:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
# Align `end` with the matching keyword or starting expression except for
|
31
|
+
# assignments, where it should be aligned with the LHS.
|
32
|
+
Layout/EndAlignment:
|
33
|
+
Enabled: true
|
34
|
+
EnforcedStyleAlignWith: variable
|
35
|
+
AutoCorrect: true
|
36
|
+
|
37
|
+
Layout/EmptyLineAfterMagicComment:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Layout/EmptyLinesAroundBlockBody:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
# In a regular class definition, no empty lines around the body.
|
44
|
+
Layout/EmptyLinesAroundClassBody:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
# In a regular method definition, no empty lines around the body.
|
48
|
+
Layout/EmptyLinesAroundMethodBody:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
# In a regular module definition, no empty lines around the body.
|
52
|
+
Layout/EmptyLinesAroundModuleBody:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
Layout/IndentFirstArgument:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
59
|
+
Style/HashSyntax:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
63
|
+
# extra level of indentation.
|
64
|
+
Layout/IndentationConsistency:
|
65
|
+
Enabled: true
|
66
|
+
EnforcedStyle: indented_internal_methods
|
67
|
+
|
68
|
+
# Two spaces, no tabs (for indentation).
|
69
|
+
Layout/IndentationWidth:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Layout/LeadingCommentSpace:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Layout/SpaceAfterColon:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Layout/SpaceAfterComma:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Layout/SpaceAfterSemicolon:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
Layout/SpaceAroundKeyword:
|
88
|
+
Enabled: true
|
89
|
+
|
90
|
+
Layout/SpaceAroundOperators:
|
91
|
+
Enabled: true
|
92
|
+
|
93
|
+
Layout/SpaceBeforeComma:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
Layout/SpaceBeforeComment:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
Layout/SpaceBeforeFirstArg:
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
Style/DefWithParentheses:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
# Defining a method with parameters needs parentheses.
|
106
|
+
Style/MethodDefParentheses:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
Style/FrozenStringLiteralComment:
|
110
|
+
Enabled: true
|
111
|
+
EnforcedStyle: always
|
112
|
+
Exclude:
|
113
|
+
- 'actionview/test/**/*.builder'
|
114
|
+
- 'actionview/test/**/*.ruby'
|
115
|
+
- 'actionpack/test/**/*.builder'
|
116
|
+
- 'actionpack/test/**/*.ruby'
|
117
|
+
- 'activestorage/db/migrate/**/*.rb'
|
118
|
+
- 'activestorage/db/update_migrate/**/*.rb'
|
119
|
+
- 'actionmailbox/db/migrate/**/*.rb'
|
120
|
+
- 'actiontext/db/migrate/**/*.rb'
|
121
|
+
|
122
|
+
Style/RedundantFreeze:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
# Use `foo {}` not `foo{}`.
|
126
|
+
Layout/SpaceBeforeBlockBraces:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
# Use `foo { bar }` not `foo {bar}`.
|
130
|
+
Layout/SpaceInsideBlockBraces:
|
131
|
+
Enabled: true
|
132
|
+
EnforcedStyleForEmptyBraces: space
|
133
|
+
|
134
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
135
|
+
Layout/SpaceInsideHashLiteralBraces:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
Layout/SpaceInsideParens:
|
139
|
+
Enabled: true
|
140
|
+
|
141
|
+
# Check quotes usage according to lint rule below.
|
142
|
+
Style/StringLiterals:
|
143
|
+
Enabled: true
|
144
|
+
EnforcedStyle: double_quotes
|
145
|
+
|
146
|
+
# Detect hard tabs, no hard tabs.
|
147
|
+
Layout/Tab:
|
148
|
+
Enabled: true
|
149
|
+
|
150
|
+
# Blank lines should not have any spaces.
|
151
|
+
Layout/TrailingBlankLines:
|
152
|
+
Enabled: true
|
153
|
+
|
154
|
+
# No trailing whitespace.
|
155
|
+
Layout/TrailingWhitespace:
|
156
|
+
Enabled: true
|
157
|
+
|
158
|
+
# Use quotes for string literals when they are enough.
|
159
|
+
Style/UnneededPercentQ:
|
160
|
+
Enabled: true
|
161
|
+
|
162
|
+
Lint/AmbiguousOperator:
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
Lint/AmbiguousRegexpLiteral:
|
166
|
+
Enabled: true
|
167
|
+
|
168
|
+
Lint/ErbNewArguments:
|
169
|
+
Enabled: true
|
170
|
+
|
171
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
172
|
+
Lint/RequireParentheses:
|
173
|
+
Enabled: true
|
174
|
+
|
175
|
+
Lint/ShadowingOuterLocalVariable:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
Lint/StringConversionInInterpolation:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
Lint/UriEscapeUnescape:
|
182
|
+
Enabled: true
|
183
|
+
|
184
|
+
Lint/UselessAssignment:
|
185
|
+
Enabled: true
|
186
|
+
|
187
|
+
Lint/DeprecatedClassMethods:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
Style/ParenthesesAroundCondition:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
Style/RedundantBegin:
|
194
|
+
Enabled: true
|
195
|
+
|
196
|
+
Style/RedundantReturn:
|
197
|
+
Enabled: true
|
198
|
+
AllowMultipleReturnValues: true
|
199
|
+
|
200
|
+
Style/Semicolon:
|
201
|
+
Enabled: true
|
202
|
+
AllowAsExpressionSeparator: true
|
203
|
+
|
204
|
+
# Prefer Foo.method over Foo::method
|
205
|
+
Style/ColonMethodCall:
|
206
|
+
Enabled: true
|
207
|
+
|
208
|
+
Style/TrivialAccessors:
|
209
|
+
Enabled: true
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.4.1
|
4
|
+
install:
|
5
|
+
- travis_retry bundle install
|
6
|
+
script: bundle exec rspec
|
7
|
+
notifications:
|
8
|
+
slack: datacite:Wt8En0ALoTA6Kjc5EOKNDWxN
|
9
|
+
deploy:
|
10
|
+
provider: rubygems
|
11
|
+
api_key:
|
12
|
+
secure: uE7wQ63qRd3hnuzi2omMNoAcJJfQ/UQqk67qw2llQVYMbQlwgD6nnF5ipkPuqdAxPKZycUoZuD/uFKGK1B5pSPZeMTfFmTls3vPj6kLWeUCNZkZXfOsPPzhipRmxMbuxaCn6IqNtkTavsjC5xkOeBDw9aRTMRphyrwewWtk83NlwpRefNVx1SxU6IAxpySEWpjQ/PsLvJ+NmQuPl6KXlTooDPpaVHaaW9IDLtFoTK4GGWLGiDYWkhwQerUvczxvyuNGr/o0j8obCKau6lgv8eAj1f9W8pXmbvxq8Opp3/8chSvT98sO+L5RwigJYu6X7B1xVZGSNAuOVzNRagGkF2LE20b4p+1RqpmqCLViZcfPXRuSLPD4QlyRqjPbuma1mSQ/7zR8JTyobDJfyrQbuJNu+q96Edf4ZzHATDWik6sWRaU3Qcv5MN3NKgSwB0jbHgdgUeSKZusN4vkpNN4n1uxXnII/7A2b7W9U8wPFqmwhopB9egOxP9BQERFu4GxtI1TOPjIlh3tKy8SjSF0KnunHbaI1s6UrpjEh+mS5k9WryJtRmINFRI+ZHeCI6Sl5sXococnczDImG2AH7PEJ1zZ3rq/JH7J4HJ2moJW6xhvqVhoI1i9ti1VRqDE82GwRb0QE88eS2DZX2/b6J1faxlGuj1Cup+xzOrLnj9pctZLc=
|
13
|
+
gem: omniauth-globus
|
14
|
+
on:
|
15
|
+
tags: true
|
16
|
+
repo: datacite/omniauth-globus
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-globus (0.8.3)
|
5
|
+
jwt (>= 2.0)
|
6
|
+
omniauth (~> 1.9)
|
7
|
+
omniauth-oauth2 (~> 1.6)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
ast (2.4.0)
|
15
|
+
codeclimate-test-reporter (1.0.9)
|
16
|
+
simplecov (<= 0.13)
|
17
|
+
crack (0.4.3)
|
18
|
+
safe_yaml (~> 1.0.0)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
docile (1.1.5)
|
21
|
+
faraday (0.15.4)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
hashdiff (1.0.0)
|
24
|
+
hashie (3.6.0)
|
25
|
+
jaro_winkler (1.5.3)
|
26
|
+
json (2.2.0)
|
27
|
+
jwt (2.2.1)
|
28
|
+
multi_json (1.13.1)
|
29
|
+
multi_xml (0.6.0)
|
30
|
+
multipart-post (2.1.1)
|
31
|
+
oauth2 (1.4.1)
|
32
|
+
faraday (>= 0.8, < 0.16.0)
|
33
|
+
jwt (>= 1.0, < 3.0)
|
34
|
+
multi_json (~> 1.3)
|
35
|
+
multi_xml (~> 0.5)
|
36
|
+
rack (>= 1.2, < 3)
|
37
|
+
omniauth (1.9.0)
|
38
|
+
hashie (>= 3.4.6, < 3.7.0)
|
39
|
+
rack (>= 1.6.2, < 3)
|
40
|
+
omniauth-oauth2 (1.6.0)
|
41
|
+
oauth2 (~> 1.1)
|
42
|
+
omniauth (~> 1.9)
|
43
|
+
parallel (1.17.0)
|
44
|
+
parser (2.6.4.0)
|
45
|
+
ast (~> 2.4.0)
|
46
|
+
public_suffix (4.0.1)
|
47
|
+
rack (2.0.7)
|
48
|
+
rack-test (0.6.3)
|
49
|
+
rack (>= 1.0)
|
50
|
+
rainbow (3.0.0)
|
51
|
+
rspec (3.8.0)
|
52
|
+
rspec-core (~> 3.8.0)
|
53
|
+
rspec-expectations (~> 3.8.0)
|
54
|
+
rspec-mocks (~> 3.8.0)
|
55
|
+
rspec-core (3.8.2)
|
56
|
+
rspec-support (~> 3.8.0)
|
57
|
+
rspec-expectations (3.8.4)
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
+
rspec-support (~> 3.8.0)
|
60
|
+
rspec-mocks (3.8.1)
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
+
rspec-support (~> 3.8.0)
|
63
|
+
rspec-support (3.8.2)
|
64
|
+
rubocop (0.74.0)
|
65
|
+
jaro_winkler (~> 1.5.1)
|
66
|
+
parallel (~> 1.10)
|
67
|
+
parser (>= 2.6)
|
68
|
+
rainbow (>= 2.2.2, < 4.0)
|
69
|
+
ruby-progressbar (~> 1.7)
|
70
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
71
|
+
ruby-progressbar (1.10.1)
|
72
|
+
safe_yaml (1.0.5)
|
73
|
+
simplecov (0.13.0)
|
74
|
+
docile (~> 1.1.0)
|
75
|
+
json (>= 1.8, < 3)
|
76
|
+
simplecov-html (~> 0.10.0)
|
77
|
+
simplecov-html (0.10.2)
|
78
|
+
unicode-display_width (1.6.0)
|
79
|
+
webmock (3.7.2)
|
80
|
+
addressable (>= 2.3.6)
|
81
|
+
crack (>= 0.3.2)
|
82
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
ruby
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
bundler (~> 1.0)
|
89
|
+
codeclimate-test-reporter (~> 1.0.0)
|
90
|
+
omniauth-globus!
|
91
|
+
rack-test (~> 0.6.3)
|
92
|
+
rspec (~> 3.4)
|
93
|
+
rubocop (~> 0.68)
|
94
|
+
simplecov
|
95
|
+
webmock (~> 3.0, >= 3.0.1)
|
96
|
+
|
97
|
+
BUNDLED WITH
|
98
|
+
1.17.3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 DataCite
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jwt"
|
4
|
+
require "omniauth/strategies/oauth2"
|
5
|
+
require "uri"
|
6
|
+
|
7
|
+
module OmniAuth
|
8
|
+
module Strategies
|
9
|
+
class Globus < OmniAuth::Strategies::OAuth2
|
10
|
+
option :name, "globus"
|
11
|
+
option :issuer, "https://auth.globus.org"
|
12
|
+
option :scope, "openid profile email"
|
13
|
+
option :authorize_options, %i[access_type login_hint prompt request_visible_actions scope state redirect_uri include_granted_scopes openid_realm device_id device_name]
|
14
|
+
|
15
|
+
option(:client_options, site: 'https://auth.globus.org',
|
16
|
+
authorize_url: 'https://auth.globus.org/v2/oauth2/authorize',
|
17
|
+
token_url: 'https://auth.globus.org/v2/oauth2/token',
|
18
|
+
discovery_endpoint: "https://auth.globus.org/.well-known/openid-configuration",
|
19
|
+
authorization_endpoint: "https://auth.globus.org/v2/oauth2/authorize",
|
20
|
+
token_endpoint: "https://auth.globus.org/v2/oauth2/token",
|
21
|
+
userinfo_endpoint: "https://auth.globus.org/v2/oauth2/userinfo",
|
22
|
+
jwks_uri: "https://auth.globus.org/jwk.json",
|
23
|
+
end_session_endpoint: "https://auth.globus.org/v2/oauth2/token/revoke")
|
24
|
+
|
25
|
+
def authorize_params
|
26
|
+
super.tap do |params|
|
27
|
+
options[:authorize_options].each do |k|
|
28
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
29
|
+
end
|
30
|
+
|
31
|
+
params[:scope] = get_scope(params)
|
32
|
+
params[:access_type] = 'offline' if params[:access_type].nil?
|
33
|
+
params['openid.realm'] = params.delete(:openid_realm) unless params[:openid_realm].nil?
|
34
|
+
|
35
|
+
session['omniauth.state'] = params[:state] if params[:state]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
uid { raw_info['sub'] }
|
40
|
+
|
41
|
+
info do
|
42
|
+
prune!(
|
43
|
+
name: raw_info['name'],
|
44
|
+
first_name: raw_info['given_name'],
|
45
|
+
last_name: raw_info['family_name'],
|
46
|
+
email: raw_info['email']
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
extra do
|
51
|
+
hash = {}
|
52
|
+
hash[:id_token] = access_token['id_token']
|
53
|
+
if !access_token['id_token'].nil?
|
54
|
+
decoded = ::JWT.decode(access_token['id_token'], nil, false).first
|
55
|
+
|
56
|
+
# We have to manually verify the claims because the third parameter to
|
57
|
+
# JWT.decode is false since no verification key is provided.
|
58
|
+
::JWT::Verify.verify_claims(decoded,
|
59
|
+
verify_iss: true,
|
60
|
+
iss: options.issuer,
|
61
|
+
verify_expiration: true)
|
62
|
+
|
63
|
+
hash[:id_info] = decoded
|
64
|
+
end
|
65
|
+
hash[:raw_info] = raw_info unless skip_info?
|
66
|
+
prune! hash
|
67
|
+
end
|
68
|
+
|
69
|
+
def raw_info
|
70
|
+
@raw_info ||= access_token.get(options.client_options.userinfo_endpoint).parsed
|
71
|
+
end
|
72
|
+
|
73
|
+
def custom_build_access_token
|
74
|
+
get_access_token(request)
|
75
|
+
end
|
76
|
+
|
77
|
+
alias build_access_token custom_build_access_token
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def callback_url
|
82
|
+
options[:redirect_uri] || (full_host + script_name + callback_path)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_access_token(request)
|
86
|
+
verifier = request.params['code']
|
87
|
+
redirect_uri = request.params['redirect_uri']
|
88
|
+
if verifier && request.xhr?
|
89
|
+
client_get_token(verifier, redirect_uri || 'postmessage')
|
90
|
+
elsif verifier
|
91
|
+
client_get_token(verifier, redirect_uri || callback_url)
|
92
|
+
elsif verify_token(request.params['access_token'])
|
93
|
+
::OAuth2::AccessToken.from_hash(client, request.params.dup)
|
94
|
+
elsif request.content_type =~ /json/i
|
95
|
+
begin
|
96
|
+
body = JSON.parse(request.body.read)
|
97
|
+
request.body.rewind # rewind request body for downstream middlewares
|
98
|
+
verifier = body && body['code']
|
99
|
+
client_get_token(verifier, 'postmessage') if verifier
|
100
|
+
rescue JSON::ParserError => e
|
101
|
+
warn "[omniauth globus] JSON parse error=#{e}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def client_get_token(verifier, redirect_uri)
|
107
|
+
client.auth_code.get_token(verifier, get_token_options(redirect_uri), get_token_params)
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_token_params
|
111
|
+
deep_symbolize(options.auth_token_params || {})
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_scope(params)
|
115
|
+
raw_scope = params[:scope] || options.scope
|
116
|
+
scope_list = raw_scope.split(" ").map { |item| item.split(",") }.flatten
|
117
|
+
scope_list.join(" ")
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_token_options(redirect_uri = "")
|
121
|
+
{ redirect_uri: redirect_uri }.merge(token_params.to_hash(symbolize_keys: true))
|
122
|
+
end
|
123
|
+
|
124
|
+
def prune!(hash)
|
125
|
+
hash.delete_if do |_, v|
|
126
|
+
prune!(v) if v.is_a?(Hash)
|
127
|
+
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def strip_unnecessary_query_parameters(query_parameters)
|
132
|
+
# strip `sz` parameter (defaults to sz=50) which overrides `image_size` options
|
133
|
+
return nil if query_parameters.nil?
|
134
|
+
|
135
|
+
params = CGI.parse(query_parameters)
|
136
|
+
stripped_params = params.delete_if { |key| key == 'sz' }
|
137
|
+
|
138
|
+
# don't return an empty Hash since that would result
|
139
|
+
# in URLs with a trailing ? character: http://image.url?
|
140
|
+
return nil if stripped_params.empty?
|
141
|
+
|
142
|
+
URI.encode_www_form(stripped_params)
|
143
|
+
end
|
144
|
+
|
145
|
+
def verify_token(access_token)
|
146
|
+
return false unless access_token
|
147
|
+
|
148
|
+
raw_response = client.request(:get, options.client_options.userinfo_endpoint,
|
149
|
+
params: { access_token: access_token }).parsed
|
150
|
+
raw_response["aud"] == options.client_id
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/globus'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require File.expand_path("../lib/omniauth/globus/version", __FILE__)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.authors = ["Martin Fenner"]
|
8
|
+
s.email = ["mfenner@datacite.org"]
|
9
|
+
s.name = "omniauth-globus"
|
10
|
+
s.homepage = "https://github.com/datacite/omniauth-globus"
|
11
|
+
s.summary = "Globus Auth OpenId connect Strategy for OmniAuth 1.0"
|
12
|
+
s.date = Date.today
|
13
|
+
s.description = "Enables third-party client apps to authenticate with the Globus Auth service via OpenID Connect"
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.version = OmniAuth::Globus::VERSION
|
16
|
+
s.extra_rdoc_files = ["README.md"]
|
17
|
+
s.license = "MIT"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
|
22
|
+
s.required_ruby_version = ">= 2.3"
|
23
|
+
|
24
|
+
# Declary dependencies here, rather than in the Gemfile
|
25
|
+
s.add_dependency "jwt", ">= 2.0"
|
26
|
+
s.add_dependency "omniauth", "~> 1.9"
|
27
|
+
s.add_dependency "omniauth-oauth2", "~> 1.6"
|
28
|
+
s.add_development_dependency "bundler", "~> 1.0"
|
29
|
+
s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
30
|
+
s.add_development_dependency "rack-test", "~> 0.6.3"
|
31
|
+
s.add_development_dependency "rspec", "~> 3.4"
|
32
|
+
s.add_development_dependency "rubocop", "~> 0.68"
|
33
|
+
s.add_development_dependency "simplecov"
|
34
|
+
s.add_development_dependency "webmock", "~> 3.0", ">= 3.0.1"
|
35
|
+
end
|