Duke-GCB / gcb-web-auth

Django app that integrates Duke OAuth
MIT License
0 stars 0 forks source link

Handle errors from grouper server #18

Open dleehr opened 7 years ago

dleehr commented 7 years ago

Currently, the grouper server is returning 500 Internal server error, which prevents auth from working:

 ERROR:django.request:Internal Server Error: /auth/code_callback
 Traceback (most recent call last):
   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner
     response = get_response(request)
   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
     response = self.process_exception_by_middleware(e, request)
   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
     response = wrapped_callback(request, *callback_args, **callback_kwargs)
   File "/app/data/views.py", line 25, in authorize_callback
     user = authenticate(service=service, token_dict=token_dict)
   File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 74, in authenticate
     user = backend.authenticate(**credentials)
   File "/usr/local/lib/python2.7/site-packages/gcb_web_auth/backends/oauth.py", line 37, in authenticate
     self.check_user_details(details)
   File "/app/bespin/backend.py", line 13, in check_user_details
     self.verify_user_belongs_to_group(duke_unique_id, BESPIN_USER_GROUP)
   File "/usr/local/lib/python2.7/site-packages/gcb_web_auth/backends/oauth.py", line 69, in verify_user_belongs_to_group
     if not user_belongs_to_group(group_manager_connection, duke_unique_id, group_name):
   File "/usr/local/lib/python2.7/site-packages/gcb_web_auth/groupmanager.py", line 13, in user_belongs_to_group
     return group_name in get_users_group_names(group_manager_connection, duke_unique_id)
   File "/usr/local/lib/python2.7/site-packages/gcb_web_auth/groupmanager.py", line 23, in get_users_group_names
     response_payload = _fetch_users_groups(group_manager_connection, duke_unique_id)
   File "/usr/local/lib/python2.7/site-packages/gcb_web_auth/groupmanager.py", line 32, in _fetch_users_groups
     resp.raise_for_status()
   File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 862, in raise_for_status
     raise HTTPError(http_error_msg, response=self)
 HTTPError: 500 Server Error: Internal Server Error for url: https://grouper-server/grouper-ws/servicesRest/json/v2_1_500/subjects/xxxxx/groups
dleehr commented 7 years ago

Oddly, I can curl the server from my local machine:

$ curl -u <account_id> https://grouper-server/grouper-ws/servicesRest/json/v2_1_500/subjects/my-id/groups

Enter host password for user '<account_id>':
{"WsGetGroupsLiteResult":{"responseMetadata":{"millis":"115",...
dleehr commented 7 years ago

And requests.get works. so it's not a content type thing.

dleehr commented 7 years ago

Started debugging from the server in a django shell. This worked just fine and now the website is working too.

But we should capture errors from the grouper web service better