pyramid-fullauth 0.3.1__py2.7.egg → 0.3.2__py2.7.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. EGG-INFO/PKG-INFO +8 -1
  2. EGG-INFO/top_level.txt +1 -1
  3. pyramid_fullauth/__init__.py +1 -1
  4. pyramid_fullauth/__init__.pyc +0 -0
  5. pyramid_fullauth/auth.pyc +0 -0
  6. pyramid_fullauth/events.py +25 -11
  7. pyramid_fullauth/events.pyc +0 -0
  8. pyramid_fullauth/exceptions.pyc +0 -0
  9. pyramid_fullauth/models/__init__.pyc +0 -0
  10. pyramid_fullauth/models/mixins/__init__.pyc +0 -0
  11. pyramid_fullauth/models/mixins/email.pyc +0 -0
  12. pyramid_fullauth/models/mixins/password.pyc +0 -0
  13. pyramid_fullauth/request.py +3 -3
  14. pyramid_fullauth/request.pyc +0 -0
  15. pyramid_fullauth/routing/__init__.pyc +0 -0
  16. pyramid_fullauth/routing/predicates.pyc +0 -0
  17. pyramid_fullauth/tools.pyc +0 -0
  18. pyramid_fullauth/views/__init__.pyc +0 -0
  19. pyramid_fullauth/views/basic/__init__.pyc +0 -0
  20. pyramid_fullauth/views/basic/activate.py +2 -2
  21. pyramid_fullauth/views/basic/activate.pyc +0 -0
  22. pyramid_fullauth/views/basic/forbidden.pyc +0 -0
  23. pyramid_fullauth/views/basic/login.py +4 -4
  24. pyramid_fullauth/views/basic/login.pyc +0 -0
  25. pyramid_fullauth/views/basic/logout.py +3 -3
  26. pyramid_fullauth/views/basic/logout.pyc +0 -0
  27. pyramid_fullauth/views/basic/profile/__init__.pyc +0 -0
  28. pyramid_fullauth/views/basic/profile/email.py +5 -5
  29. pyramid_fullauth/views/basic/profile/email.pyc +0 -0
  30. pyramid_fullauth/views/basic/profile/password.py +4 -4
  31. pyramid_fullauth/views/basic/profile/password.pyc +0 -0
  32. pyramid_fullauth/views/basic/register.py +2 -2
  33. pyramid_fullauth/views/basic/register.pyc +0 -0
  34. pyramid_fullauth/views/social.py +5 -5
  35. pyramid_fullauth/views/social.pyc +0 -0
  36. tests/__init__.pyc +0 -0
  37. tests/conftest.pyc +0 -0
  38. tests/tools.py +1 -1
  39. tests/tools.pyc +0 -0
  40. tests/unit/test_default_settings.pyc +0 -0
  41. tests/unit/test_groupfinder.pyc +0 -0
  42. tests/unit/test_social_view.pyc +0 -0
  43. tests/unit/test_tools.pyc +0 -0
  44. tests/unit/test_user_active.pyc +0 -0
  45. tests/unit/test_user_admin.pyc +0 -0
  46. tests/unit/test_user_email.pyc +0 -0
  47. tests/unit/test_user_password.pyc +0 -0
  48. tests/unit/test_user_providers.pyc +0 -0
  49. tests/unit/test_user_repr.pyc +0 -0
  50. tests/unit/test_validators.pyc +0 -0
  51. tests/views/__init__.pyc +0 -0
  52. tests/views/conftest.pyc +0 -0
  53. tests/views/test_activation.pyc +0 -0
  54. tests/views/test_email.py +1 -1
  55. tests/views/test_email.pyc +0 -0
  56. tests/views/test_events.pyc +0 -0
  57. tests/views/test_login.py +2 -2
  58. tests/views/test_login.pyc +0 -0
  59. tests/views/test_login_social.pyc +0 -0
  60. tests/views/test_logout.py +2 -2
  61. tests/views/test_logout.pyc +0 -0
  62. tests/views/test_register.pyc +0 -0
  63. tests/views/test_reset.pyc +0 -0
EGG-INFO/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: pyramid-fullauth
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: This package intends to provide full authentication / authorisation
5
5
  implementation for pyramid applications
6
6
  Home-page: https://github.com/fizyk/pyramid_fullauth
@@ -73,6 +73,13 @@ Description: pyramid_fullauth
73
73
  CHANGELOG
74
74
  =========
75
75
 
76
+ 0.3.2
77
+ -----
78
+
79
+ - catch all HTTPRedirect instead of just HTTPFound.
80
+ - redirect with HTTPSeeOther instead of HTTPFound where applicable.
81
+
82
+
76
83
  0.3.1
77
84
  -----
78
85
 
EGG-INFO/top_level.txt CHANGED
@@ -1,2 +1,2 @@
1
- tests
2
1
  pyramid_fullauth
2
+ tests
@@ -17,7 +17,7 @@ from pyramid_fullauth.auth import groupfinder
17
17
  from pyramid_fullauth.routing import predicates
18
18
  from pyramid_fullauth.request import login_perform, logout, user
19
19
 
20
- __version__ = '0.3.1'
20
+ __version__ = '0.3.2'
21
21
 
22
22
 
23
23
  logger = logging.getLogger(__name__)
Binary file
pyramid_fullauth/auth.pyc CHANGED
Binary file
@@ -60,10 +60,12 @@ class AfterRegister(_BaseRegisterEvent):
60
60
  User object is already in a session.
61
61
 
62
62
  .. note::
63
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
63
+ Action emitting this event, should catch all HTTPRedirection that might
64
+ be risen in event listener.
64
65
 
65
66
  .. warning::
66
- If HTTPFound is risen from event listener, then response_values will not be used!
67
+ If HTTPRedirection is risen from event listener, then response_values
68
+ will not be used!
67
69
 
68
70
  """
69
71
 
@@ -85,7 +87,8 @@ class AfterActivate(_BaseRegisterEvent):
85
87
  Add custom post-processing logic after user gets activated.
86
88
 
87
89
  .. note::
88
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
90
+ Action emitting this event, should catch all HTTPRedirection that might
91
+ be risen in event listener.
89
92
  """
90
93
 
91
94
  pass
@@ -97,7 +100,8 @@ class AfterResetRequest(_BaseRegisterEvent):
97
100
  Add custom post-processing after user sends request to reset password.
98
101
 
99
102
  .. note::
100
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
103
+ Action emitting this event, should catch all HTTPRedirection that might
104
+ be risen in event listener.
101
105
  """
102
106
 
103
107
  pass
@@ -116,7 +120,8 @@ class AfterReset(_BaseRegisterEvent):
116
120
  Add custom post-processing after the actual reset-password process.
117
121
 
118
122
  .. note::
119
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
123
+ Action emitting this event, should catch all HTTPRedirection that might
124
+ be risen in event listener.
120
125
  """
121
126
 
122
127
  pass
@@ -128,7 +133,8 @@ class AlreadyLoggedIn(object):
128
133
  Allow execute custom logic, when logged in user tries to log in again.
129
134
 
130
135
  .. note::
131
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
136
+ Action emitting this event, should catch all HTTPRedirection that might
137
+ be risen in event listener.
132
138
 
133
139
  """
134
140
 
@@ -147,7 +153,8 @@ class BeforeLogIn(_BaseRegisterEvent):
147
153
  Add custom logic before user gets logged in.
148
154
 
149
155
  .. note::
150
- Action emitting this event, should catch all AttributeError that might be risen in event listener.
156
+ Action emitting this event, should catch all AttributeError that might
157
+ be risen in event listener.
151
158
  User param set to None when user is not found or request method is GET.
152
159
  """
153
160
 
@@ -194,7 +201,8 @@ class AfterSocialRegister(_BaseSocialRegister):
194
201
  Add custom logic after user registers through social network.
195
202
 
196
203
  .. note::
197
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
204
+ Action emitting this event, should catch all HTTPRedirection that might
205
+ be risen in event listener.
198
206
  """
199
207
 
200
208
  def __init__(self, request, user, profile, response_values):
@@ -216,7 +224,8 @@ class AfterSocialLogIn(_BaseSocialRegister):
216
224
  Custom logic after user logs in through social network.
217
225
 
218
226
  .. note::
219
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
227
+ Action emitting this event, should catch all HTTPRedirection that might
228
+ be risen in event listener.
220
229
  """
221
230
 
222
231
  pass
@@ -225,10 +234,15 @@ class AfterSocialLogIn(_BaseSocialRegister):
225
234
  class SocialAccountAlreadyConnected(_BaseSocialRegister):
226
235
 
227
236
  """
228
- Allow to add custom logic, when someone tries to connect social account to second user in application.
237
+ Event raised when social account is already connected to some other user.
238
+
239
+
240
+ Allow to add custom logic, when someone tries to connect social account to
241
+ second user in application.
229
242
 
230
243
  .. note::
231
- Action emitting this event, should catch all HTTPFound that might be risen in event listener.
244
+ Action emitting this event, should catch all HTTPRedirection that might
245
+ be risen in event listener.
232
246
  """
233
247
 
234
248
  def __init__(self, request, user, profile, response_values):
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -4,7 +4,7 @@
4
4
  # the MIT License (MIT): http://opensource.org/licenses/MIT
5
5
  """These method gets added to each ``pyramid.request.Request`` object."""
6
6
 
7
- from pyramid.httpexceptions import HTTPFound
7
+ from pyramid.httpexceptions import HTTPSeeOther
8
8
  from pyramid.security import remember, unauthenticated_userid, forget
9
9
  from sqlalchemy.sql.expression import func
10
10
  from sqlalchemy.orm.exc import NoResultFound
@@ -23,7 +23,7 @@ def login_perform(request, user, location=None, remember_me=False):
23
23
  :param bool remember_me: if True set cookie max_age to one month (60 * 60 * 24 * 30 seconds)
24
24
 
25
25
  :returns: redirect exception
26
- :rtype: pyramid.httpexceptions.HTTPFound
26
+ :rtype: pyramid.httpexceptions.HTTPSeeOther
27
27
  """
28
28
  user.logged_at = func.now()
29
29
  if remember_me: # if remember in POST set cookie timeout to one from configure
@@ -36,7 +36,7 @@ def login_perform(request, user, location=None, remember_me=False):
36
36
 
37
37
  # this remembers user immediately, without the need to redirect (see below)
38
38
  request.response.headers.extend(headers)
39
- return HTTPFound(location=location, headers=request.response.headers)
39
+ return HTTPSeeOther(location=location, headers=request.response.headers)
40
40
 
41
41
 
42
42
  def user(request):
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -5,7 +5,7 @@
5
5
  """Registration related views."""
6
6
 
7
7
  from pyramid.view import view_config
8
- from pyramid.httpexceptions import HTTPFound
8
+ from pyramid.httpexceptions import HTTPRedirection
9
9
  from pyramid.security import NO_PERMISSION_REQUIRED
10
10
 
11
11
  from sqlalchemy.orm.exc import NoResultFound
@@ -37,7 +37,7 @@ class ActivateView(BaseView):
37
37
  response['status'] = False
38
38
  try:
39
39
  self.request.registry.notify(AfterActivate(self.request, user))
40
- except HTTPFound as e:
40
+ except HTTPRedirection as e:
41
41
  # it's a redirect, let's follow it!
42
42
  return e
43
43
 
Binary file
Binary file
@@ -6,7 +6,7 @@
6
6
 
7
7
  from pyramid.view import view_config
8
8
  from pyramid.view import view_defaults
9
- from pyramid.httpexceptions import HTTPFound
9
+ from pyramid.httpexceptions import HTTPSeeOther, HTTPRedirection
10
10
  from pyramid.security import authenticated_userid
11
11
  from pyramid.security import NO_PERMISSION_REQUIRED
12
12
 
@@ -40,10 +40,10 @@ class BaseLoginView(BaseView):
40
40
 
41
41
  def _redirect_authenticated_user(self):
42
42
  """Redirect already logged in user away from login page."""
43
- redirect = HTTPFound(location=self.response['after'])
43
+ redirect = HTTPSeeOther(location=self.response['after'])
44
44
  try:
45
45
  self.request.registry.notify(AlreadyLoggedIn(self.request))
46
- except HTTPFound as redirect:
46
+ except HTTPRedirection as redirect:
47
47
  pass
48
48
 
49
49
  if self.request.is_xhr:
@@ -111,7 +111,7 @@ class LoginViewPost(BaseLoginView):
111
111
  except AttributeError as e:
112
112
  self.response['msg'] = str(e)
113
113
  return self.response
114
- except HTTPFound as redirect:
114
+ except HTTPRedirection as redirect:
115
115
  login_kwargs['location'] = redirect.location
116
116
 
117
117
  redirect = self.request.login_perform(user, **login_kwargs)
Binary file
@@ -5,7 +5,7 @@
5
5
  """De-authentication related view."""
6
6
 
7
7
  from pyramid.view import view_config
8
- from pyramid.httpexceptions import HTTPFound
8
+ from pyramid.httpexceptions import HTTPSeeOther
9
9
  from pyramid.security import NO_PERMISSION_REQUIRED
10
10
 
11
11
  from pyramid_fullauth.views import BaseView
@@ -24,5 +24,5 @@ class LogoutView(BaseView):
24
24
  # forget headers
25
25
  self.request.logout()
26
26
 
27
- return HTTPFound(location=location,
28
- headers=self.request.response.headers)
27
+ return HTTPSeeOther(location=location,
28
+ headers=self.request.response.headers)
Binary file
@@ -5,7 +5,7 @@
5
5
  """Email related views."""
6
6
 
7
7
  from pyramid.view import view_config, view_defaults
8
- from pyramid.httpexceptions import HTTPFound
8
+ from pyramid.httpexceptions import HTTPRedirection, HTTPSeeOther
9
9
  from pyramid.security import NO_PERMISSION_REQUIRED
10
10
 
11
11
  from sqlalchemy.orm.exc import NoResultFound
@@ -76,7 +76,7 @@ class EmailChangeViews(BaseView):
76
76
 
77
77
  try:
78
78
  self.request.registry.notify(AfterEmailChange(self.request, user))
79
- except HTTPFound as redirect:
79
+ except HTTPRedirection as redirect:
80
80
  if self.request.is_xhr:
81
81
  response_values['url'] = redirect.location
82
82
  return response_values
@@ -86,7 +86,7 @@ class EmailChangeViews(BaseView):
86
86
  if self.request.is_xhr:
87
87
  return response_values
88
88
  else:
89
- return HTTPFound(location='/')
89
+ return HTTPSeeOther(location='/')
90
90
 
91
91
 
92
92
  @view_config(route_name='email:change:continue', permission=NO_PERMISSION_REQUIRED,
@@ -102,6 +102,6 @@ class EmailChangeAccept(BaseView):
102
102
 
103
103
  try:
104
104
  self.request.registry.notify(AfterEmailChangeActivation(self.request, user))
105
- except HTTPFound as redirect:
105
+ except HTTPRedirection as redirect:
106
106
  return redirect
107
- return HTTPFound(location='/')
107
+ return HTTPSeeOther(location='/')
@@ -5,7 +5,7 @@
5
5
  """Profile related views."""
6
6
 
7
7
  from pyramid.view import view_config, view_defaults
8
- from pyramid.httpexceptions import HTTPFound
8
+ from pyramid.httpexceptions import HTTPRedirection, HTTPSeeOther
9
9
  from pyramid.security import NO_PERMISSION_REQUIRED
10
10
 
11
11
  from sqlalchemy.orm.exc import NoResultFound
@@ -52,10 +52,10 @@ class PasswordResetView(BaseView):
52
52
  user.set_reset()
53
53
  try:
54
54
  self.request.registry.notify(AfterResetRequest(self.request, user))
55
- except HTTPFound as redirect:
55
+ except HTTPRedirection as redirect:
56
56
  return redirect
57
57
 
58
- return HTTPFound(location='/')
58
+ return HTTPSeeOther(location='/')
59
59
 
60
60
 
61
61
  @view_defaults(route_name='password:reset:continue', permission=NO_PERMISSION_REQUIRED,
@@ -114,7 +114,7 @@ class PasswordResetContinueView(BaseView):
114
114
 
115
115
  try:
116
116
  self.request.registry.notify(AfterReset(self.request, user))
117
- except HTTPFound as redirect:
117
+ except HTTPRedirection as redirect:
118
118
  return redirect
119
119
  else:
120
120
  return {
@@ -5,7 +5,7 @@
5
5
  """Registration related views."""
6
6
 
7
7
  from pyramid.view import view_config, view_defaults
8
- from pyramid.httpexceptions import HTTPFound
8
+ from pyramid.httpexceptions import HTTPRedirection
9
9
  from pyramid.security import NO_PERMISSION_REQUIRED
10
10
 
11
11
  import pyramid_basemodel
@@ -53,7 +53,7 @@ class RegisterView(BaseView):
53
53
 
54
54
  try:
55
55
  self.request.registry.notify(AfterRegister(self.request, user, response))
56
- except HTTPFound as redirect:
56
+ except HTTPRedirection as redirect:
57
57
  return redirect
58
58
 
59
59
  return response
Binary file
@@ -6,7 +6,7 @@
6
6
  import logging
7
7
 
8
8
  from pyramid.view import view_config
9
- from pyramid.httpexceptions import HTTPFound
9
+ from pyramid.httpexceptions import HTTPRedirection
10
10
  from pyramid.security import NO_PERMISSION_REQUIRED
11
11
 
12
12
  from sqlalchemy.orm.exc import NoResultFound
@@ -106,14 +106,14 @@ class SocialLoginViews(BaseView):
106
106
  self.request.registry.notify(
107
107
  AfterSocialRegister(
108
108
  self.request, user, context.profile, response_values))
109
- except HTTPFound as redirect:
109
+ except HTTPRedirection as redirect:
110
110
  # it's a redirect, let's follow it!
111
111
  return redirect
112
112
 
113
113
  # if we're here, user exists,
114
114
  try:
115
115
  self.request.registry.notify(AfterSocialLogIn(self.request, user, context.profile))
116
- except HTTPFound as redirect:
116
+ except HTTPRedirection as redirect:
117
117
  # it's a redirect, let's follow it!
118
118
  return self.request.login_perform(user, location=redirect.location)
119
119
  else:
@@ -126,7 +126,7 @@ class SocialLoginViews(BaseView):
126
126
  :param dict response_values:
127
127
 
128
128
  :returns: response values with any message,
129
- or HTTPFound if raised in SocialAccountAlreadyConnected
129
+ or HTTPRedirection if raised in SocialAccountAlreadyConnected
130
130
  :rtype: dict
131
131
  """
132
132
  context = self.request.context
@@ -157,7 +157,7 @@ class SocialLoginViews(BaseView):
157
157
  self.request.registry.notify(
158
158
  SocialAccountAlreadyConnected(
159
159
  self.request, user, context.profile, response_values))
160
- except HTTPFound as redirect:
160
+ except HTTPRedirection as redirect:
161
161
  # it's a redirect, let's follow it!
162
162
  return redirect
163
163
  return response_values
Binary file
tests/__init__.pyc CHANGED
Binary file
tests/conftest.pyc CHANGED
Binary file
tests/tools.py CHANGED
@@ -13,7 +13,7 @@ DEFAULT_USER = {
13
13
  def authenticate(app, email=DEFAULT_USER['email'],
14
14
  password=DEFAULT_USER['password'],
15
15
  remember=False,
16
- response_code=302):
16
+ response_code=303):
17
17
  """Authenticate user."""
18
18
  res = app.get('/login')
19
19
  form = res.form
tests/tools.pyc CHANGED
Binary file
Binary file
Binary file
Binary file
tests/unit/test_tools.pyc CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
tests/views/__init__.pyc CHANGED
Binary file
tests/views/conftest.pyc CHANGED
Binary file
Binary file
tests/views/test_email.py CHANGED
@@ -146,7 +146,7 @@ def test_email_proceed(db_session, active_user, default_app):
146
146
 
147
147
  user = db_session.merge(user)
148
148
  res = app.get('/email/change/' + user.email_change_key)
149
- assert res.status_code == 302
149
+ assert res.status_code == 303
150
150
 
151
151
  with pytest.raises(NoResultFound):
152
152
  # there is no user with old email
Binary file
Binary file
tests/views/test_login.py CHANGED
@@ -67,7 +67,7 @@ def test_login_redirects(active_user, extended_app):
67
67
  res = res.form.submit()
68
68
 
69
69
  assert is_user_logged(extended_app) is True
70
- assert res.status_code == 302
70
+ assert res.status_code == 303
71
71
 
72
72
 
73
73
  @pytest.mark.parametrize('user_kwargs', (
@@ -147,5 +147,5 @@ def test_default_login_forbidden(active_user, authable_app):
147
147
  def test_default_login_redirectaway(active_user, authable_app):
148
148
  """After successful login, access to login page should result in redirect."""
149
149
  authenticate(authable_app)
150
- res = authable_app.get('/login', status=302)
150
+ res = authable_app.get('/login', status=303)
151
151
  assert res.location == 'http://localhost/'
Binary file
Binary file
@@ -9,7 +9,7 @@ def test_logout(active_user, extended_app):
9
9
  authenticate(extended_app)
10
10
  assert is_user_logged(extended_app) is True
11
11
 
12
- extended_app.get('/logout', status=302)
12
+ extended_app.get('/logout', status=303)
13
13
  assert is_user_logged(extended_app) is False
14
14
  res = extended_app.get('/secret', status=302)
15
15
  assert res.status_code == 302
@@ -21,7 +21,7 @@ def test_logout_login(active_user, extended_config, extended_app):
21
21
  authenticate(extended_app)
22
22
  assert is_user_logged(extended_app) is True
23
23
 
24
- res = extended_app.get('/logout', status=302)
24
+ res = extended_app.get('/logout', status=303)
25
25
  assert is_user_logged(extended_app) is False
26
26
  # redirection should be done to login page.
27
27
  assert '/login' in res.location
Binary file
Binary file
Binary file