Skip to content

Comments

fix(oauth2): ensure expires_in is an integer#18936

Closed
ssut wants to merge 2 commits intogetsentry:masterfrom
ssut:patch-1
Closed

fix(oauth2): ensure expires_in is an integer#18936
ssut wants to merge 2 commits intogetsentry:masterfrom
ssut:patch-1

Conversation

@ssut
Copy link

@ssut ssut commented May 20, 2020

Github SSO setup fails with the latest version of Sentry on-premise build because of the following error:

web_1                      | Traceback (most recent call last):
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
web_1                      |     response = get_response(request)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
web_1                      |     response = self._get_response(request)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
web_1                      |     response = self.process_exception_by_middleware(e, request)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
web_1                      |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
web_1                      |     return self.dispatch(request, *args, **kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
web_1                      |     return view_func(*args, **kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/web/frontend/base.py", line 227, in dispatch
web_1                      |     return self.handle(request, *args, **kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/web/frontend/auth_provider_login.py", line 19, in handle
web_1                      |     return helper.current_step()
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/helper.py", line 628, in current_step
web_1                      |     return self.pipeline[step_index].dispatch(request=self.request, helper=self)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
web_1                      |     return view_func(*args, **kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/web/frontend/base.py", line 227, in dispatch
web_1                      |     return self.handle(request, *args, **kwargs)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/providers/github/views.py", line 130, in handle
web_1                      |     return helper.next_step()
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/helper.py", line 635, in next_step
web_1                      |     return self.current_step()
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/helper.py", line 626, in current_step
web_1                      |     return self.finish_pipeline()
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/helper.py", line 646, in finish_pipeline
web_1                      |     identity = self.provider.build_identity(data)
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/providers/github/provider.py", line 57, in build_identity
web_1                      |     "data": self.get_oauth_data(data),
web_1                      |   File "/usr/local/lib/python2.7/site-packages/sentry/auth/providers/oauth2.py", line 156, in get_oauth_data
web_1                      |     data["expires"] = int(time()) + payload["expires_in"]
web_1                      | TypeError: unsupported operand type(s) for +: 'int' and 'str'

This pull request fixes the error above that was caused because payload["expires_in"] could be string and the get_oauth_data tries to sum it with an integer value (current timestamp).


I'm not sure if sentry uses the API documented here, as you can see Github response contains expires_in in string type.

@joshuarli
Copy link
Member

joshuarli commented May 27, 2020

Hey @ssut, thanks for the patch! FYI, A duplicate has been merged already: #18921

Sorry we didn't see this sooner.

@joshuarli joshuarli closed this May 27, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants