Skip to content

Commit

Permalink
Expiration time bug resolved.
Browse files Browse the repository at this point in the history
- closes #3
  • Loading branch information
Javier Carnero committed May 18, 2018
1 parent 83ea5d3 commit b6c08ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 61 deletions.
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Web portal of the MSO4SC project.

.Components
* *Portal*: Integrates the different services into a single web interface.
* *IDM*: Manages the authentication & authorization server side.
* *Experiments Tool*: Executes the applications in the MSO4SC platform.
* *Marketplace*: Manages the applications available in MSO4SC. Built using FIWARE Business Ecosystem.
* *Data Catalogue*: Manages the datasets available in MSO4SC. Built using CKAN.
Expand Down
72 changes: 11 additions & 61 deletions portal/sso/backends/keyrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,75 +25,21 @@ class KeyrockOAuth2(BaseOAuth2):
REDIRECT_STATE = False

EXTRA_DATA = [
('id', 'uid'),
('displayName', 'id'),
('refresh_token', 'refresh_token'),
('id', 'id'),
('uid', 'uid'),
# ('displayName', 'id'),
# ('refresh_token', 'refresh_token'),
('roles', 'roles'),
('organizations', 'organizations'),
('expires_in', 'expires')
]

def get_user_id(self, details, response):
# ---- v5.4.0
# {'access_token': '53ERoBZXTDzjDrvSMAzEbLPW9JWX6f',
# 'expires_in': 3600,
# 'token_type': 'Bearer',
# 'state': 'IVbDtzMyx9fZib77Eiwqb4jtBwFLxgt0',
# 'scope': 'all_info',
# 'refresh_token': 'VGyiMKgKMISjmUraVmMb8ALIrtYb3u',
# 'organizations': [],
# 'displayName': 'j*******',
# 'roles': [{'name': 'Provider', 'id': 'provider'}],
# 'app_id': '0db45bbbfe05409685c2e043892d7d00',
# 'isGravatarEnabled': False,
# 'email': 'j*****.c******@atos.net',
# 'id': 'j*******'}
# ---- v7.0.0
# {'access_token': '4bb8dee1ea3e1f4523623af71d52e265f05304f3',
# 'token_type': 'Bearer',
# 'expires_in': 3599,
# 'refresh_token': 'd200de308c8694a3edde6afe9e19c89196754d29',
# 'organizations': [],
# 'displayName': 'jcarnero',
# 'roles': [
# {'id': 'b6208353-cd6d-4443-ad55-2a34b4c6df4f', 'name': 'Developer'},
# {'id': '8a2fc748-d7d9-48b9-be17-2cad3c1140c3', 'name': 'User'}],
# 'app_id': '390f1cbf-0582-4d65-aa93-531c3aed9a3f',
# 'email': '[email protected]',
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f',
# 'app_azf_domain': ''})
return response['displayName'].replace('-', '_')
print("--------->USER_ID: "+str(response))
return response['id'].replace('-', '_')

def get_user_details(self, response):
"""Return user details from FI-WARE account"""
# ---- v5.4.0
# {'access_token': 'uN1mFJKd9m0pGMdLyRFdvew5VLFMs3',
# 'expires_in': 3600,
# 'token_type': 'Bearer',
# 'state': 'HuQGmypp6QjjIcp4Izw097egFV1wd55f',
# 'scope': 'all_info',
# 'refresh_token': '35pOUhNnaUOEAicjyF4C8F9ZAa3jG8',
# 'organizations': [],
# 'displayName': 'j*******',
# 'roles': [{'name': 'Provider', 'id': 'provider'}],
# 'app_id': '0db45bbbfe05409685c2e043892d7d00',
# 'isGravatarEnabled': False,
# 'email': 'j*****.c******@atos.net',
# 'id': 'j*******'}
# ---- v7.0.0
# {'access_token': '4bb8dee1ea3e1f4523623af71d52e265f05304f3',
# 'token_type': 'Bearer',
# 'expires_in': 3599,
# 'refresh_token': 'd200de308c8694a3edde6afe9e19c89196754d29',
# 'organizations': [],
# 'displayName': 'jcarnero',
# 'roles': [
# {'id': 'b6208353-cd6d-4443-ad55-2a34b4c6df4f', 'name': 'Developer'},
# {'id': '8a2fc748-d7d9-48b9-be17-2cad3c1140c3', 'name': 'User'}],
# 'app_id': '390f1cbf-0582-4d65-aa93-531c3aed9a3f',
# 'email': '[email protected]',
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f',
# 'app_azf_domain': ''}
return {'username': response.get('displayName').replace('-', '_'),
'email': response.get('email') or ''}

Expand All @@ -120,7 +66,11 @@ def user_data(self, access_token, *args, **kwargs):
# 'email': '[email protected]',
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f',
# 'app_azf_domain': ''}
return self.get_json(url)
response = self.get_json(url)
response['uid'] = response['id']
response['id'] = response['displayName'].replace('-', '_')
print("--------->USER_DATA: "+str(response))
return response

def auth_headers(self):
response = super(KeyrockOAuth2, self).auth_headers()
Expand Down

0 comments on commit b6c08ec

Please sign in to comment.