Permalink
Browse files

fixes bug 941358 - 403 when logging in while having a second tab open…

…, r=AdrianGaudebert
  • Loading branch information...
1 parent f239902 commit 03db93df3231a9bc771dee3188d0c197016a5a14 @peterbe peterbe committed Jan 10, 2014
Showing with 14,911 additions and 1,525 deletions.
  1. +3 −0 .gitmodules
  2. +17 −5 webapp-django/crashstats/auth/browserid_mock.py
  3. +11 −11 webapp-django/crashstats/auth/tests/test_views.py
  4. +0 −1 webapp-django/crashstats/base/templates/crashstats_base.html
  5. +1 −1 webapp-django/crashstats/settings/local.py-dist
  6. +1 −1 webapp-django/crashstats/urls.py
  7. +2 −0 webapp-django/manage.py
  8. +0 −1 webapp-django/requirements.txt
  9. +1 −1 webapp-django/settings_test.py
  10. +783 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/PKG-INFO
  11. +83 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/SOURCES.txt
  12. +1 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/dependency_links.txt
  13. +143 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/installed-files.txt
  14. +1 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/not-zip-safe
  15. +1 −0 webapp-django/vendor-local/lib/python/requests-1.2.3-py2.6.egg-info/top_level.txt
  16. +53 −9 webapp-django/vendor-local/lib/python/requests/__init__.py
  17. +342 −0 webapp-django/vendor-local/lib/python/requests/adapters.py
  18. +15 −14 webapp-django/vendor-local/lib/python/requests/api.py
  19. +106 −158 webapp-django/vendor-local/lib/python/requests/auth.py
  20. +3,290 −0 webapp-django/vendor-local/lib/python/requests/cacert.pem
  21. +24 −0 webapp-django/vendor-local/lib/python/requests/certs.py
  22. +15 −7 webapp-django/vendor-local/lib/python/requests/compat.py
  23. +52 −26 webapp-django/vendor-local/lib/python/requests/cookies.py
  24. +15 −1 webapp-django/vendor-local/lib/python/requests/exceptions.py
  25. +13 −19 webapp-django/vendor-local/lib/python/requests/hooks.py
  26. +424 −570 webapp-django/vendor-local/lib/python/requests/models.py
  27. +32 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/__init__.py
  28. +925 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/big5freq.py
  29. +42 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/big5prober.py
  30. +231 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/chardistribution.py
  31. +106 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/charsetgroupprober.py
  32. +62 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/charsetprober.py
  33. +61 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/codingstatemachine.py
  34. +34 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/compat.py
  35. +39 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/constants.py
  36. +44 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/cp949prober.py
  37. +86 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/escprober.py
  38. +242 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/escsm.py
  39. +90 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/eucjpprober.py
  40. +596 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/euckrfreq.py
  41. +42 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/euckrprober.py
  42. +428 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/euctwfreq.py
  43. +41 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/euctwprober.py
  44. +472 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/gb2312freq.py
  45. +41 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/gb2312prober.py
  46. +283 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/hebrewprober.py
  47. +569 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/jisfreq.py
  48. +219 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/jpcntx.py
  49. +229 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langbulgarianmodel.py
  50. +329 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langcyrillicmodel.py
  51. +225 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langgreekmodel.py
  52. +201 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langhebrewmodel.py
  53. +225 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langhungarianmodel.py
  54. +200 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/langthaimodel.py
  55. +139 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/latin1prober.py
  56. +86 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/mbcharsetprober.py
  57. +54 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/mbcsgroupprober.py
  58. +575 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/mbcssm.py
  59. +120 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/sbcharsetprober.py
  60. +69 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/sbcsgroupprober.py
  61. +91 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/sjisprober.py
  62. +172 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/universaldetector.py
  63. +76 −0 webapp-django/vendor-local/lib/python/requests/packages/charade/utf8prober.py
  64. +19 −3 webapp-django/vendor-local/lib/python/requests/packages/urllib3/__init__.py
  65. +67 −104 webapp-django/vendor-local/lib/python/requests/packages/urllib3/_collections.py
  66. +132 −57 webapp-django/vendor-local/lib/python/requests/packages/urllib3/connectionpool.py
  67. 0 webapp-django/vendor-local/lib/python/requests/packages/urllib3/contrib/__init__.py
  68. +120 −0 webapp-django/vendor-local/lib/python/requests/packages/urllib3/contrib/ntlmpool.py
  69. +167 −0 webapp-django/vendor-local/lib/python/requests/packages/urllib3/contrib/pyopenssl.py
  70. +39 −11 webapp-django/vendor-local/lib/python/requests/packages/urllib3/exceptions.py
  71. +24 −14 webapp-django/vendor-local/lib/python/requests/packages/urllib3/filepost.py
  72. +260 −0 webapp-django/vendor-local/lib/python/requests/packages/urllib3/packages/ordered_dict.py
  73. +33 −20 webapp-django/vendor-local/lib/python/requests/packages/urllib3/packages/six.py
  74. +95 −41 webapp-django/vendor-local/lib/python/requests/packages/urllib3/poolmanager.py
  75. +21 −7 webapp-django/vendor-local/lib/python/requests/packages/urllib3/request.py
  76. +70 −31 webapp-django/vendor-local/lib/python/requests/packages/urllib3/response.py
  77. +287 −45 webapp-django/vendor-local/lib/python/requests/packages/urllib3/util.py
  78. +369 −192 webapp-django/vendor-local/lib/python/requests/sessions.py
  79. +4 −3 webapp-django/vendor-local/lib/python/requests/status_codes.py
  80. +87 −25 webapp-django/vendor-local/lib/python/requests/structures.py
  81. +242 −147 webapp-django/vendor-local/lib/python/requests/utils.py
  82. +1 −0 webapp-django/vendor-local/src/django-browserid
  83. +1 −0 webapp-django/vendor-local/vendor.pth
View
@@ -10,3 +10,6 @@
[submodule "webapp-django/vendor"]
path = webapp-django/vendor
url = git://github.com/mozilla/playdoh-lib.git
+[submodule "webapp-django/vendor-local/src/django-browserid"]
+ path = webapp-django/vendor-local/src/django-browserid
+ url = https://github.com/mozilla/django-browserid.git
@@ -6,6 +6,14 @@
### From Mozillians
+class MockedResponse(object):
+ def __init__(self, response):
+ self.response = response
+
+ def json(self):
+ return self.response
+
+
class mock_browserid(object):
def __init__(self, email=None):
self.settings_patches = (
@@ -14,15 +22,19 @@ def __init__(self, email=None):
('django_browserid.auth.BrowserIDBackend',),
),
patch.object(
- settings, 'SITE_URL',
- 'http://testserver',
+ settings, 'BROWSERID_AUDIENCES',
+ ['http://testserver'],
)
)
- self.patcher = patch('django_browserid.base._verify_http_request')
+ self.patcher = patch('django_browserid.base.requests.post')
if email is not None:
- self.return_value = {'status': 'okay', 'email': email}
+ self.return_value = MockedResponse(
+ {'status': 'okay', 'email': email}
+ )
else:
- self.return_value = {'status': 'failure'}
+ self.return_value = MockedResponse(
+ {'status': 'failure'}
+ )
def __enter__(self):
for patch in self.settings_patches:
@@ -1,3 +1,5 @@
+import json
+
from nose.tools import eq_, ok_
from django.conf import settings
@@ -33,23 +35,21 @@ def _home_url(self):
def test_invalid(self):
"""Bad BrowserID form (i.e. no assertion) -> failure."""
response = self._login_attempt(None, None)
- eq_(response.status_code, 302)
- # not using assertRedirects because that makes it render the home URL
- # which means we need to mock the calls to the middleware
- ok_(self._home_url in response['Location'])
- ok_(response['Location'].endswith('?bid_login_failed=1'))
+ eq_(response.status_code, 403)
+ context = json.loads(response.content)
+ ok_(context['redirect'].endswith('?bid_login_failed=1'))
def test_bad_verification(self):
"""Bad verification -> failure."""
response = self._login_attempt(None)
- eq_(response.status_code, 302)
- ok_(self._home_url in response['Location'])
- ok_(response['Location'].endswith('?bid_login_failed=1'))
+ eq_(response.status_code, 403)
+ context = json.loads(response.content)
+ ok_(context['redirect'].endswith('?bid_login_failed=1'))
def test_successful_redirect(self):
response = self._login_attempt(
'peter@example.com',
- next='/something/?else=here'
)
- eq_(response.status_code, 302)
- ok_(response['Location'].endswith('/something/?else=here'))
+ eq_(response.status_code, 200)
+ context = json.loads(response.content)
+ eq_(context['redirect'], self._home_url)
@@ -36,7 +36,6 @@
</script>
</head>
<body>
- {{ browserid_info() }}
<div class="page-header">
<h1>
<a href="/">
@@ -134,7 +134,7 @@ SECRET_KEY = 'you must change this'
# If you intend to run with DEBUG=False, this must match the URL
# you're using
-#SITE_URL = 'http://localhost:8000'
+#BROWSERID_AUDIENCES = ['http://localhost:8000']
# Optional Google Analytics ID
#GOOGLE_ANALYTICS_ID = "UA-XXXXX-X"
@@ -37,7 +37,7 @@
(r'^api/', include('crashstats.api.urls', namespace='api')),
# if we ever use the Django admin we might want to change this URL
(r'^admin/', include('crashstats.manage.urls', namespace='manage')),
- (r'^browserid/', include('django_browserid.urls')),
+ (r'', include('django_browserid.urls')),
)
## In DEBUG mode, serve media files through Django.
@@ -37,6 +37,8 @@
# now re-arrange so the order is right
_other_path = manage.path('vendor-local/lib/python')
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)
+_other_path = manage.path('vendor-local')
+sys.path.insert(sys.path.index(_other_path) + 1, _new_path)
if __name__ == "__main__":
@@ -7,7 +7,6 @@ pyquery==1.2.6
# production libs
-requests==0.13.0
@lonnen
lonnen Mar 1, 2014 Member

wtf? how does this still work?!

@lonnen
lonnen Mar 1, 2014 Member

I see now that its checked into vendor local below.

python-memcached==1.48
isodate==0.4.7
ordereddict==1.1
@@ -40,4 +40,4 @@
SENTRY_DSN = None
-SITE_URL = 'http://localhost:8000'
+BROWSERID_AUDIENCES = ['http://testserver']
Oops, something went wrong.

0 comments on commit 03db93d

Please sign in to comment.