forked from data-exp-lab/girder_ythub
-
Notifications
You must be signed in to change notification settings - Fork 5
/
auth.py
25 lines (19 loc) · 895 Bytes
/
auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from girder.models.setting import Setting
from ...constants import PluginSettings, DEFAULT_DERIVA_SCOPE
from ..verificator import Verificator
from girder.plugins.oauth.providers.globus import Globus
Globus.addScopes([DEFAULT_DERIVA_SCOPE])
class DerivaVerificator(Verificator):
def __init__(self, resource_server=None, key=None, user=None, url=None):
super().__init__(resource_server, key, user, url)
self.user = user
@property
def headers(self):
scope_map = Setting().get(PluginSettings.DERIVA_SCOPES)
if self.resource_server in scope_map:
scope = scope_map[self.resource_server]
if 'otherTokens' in self.user:
for token in self.user['otherTokens']:
if token.get("scope") == scope:
return {'Authorization': 'Bearer ' + token['access_token']}
return {}