girder-oauth 3.2.2.dev4__tar.gz → 3.2.3__tar.gz
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.
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/PKG-INFO +1 -1
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/rest.py +18 -7
- girder-oauth-3.2.3/girder_oauth/web_client/main.js +21 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/PKG-INFO +1 -1
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/plugin_tests/oauth_test.py +7 -49
- girder-oauth-3.2.2.dev4/girder_oauth/web_client/main.js +0 -5
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/__init__.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/__init__.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/base.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/bitbucket.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/box.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/github.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/globus.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/google.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/linkedin.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/providers/microsoft.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/settings.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/package.json +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/routes.js +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/stylesheets/configView.styl +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/stylesheets/oauthLoginView.styl +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/templates/configView.pug +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/templates/oauthLoginView.pug +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/ConfigView.js +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/LoginView.js +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/OAuthLoginView.js +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/RegisterView.js +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/SOURCES.txt +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/dependency_links.txt +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/entry_points.txt +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/not-zip-safe +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/requires.txt +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth.egg-info/top_level.txt +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/plugin.cmake +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/plugin_tests/__init__.py +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/setup.cfg +0 -0
- {girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/setup.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cherrypy
|
|
2
2
|
import datetime
|
|
3
|
+
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
|
|
3
4
|
|
|
4
5
|
from girder import events
|
|
5
6
|
from girder.constants import AccessType
|
|
@@ -134,10 +135,20 @@ class OAuth(Resource):
|
|
|
134
135
|
if event.defaultPrevented:
|
|
135
136
|
raise cherrypy.HTTPRedirect(redirect)
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
token = str(Token().createToken(user)['_id'])
|
|
139
|
+
|
|
140
|
+
# Set `girderToken` in the query params of the redirect URL
|
|
141
|
+
parsed = urlparse(redirect)
|
|
142
|
+
query_params = parse_qs(parsed.query)
|
|
143
|
+
query_params['girderToken'] = token
|
|
144
|
+
encoded_query_params = urlencode(query_params)
|
|
145
|
+
updated_redirect = urlunparse((
|
|
146
|
+
parsed.scheme,
|
|
147
|
+
parsed.netloc,
|
|
148
|
+
parsed.path,
|
|
149
|
+
parsed.params,
|
|
150
|
+
encoded_query_params,
|
|
151
|
+
parsed.fragment,
|
|
152
|
+
))
|
|
153
|
+
|
|
154
|
+
raise cherrypy.HTTPRedirect(updated_redirect)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { setCurrentToken } from '@girder/core/auth';
|
|
2
|
+
|
|
3
|
+
import './routes';
|
|
4
|
+
|
|
5
|
+
// Extends and overrides API
|
|
6
|
+
import './views/LoginView';
|
|
7
|
+
import './views/RegisterView';
|
|
8
|
+
|
|
9
|
+
// If the current URL contains a `girderToken` query parameter, set the current token to its value
|
|
10
|
+
const girderToken = new URLSearchParams(window.location.search).get('girderToken');
|
|
11
|
+
|
|
12
|
+
if (girderToken) {
|
|
13
|
+
// This means we have been redirected from a successful OAuth login.
|
|
14
|
+
// Save the token, and delete the query parameter from the URL.
|
|
15
|
+
window.localStorage.setItem('girderToken', girderToken);
|
|
16
|
+
setCurrentToken(girderToken);
|
|
17
|
+
|
|
18
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
19
|
+
queryParams.delete('girderToken');
|
|
20
|
+
window.location.search = queryParams.toString();
|
|
21
|
+
}
|
|
@@ -135,7 +135,7 @@ class OauthTest(base.TestCase):
|
|
|
135
135
|
}
|
|
136
136
|
return callbackParams
|
|
137
137
|
|
|
138
|
-
redirect = 'http://localhost/#foo/bar
|
|
138
|
+
redirect = 'http://localhost/#foo/bar'
|
|
139
139
|
|
|
140
140
|
class EventHandler:
|
|
141
141
|
def __init__(self):
|
|
@@ -167,7 +167,7 @@ class OauthTest(base.TestCase):
|
|
|
167
167
|
resp = self.request(
|
|
168
168
|
'/oauth/%s/callback' % providerInfo['id'], params=params, isJson=False)
|
|
169
169
|
self.assertStatus(resp, 303)
|
|
170
|
-
self.assertTrue('girderToken' not in resp.
|
|
170
|
+
self.assertTrue('girderToken' not in resp.headers['Location'])
|
|
171
171
|
self.assertEqual(event_handler.state, 'been in "before"')
|
|
172
172
|
|
|
173
173
|
params = _getCallbackParams(providerInfo, redirect)
|
|
@@ -183,51 +183,9 @@ class OauthTest(base.TestCase):
|
|
|
183
183
|
resp = self.request(
|
|
184
184
|
'/oauth/%s/callback' % providerInfo['id'], params=params, isJson=False)
|
|
185
185
|
self.assertStatus(resp, 303)
|
|
186
|
-
self.assertTrue('girderToken' not in resp.
|
|
186
|
+
self.assertTrue('girderToken' not in resp.headers['Location'])
|
|
187
187
|
self.assertEqual(event_handler.state, 'been in "after"')
|
|
188
188
|
|
|
189
|
-
def _testOauthTokenAsParam(self, providerInfo):
|
|
190
|
-
self.accountType = 'existing'
|
|
191
|
-
|
|
192
|
-
def _getCallbackParams(providerInfo, redirect):
|
|
193
|
-
resp = self.request('/oauth/provider', params={
|
|
194
|
-
'redirect': redirect,
|
|
195
|
-
'list': True
|
|
196
|
-
})
|
|
197
|
-
self.assertStatusOk(resp)
|
|
198
|
-
providerResp = resp.json[0]
|
|
199
|
-
resp = requests.get(providerResp['url'], allow_redirects=False)
|
|
200
|
-
self.assertEqual(resp.status_code, 302)
|
|
201
|
-
callbackLoc = urllib.parse.urlparse(resp.headers['location'])
|
|
202
|
-
self.assertEqual(
|
|
203
|
-
callbackLoc.path, r'/api/v1/oauth/%s/callback' % providerInfo['id'])
|
|
204
|
-
callbackLocQuery = urllib.parse.parse_qs(callbackLoc.query)
|
|
205
|
-
self.assertNotHasKeys(callbackLocQuery, ('error',))
|
|
206
|
-
callbackParams = {
|
|
207
|
-
key: val[0] for key, val in callbackLocQuery.items()
|
|
208
|
-
}
|
|
209
|
-
return callbackParams
|
|
210
|
-
|
|
211
|
-
redirect = 'http://localhost/#foo/bar?token={girderToken}'
|
|
212
|
-
params = _getCallbackParams(providerInfo, redirect)
|
|
213
|
-
|
|
214
|
-
resp = self.request(
|
|
215
|
-
'/oauth/%s/callback' % providerInfo['id'], params=params, isJson=False)
|
|
216
|
-
self.assertStatus(resp, 303)
|
|
217
|
-
self.assertTrue('girderToken' in resp.cookie)
|
|
218
|
-
self.assertEqual(
|
|
219
|
-
resp.headers['Location'],
|
|
220
|
-
redirect.format(girderToken=resp.cookie['girderToken'].value))
|
|
221
|
-
|
|
222
|
-
redirect = 'http://localhost/#foo/bar?token={foobar}'
|
|
223
|
-
params = _getCallbackParams(providerInfo, redirect)
|
|
224
|
-
|
|
225
|
-
resp = self.request(
|
|
226
|
-
'/oauth/%s/callback' % providerInfo['id'], params=params, isJson=False)
|
|
227
|
-
self.assertStatus(resp, 303)
|
|
228
|
-
self.assertTrue('girderToken' in resp.cookie)
|
|
229
|
-
self.assertEqual(resp.headers['Location'], redirect)
|
|
230
|
-
|
|
231
189
|
def _testOauth(self, providerInfo):
|
|
232
190
|
# Close registration to start off, and simulate a new user
|
|
233
191
|
self._testSettings(providerInfo)
|
|
@@ -349,10 +307,11 @@ class OauthTest(base.TestCase):
|
|
|
349
307
|
resp = self.request(
|
|
350
308
|
'/oauth/%s/callback' % providerInfo['id'], params=params, isJson=False)
|
|
351
309
|
self.assertStatus(resp, 303)
|
|
352
|
-
|
|
353
|
-
self.
|
|
310
|
+
expr = re.compile(r'^http://localhost/\?girderToken=(\w+)#foo/bar$')
|
|
311
|
+
self.assertRegex(resp.headers['Location'], expr)
|
|
354
312
|
|
|
355
|
-
|
|
313
|
+
girderToken = expr.match(resp.headers['Location']).group(1)
|
|
314
|
+
resp = self.request('/user/me', token=girderToken)
|
|
356
315
|
user = resp.json
|
|
357
316
|
self.assertStatusOk(resp)
|
|
358
317
|
self.assertEqual(
|
|
@@ -1001,7 +960,6 @@ class OauthTest(base.TestCase):
|
|
|
1001
960
|
self.mockOtherRequest
|
|
1002
961
|
):
|
|
1003
962
|
self._testOauth(providerInfo)
|
|
1004
|
-
self._testOauthTokenAsParam(providerInfo)
|
|
1005
963
|
self._testOauthEventHandling(providerInfo)
|
|
1006
964
|
|
|
1007
965
|
def testLinkedinOauth(self): # noqa
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/stylesheets/configView.styl
RENAMED
|
File without changes
|
|
File without changes
|
{girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/templates/configView.pug
RENAMED
|
File without changes
|
{girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/templates/oauthLoginView.pug
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/OAuthLoginView.js
RENAMED
|
File without changes
|
{girder-oauth-3.2.2.dev4 → girder-oauth-3.2.3}/girder_oauth/web_client/views/RegisterView.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|