girder-oauth 3.2.7.dev18__tar.gz → 3.2.7.dev31__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.
Files changed (37) hide show
  1. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/PKG-INFO +1 -1
  2. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/__init__.py +2 -0
  3. girder_oauth-3.2.7.dev31/girder_oauth/providers/cilogon.py +91 -0
  4. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/settings.py +7 -0
  5. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/stylesheets/oauthLoginView.styl +13 -0
  6. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/views/ConfigView.js +9 -0
  7. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/views/OAuthLoginView.js +4 -0
  8. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/PKG-INFO +1 -1
  9. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/SOURCES.txt +1 -0
  10. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/__init__.py +0 -0
  11. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/base.py +0 -0
  12. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/bitbucket.py +0 -0
  13. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/box.py +0 -0
  14. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/github.py +0 -0
  15. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/globus.py +0 -0
  16. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/google.py +0 -0
  17. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/linkedin.py +0 -0
  18. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/providers/microsoft.py +0 -0
  19. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/rest.py +0 -0
  20. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/main.js +0 -0
  21. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/package.json +0 -0
  22. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/routes.js +0 -0
  23. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/stylesheets/configView.styl +0 -0
  24. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/templates/configView.pug +0 -0
  25. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/templates/oauthLoginView.pug +0 -0
  26. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/views/LoginView.js +0 -0
  27. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth/web_client/views/RegisterView.js +0 -0
  28. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/dependency_links.txt +0 -0
  29. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/entry_points.txt +0 -0
  30. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/not-zip-safe +0 -0
  31. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/requires.txt +0 -0
  32. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/girder_oauth.egg-info/top_level.txt +0 -0
  33. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/plugin.cmake +0 -0
  34. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/plugin_tests/__init__.py +0 -0
  35. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/plugin_tests/oauth_test.py +0 -0
  36. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/setup.cfg +0 -0
  37. {girder_oauth-3.2.7.dev18 → girder_oauth-3.2.7.dev31}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: girder-oauth
3
- Version: 3.2.7.dev18
3
+ Version: 3.2.7.dev31
4
4
  Summary: Allow users to login via supported OAuth2 providers.
5
5
  Home-page: http://girder.readthedocs.io/en/latest/plugins.html#oauth-login
6
6
  Author: Kitware, Inc.
@@ -7,6 +7,7 @@ from .linkedin import LinkedIn
7
7
  from .bitbucket import Bitbucket
8
8
  from .microsoft import Microsoft
9
9
  from .box import Box
10
+ from .cilogon import CILogon
10
11
 
11
12
 
12
13
  def addProvider(provider):
@@ -23,3 +24,4 @@ addProvider(LinkedIn)
23
24
  addProvider(Bitbucket)
24
25
  addProvider(Microsoft)
25
26
  addProvider(Box)
27
+ addProvider(CILogon)
@@ -0,0 +1,91 @@
1
+ import warnings
2
+
3
+ from girder.api.rest import getApiUrl
4
+ from girder.exceptions import RestException
5
+ from girder.models.setting import Setting
6
+
7
+ from ..settings import PluginSettings
8
+ from .base import ProviderBase
9
+ import requests
10
+
11
+
12
+ class CILogon(ProviderBase):
13
+ _AUTH_SCOPES = ['openid', 'email', 'profile']
14
+ _API_USER_URL = 'https://cilogon.org/oauth2/userinfo'
15
+ _AUTHORITY = 'https://cilogon.org'
16
+
17
+ def getClientIdSetting(self):
18
+ return Setting().get(PluginSettings.CILOGON_CLIENT_ID)
19
+
20
+ def getClientSecretSetting(self):
21
+ return Setting().get(PluginSettings.CILOGON_CLIENT_SECRET)
22
+
23
+ @classmethod
24
+ def getUrl(cls, state):
25
+ clientId = Setting().get(PluginSettings.CILOGON_CLIENT_ID)
26
+ if not clientId:
27
+ raise Exception('No CILogon client ID setting is present.')
28
+
29
+ redirectUri = '/'.join((getApiUrl(), 'oauth', 'cilogon', 'callback'))
30
+
31
+ url = (
32
+ f'{cls._AUTHORITY}/authorize'
33
+ f'?client_id={clientId}'
34
+ f'&response_type=code'
35
+ f'&scope={" ".join(cls._AUTH_SCOPES)}'
36
+ f'&redirect_uri={redirectUri}'
37
+ f'&state={state}'
38
+ )
39
+ return url
40
+
41
+ def getToken(self, code):
42
+ clientId = self.getClientIdSetting()
43
+ clientSecret = self.getClientSecretSetting()
44
+ redirectUri = '/'.join((getApiUrl(), 'oauth', 'cilogon', 'callback'))
45
+
46
+ if not clientId or not clientSecret or not redirectUri:
47
+ raise Exception('CILogon settings are incomplete.')
48
+
49
+ token_url = f'{self._AUTHORITY}/oauth2/token'
50
+ data = {
51
+ 'grant_type': 'authorization_code',
52
+ 'code': code,
53
+ 'redirect_uri': redirectUri,
54
+ 'client_id': clientId,
55
+ 'client_secret': clientSecret,
56
+ }
57
+ with warnings.catch_warnings():
58
+ warnings.simplefilter('ignore', DeprecationWarning)
59
+ response = requests.post(token_url, data=data)
60
+
61
+ if response.status_code != 200:
62
+ raise Exception('Error acquiring token: %s' %
63
+ response.json().get('error_description', 'Unknown error'))
64
+
65
+ return response.json()
66
+
67
+ def getUser(self, token):
68
+ headers = {
69
+ 'Authorization': f'Bearer {token["access_token"]}',
70
+ 'Accept': 'application/json'
71
+ }
72
+
73
+ # Get user's info
74
+ resp = requests.get(self._API_USER_URL, headers=headers)
75
+ if resp.status_code != 200:
76
+ raise RestException('Failed to fetch user info from CILogon.', code=502)
77
+
78
+ user_data = resp.json()
79
+ oauthId = user_data.get('sub')
80
+ if not oauthId:
81
+ raise RestException('CILogon did not return user ID.', code=502)
82
+
83
+ email = user_data.get('email')
84
+ if not email:
85
+ raise RestException('CILogon user has no registered email address.', code=502)
86
+
87
+ firstName = user_data.get('given_name', '')
88
+ lastName = user_data.get('family_name', '')
89
+
90
+ user = self._createOrReuseUser(oauthId, email, firstName, lastName)
91
+ return user
@@ -28,6 +28,9 @@ class PluginSettings:
28
28
  BOX_CLIENT_ID = 'oauth.box_client_id'
29
29
  BOX_CLIENT_SECRET = 'oauth.box_client_secret'
30
30
 
31
+ CILOGON_CLIENT_ID = 'oauth.cilogon_client_id'
32
+ CILOGON_CLIENT_SECRET = 'oauth.cilogon_client_secret'
33
+
31
34
 
32
35
  @setting_utilities.default(PluginSettings.PROVIDERS_ENABLED)
33
36
  def _defaultProvidersEnabled():
@@ -47,6 +50,7 @@ def _defaultIgnoreRegistrationPolicy():
47
50
  PluginSettings.BITBUCKET_CLIENT_ID,
48
51
  PluginSettings.MICROSOFT_CLIENT_ID,
49
52
  PluginSettings.BOX_CLIENT_ID,
53
+ PluginSettings.CILOGON_CLIENT_ID,
50
54
  PluginSettings.GOOGLE_CLIENT_SECRET,
51
55
  PluginSettings.GLOBUS_CLIENT_SECRET,
52
56
  PluginSettings.GITHUB_CLIENT_SECRET,
@@ -54,6 +58,7 @@ def _defaultIgnoreRegistrationPolicy():
54
58
  PluginSettings.BITBUCKET_CLIENT_SECRET,
55
59
  PluginSettings.MICROSOFT_CLIENT_SECRET,
56
60
  PluginSettings.BOX_CLIENT_SECRET,
61
+ PluginSettings.CILOGON_CLIENT_SECRET,
57
62
  PluginSettings.MICROSOFT_TENANT_ID,
58
63
  })
59
64
  def _defaultOtherSettings():
@@ -80,6 +85,7 @@ def _validateIgnoreRegistrationPolicy(doc):
80
85
  PluginSettings.BITBUCKET_CLIENT_ID,
81
86
  PluginSettings.MICROSOFT_CLIENT_ID,
82
87
  PluginSettings.BOX_CLIENT_ID,
88
+ PluginSettings.CILOGON_CLIENT_ID,
83
89
  PluginSettings.GOOGLE_CLIENT_SECRET,
84
90
  PluginSettings.GLOBUS_CLIENT_SECRET,
85
91
  PluginSettings.GITHUB_CLIENT_SECRET,
@@ -87,6 +93,7 @@ def _validateIgnoreRegistrationPolicy(doc):
87
93
  PluginSettings.BITBUCKET_CLIENT_SECRET,
88
94
  PluginSettings.MICROSOFT_CLIENT_SECRET,
89
95
  PluginSettings.BOX_CLIENT_SECRET,
96
+ PluginSettings.CILOGON_CLIENT_SECRET,
90
97
  PluginSettings.MICROSOFT_TENANT_ID,
91
98
  })
92
99
  def _validateOtherSettings(doc):
@@ -127,3 +127,16 @@
127
127
 
128
128
  .g-oauth-button-icon
129
129
  border-right-color darken($brandColor, 30%)
130
+
131
+ .g-oauth-button-cilogon
132
+ $brandColor = #669966
133
+
134
+ background-color $brandColor
135
+ border 1px solid darken($brandColor, 30%)
136
+ color white
137
+
138
+ &:hover
139
+ background-color darken($brandColor, 15%)
140
+
141
+ .g-oauth-button-icon
142
+ border-right-color darken($brandColor, 30%)
@@ -120,6 +120,15 @@ var ConfigView = View.extend({
120
120
  instructions: 'Client IDs and secret keys are managed in the Box ' +
121
121
  'Developer Services page. When creating your client ID ' +
122
122
  'there, use the following as the authorization callback URL:'
123
+ }, {
124
+ id: 'cilogon',
125
+ name: 'CILogon',
126
+ icon: 'box-brand',
127
+ hasAuthorizedOrigins: false,
128
+ takesTenantId: false,
129
+ instructions: 'Client IDs and secret keys are managed through the CILogon ' +
130
+ 'Client Registration page. When creating your client ID ' +
131
+ 'there, use the following as the authorization callback URL:'
123
132
  }];
124
133
  this.providerIds = _.pluck(this.providers, 'id');
125
134
 
@@ -92,6 +92,10 @@ var OAuthLoginView = View.extend({
92
92
  box: {
93
93
  icon: 'box',
94
94
  class: 'g-oauth-button-box'
95
+ },
96
+ cilogon: {
97
+ icon: 'box',
98
+ class: 'g-oauth-button-box'
95
99
  }
96
100
  }
97
101
  });
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: girder-oauth
3
- Version: 3.2.7.dev18
3
+ Version: 3.2.7.dev31
4
4
  Summary: Allow users to login via supported OAuth2 providers.
5
5
  Home-page: http://girder.readthedocs.io/en/latest/plugins.html#oauth-login
6
6
  Author: Kitware, Inc.
@@ -14,6 +14,7 @@ girder_oauth/providers/__init__.py
14
14
  girder_oauth/providers/base.py
15
15
  girder_oauth/providers/bitbucket.py
16
16
  girder_oauth/providers/box.py
17
+ girder_oauth/providers/cilogon.py
17
18
  girder_oauth/providers/github.py
18
19
  girder_oauth/providers/globus.py
19
20
  girder_oauth/providers/google.py