pyramid-fullauth 0.3.0__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 (113) hide show
  1. EGG-INFO/PKG-INFO +176 -0
  2. EGG-INFO/SOURCES.txt +91 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/requires.txt +17 -0
  6. EGG-INFO/top_level.txt +2 -0
  7. pyramid_fullauth/__init__.py +105 -0
  8. pyramid_fullauth/__init__.pyc +0 -0
  9. pyramid_fullauth/auth.py +66 -0
  10. pyramid_fullauth/auth.pyc +0 -0
  11. pyramid_fullauth/events.py +267 -0
  12. pyramid_fullauth/events.pyc +0 -0
  13. pyramid_fullauth/exceptions.py +47 -0
  14. pyramid_fullauth/exceptions.pyc +0 -0
  15. pyramid_fullauth/models/__init__.py +189 -0
  16. pyramid_fullauth/models/__init__.pyc +0 -0
  17. pyramid_fullauth/models/mixins/__init__.py +9 -0
  18. pyramid_fullauth/models/mixins/__init__.pyc +0 -0
  19. pyramid_fullauth/models/mixins/email.py +81 -0
  20. pyramid_fullauth/models/mixins/email.pyc +0 -0
  21. pyramid_fullauth/models/mixins/password.py +141 -0
  22. pyramid_fullauth/models/mixins/password.pyc +0 -0
  23. pyramid_fullauth/request.py +69 -0
  24. pyramid_fullauth/request.pyc +0 -0
  25. pyramid_fullauth/resources/helpers/social.mako +17 -0
  26. pyramid_fullauth/resources/locale/pyramid_fullauth.pot +216 -0
  27. pyramid_fullauth/resources/templates/403.mako +11 -0
  28. pyramid_fullauth/resources/templates/_form.login.mako +44 -0
  29. pyramid_fullauth/resources/templates/_form.register.mako +47 -0
  30. pyramid_fullauth/resources/templates/_social.login.mako +17 -0
  31. pyramid_fullauth/resources/templates/activate.mako +14 -0
  32. pyramid_fullauth/resources/templates/email_change.mako +33 -0
  33. pyramid_fullauth/resources/templates/layout.mako +13 -0
  34. pyramid_fullauth/resources/templates/login.mako +14 -0
  35. pyramid_fullauth/resources/templates/register.mako +22 -0
  36. pyramid_fullauth/resources/templates/reset.mako +34 -0
  37. pyramid_fullauth/resources/templates/reset.proceed.mako +41 -0
  38. pyramid_fullauth/routing/__init__.py +5 -0
  39. pyramid_fullauth/routing/__init__.pyc +0 -0
  40. pyramid_fullauth/routing/predicates.py +86 -0
  41. pyramid_fullauth/routing/predicates.pyc +0 -0
  42. pyramid_fullauth/tools.py +66 -0
  43. pyramid_fullauth/tools.pyc +0 -0
  44. pyramid_fullauth/views/__init__.py +15 -0
  45. pyramid_fullauth/views/__init__.pyc +0 -0
  46. pyramid_fullauth/views/basic/__init__.py +5 -0
  47. pyramid_fullauth/views/basic/__init__.pyc +0 -0
  48. pyramid_fullauth/views/basic/activate.py +44 -0
  49. pyramid_fullauth/views/basic/activate.pyc +0 -0
  50. pyramid_fullauth/views/basic/forbidden.py +47 -0
  51. pyramid_fullauth/views/basic/forbidden.pyc +0 -0
  52. pyramid_fullauth/views/basic/login.py +128 -0
  53. pyramid_fullauth/views/basic/login.pyc +0 -0
  54. pyramid_fullauth/views/basic/logout.py +28 -0
  55. pyramid_fullauth/views/basic/logout.pyc +0 -0
  56. pyramid_fullauth/views/basic/profile/__init__.py +5 -0
  57. pyramid_fullauth/views/basic/profile/__init__.pyc +0 -0
  58. pyramid_fullauth/views/basic/profile/email.py +107 -0
  59. pyramid_fullauth/views/basic/profile/email.pyc +0 -0
  60. pyramid_fullauth/views/basic/profile/password.py +128 -0
  61. pyramid_fullauth/views/basic/profile/password.pyc +0 -0
  62. pyramid_fullauth/views/basic/register.py +110 -0
  63. pyramid_fullauth/views/basic/register.pyc +0 -0
  64. pyramid_fullauth/views/social.py +218 -0
  65. pyramid_fullauth/views/social.pyc +0 -0
  66. tests/__init__.py +1 -0
  67. tests/__init__.pyc +0 -0
  68. tests/conftest.py +190 -0
  69. tests/conftest.pyc +0 -0
  70. tests/tools.py +54 -0
  71. tests/tools.pyc +0 -0
  72. tests/unit/test_default_settings.py +15 -0
  73. tests/unit/test_default_settings.pyc +0 -0
  74. tests/unit/test_groupfinder.py +20 -0
  75. tests/unit/test_groupfinder.pyc +0 -0
  76. tests/unit/test_social_view.py +65 -0
  77. tests/unit/test_social_view.pyc +0 -0
  78. tests/unit/test_tools.py +24 -0
  79. tests/unit/test_tools.pyc +0 -0
  80. tests/unit/test_user_active.py +31 -0
  81. tests/unit/test_user_active.pyc +0 -0
  82. tests/unit/test_user_admin.py +61 -0
  83. tests/unit/test_user_admin.pyc +0 -0
  84. tests/unit/test_user_email.py +37 -0
  85. tests/unit/test_user_email.pyc +0 -0
  86. tests/unit/test_user_password.py +52 -0
  87. tests/unit/test_user_password.pyc +0 -0
  88. tests/unit/test_user_providers.py +24 -0
  89. tests/unit/test_user_providers.pyc +0 -0
  90. tests/unit/test_user_repr.py +29 -0
  91. tests/unit/test_user_repr.pyc +0 -0
  92. tests/unit/test_validators.py +44 -0
  93. tests/unit/test_validators.pyc +0 -0
  94. tests/views/__init__.py +1 -0
  95. tests/views/__init__.pyc +0 -0
  96. tests/views/conftest.py +15 -0
  97. tests/views/conftest.pyc +0 -0
  98. tests/views/test_activation.py +83 -0
  99. tests/views/test_activation.pyc +0 -0
  100. tests/views/test_email.py +175 -0
  101. tests/views/test_email.pyc +0 -0
  102. tests/views/test_events.py +546 -0
  103. tests/views/test_events.pyc +0 -0
  104. tests/views/test_login.py +151 -0
  105. tests/views/test_login.pyc +0 -0
  106. tests/views/test_login_social.py +254 -0
  107. tests/views/test_login_social.pyc +0 -0
  108. tests/views/test_logout.py +42 -0
  109. tests/views/test_logout.pyc +0 -0
  110. tests/views/test_register.py +134 -0
  111. tests/views/test_register.pyc +0 -0
  112. tests/views/test_reset.py +100 -0
  113. tests/views/test_reset.pyc +0 -0
EGG-INFO/PKG-INFO ADDED
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 1.1
2
+ Name: pyramid-fullauth
3
+ Version: 0.3.0
4
+ Summary: This package intends to provide full authentication / authorisation
5
+ implementation for pyramid applications
6
+ Home-page: https://github.com/fizyk/pyramid_fullauth
7
+ Author: Grzegorz Sliwinski
8
+ Author-email: fizyk@fizyk.net.pl
9
+ License: MIT License
10
+ Description: pyramid_fullauth
11
+ ================
12
+
13
+ .. image:: https://pypip.in/v/pyramid_fullauth/badge.png
14
+ :target: https://pypi.python.org/pypi/pyramid_fullauth/
15
+ :alt: Latest PyPI version
16
+
17
+ .. image:: https://pypip.in/d/pyramid_fullauth/badge.png
18
+ :target: https://pypi.python.org/pypi/pyramid_fullauth/
19
+ :alt: Number of PyPI downloads
20
+
21
+ .. image:: https://pypip.in/wheel/pyramid_fullauth/badge.png
22
+ :target: https://pypi.python.org/pypi/pyramid_fullauth/
23
+ :alt: Wheel Status
24
+
25
+ .. image:: https://pypip.in/egg/pyramid_fullauth/badge.png
26
+ :target: https://pypi.python.org/pypi/pyramid_fullauth/
27
+ :alt: Egg Status
28
+
29
+ .. image:: https://pypip.in/license/pyramid_fullauth/badge.png
30
+ :target: https://pypi.python.org/pypi/pyramid_fullauth/
31
+ :alt: License
32
+
33
+ Pyramid fullauth's goal is to provide full plug-in registration functionality for pyramid, with user managing
34
+
35
+ Package status
36
+ --------------
37
+
38
+ .. image:: https://travis-ci.org/fizyk/pyramid_fullauth.png?branch=master
39
+ :target: https://travis-ci.org/fizyk/pyramid_fullauth
40
+ :alt: Tests
41
+
42
+ .. image:: https://coveralls.io/repos/fizyk/pyramid_fullauth/badge.png?branch=master
43
+ :target: https://coveralls.io/r/fizyk/pyramid_fullauth?branch=master
44
+ :alt: Coverage Status
45
+
46
+ .. image:: https://requires.io/github/fizyk/pyramid_fullauth/requirements.png?branch=master
47
+ :target: https://requires.io/github/fizyk/pyramid_fullauth/requirements/?branch=master
48
+ :alt: Requirements Status
49
+
50
+ Package resources
51
+ -----------------
52
+
53
+ * Bug tracker: https://github.com/fizyk/pyramid_fullauth/issues
54
+ * Documentation: http://pyramid-fullauth.readthedocs.org/
55
+ * PyPI: https://pypi.python.org/pypi/pyramid_fullauth
56
+
57
+ Instalation
58
+ -----------
59
+
60
+ ``pip install pyramid_fullauth``
61
+
62
+ or add **pyramid_fullauth** to your **setup.py** requirements.
63
+
64
+
65
+ Tests
66
+ -----
67
+
68
+ You'll need: packages defined in extra_requires[tests] to run tests, and then:
69
+
70
+ ``py.test``
71
+
72
+
73
+ CHANGELOG
74
+ =========
75
+
76
+ 0.3.0
77
+ -----
78
+
79
+ Features
80
+ ++++++++
81
+
82
+ - configure root factory if it hasn't been already done
83
+ - configure session factory only if it hasn't been configured before
84
+ - configure authorization policy only if it hasn't been configured before
85
+ - configure authentication policy only if it hasn't been configured before
86
+ - logged in user will be redirected always away from login page
87
+ - views reorganisation - grouping by their function
88
+ - replaced force_logout decorator with logout request method
89
+ - small login view simplification
90
+
91
+ tests
92
+ +++++
93
+
94
+ - rewritten tests to use pytest_pyramid
95
+ - unified session with pyramid_basemodel's
96
+ - parametrize tests against two most recent pyramid versions and sqlalchemy
97
+ - turned on pylama to check code with linters:
98
+ - pep8
99
+ - pep257
100
+ - pyflakes
101
+ - mccabe
102
+ - add pytest-dbfixtures, and run tests against postgresql and mysql as well
103
+ - drop python 2.6 from tests
104
+ - 100% test coverage
105
+
106
+
107
+ 0.2.3
108
+ -----
109
+ - weaker pyramid_yml requirements. Use ``registry['config']`` instead of ``request.config`` which gets added only whet explicitly including tzf.pyramid_yml package.
110
+ - remove default_config with permission set for forbidden views. Throwning errors in pyramid 1.5a3
111
+ - remove lazy='load' for relationship between AuthenticationProvider and User models as it was incorrect. Fixes error while using with sqlalchemy 0.9
112
+
113
+ 0.2.2
114
+ -----
115
+ - copy all headers when login user. fixes issue, when headers set in AfterLogin event would not get passed
116
+
117
+ 0.2.1
118
+ -----
119
+ - fixed csrf_check in password:reset:continue action
120
+ - updated translation files
121
+
122
+ 0.2.0
123
+ -----
124
+ - migrated tests to py.test
125
+ - removed nose and lxml from test requirements
126
+ - extracted UserEmailMixin from User model
127
+ - validation exception improvements
128
+ - set licensing to MIT License
129
+ - fixed general error message for register_POST processing
130
+ - activate action no longer gives 404 error after first use. Default is message about token being invalid or used [veronicazgirvaci]
131
+ - extending csrf_check predicate:
132
+ - Can be turned on/off in settings.
133
+ - Failed check rises 401 Unauthorised error
134
+
135
+ Backwards Incompatibilities
136
+ +++++++++++++++++++++++++++
137
+
138
+ - token variable is changed into csrf_token in fullatuh views
139
+ - view no longer returns error messages on failed csrf token. Rises 401 Unauthorised error instead.
140
+
141
+
142
+ 0.1.0
143
+ -----
144
+ - add localize to requirements. Ability to translate registerlogin communicates
145
+ - ability to set custom session factory [with Veronica Zgirvaci help]
146
+ - moved password validation to one place
147
+
148
+ 0.0.4
149
+ -----
150
+ - remove basemodel restrictions from setup.py
151
+
152
+ 0.0.3
153
+ -----
154
+ - fixed issue, where reset password would check for csrf on GET request [Veronica Zgirvaci]
155
+
156
+ 0.0.2
157
+ -----
158
+ - fixed MANIFEST.in, to include .yml, and .mako files
159
+
160
+ 0.0.1
161
+ -----
162
+ - initial package creation
163
+ - prepared for CI on travis-ci, and coverage reports on coveralls.io
164
+
165
+ Keywords: python authentication authorisation pyramid
166
+ Platform: UNKNOWN
167
+ Classifier: Development Status :: 5 - Production/Stable
168
+ Classifier: Environment :: Web Environment
169
+ Classifier: Intended Audience :: Developers
170
+ Classifier: License :: OSI Approved :: MIT License
171
+ Classifier: Natural Language :: English
172
+ Classifier: Operating System :: OS Independent
173
+ Classifier: Programming Language :: Python
174
+ Classifier: Programming Language :: Python :: 2.6
175
+ Classifier: Programming Language :: Python :: 2.7
176
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
EGG-INFO/SOURCES.txt ADDED
@@ -0,0 +1,91 @@
1
+ AUTHORS.rst
2
+ CHANGES.rst
3
+ MANIFEST.in
4
+ README.rst
5
+ setup.cfg
6
+ setup.py
7
+ docs/Makefile
8
+ docs/make.bat
9
+ docs/source/advanced.rst
10
+ docs/source/api.rst
11
+ docs/source/authors.rst
12
+ docs/source/basic.rst
13
+ docs/source/changelog.rst
14
+ docs/source/conf.py
15
+ docs/source/customise.rst
16
+ docs/source/index.rst
17
+ docs/source/narrative.rst
18
+ docs/source/social.rst
19
+ docs/source/api/auth.rst
20
+ docs/source/api/events.rst
21
+ docs/source/api/exceptions.rst
22
+ docs/source/api/models.rst
23
+ docs/source/api/predicates.rst
24
+ docs/source/api/request.rst
25
+ docs/source/api/tools.rst
26
+ pyramid_fullauth/__init__.py
27
+ pyramid_fullauth/auth.py
28
+ pyramid_fullauth/events.py
29
+ pyramid_fullauth/exceptions.py
30
+ pyramid_fullauth/request.py
31
+ pyramid_fullauth/tools.py
32
+ pyramid_fullauth.egg-info/PKG-INFO
33
+ pyramid_fullauth.egg-info/SOURCES.txt
34
+ pyramid_fullauth.egg-info/dependency_links.txt
35
+ pyramid_fullauth.egg-info/not-zip-safe
36
+ pyramid_fullauth.egg-info/requires.txt
37
+ pyramid_fullauth.egg-info/top_level.txt
38
+ pyramid_fullauth/models/__init__.py
39
+ pyramid_fullauth/models/mixins/__init__.py
40
+ pyramid_fullauth/models/mixins/email.py
41
+ pyramid_fullauth/models/mixins/password.py
42
+ pyramid_fullauth/resources/helpers/social.mako
43
+ pyramid_fullauth/resources/locale/pyramid_fullauth.pot
44
+ pyramid_fullauth/resources/templates/403.mako
45
+ pyramid_fullauth/resources/templates/_form.login.mako
46
+ pyramid_fullauth/resources/templates/_form.register.mako
47
+ pyramid_fullauth/resources/templates/_social.login.mako
48
+ pyramid_fullauth/resources/templates/activate.mako
49
+ pyramid_fullauth/resources/templates/email_change.mako
50
+ pyramid_fullauth/resources/templates/layout.mako
51
+ pyramid_fullauth/resources/templates/login.mako
52
+ pyramid_fullauth/resources/templates/register.mako
53
+ pyramid_fullauth/resources/templates/reset.mako
54
+ pyramid_fullauth/resources/templates/reset.proceed.mako
55
+ pyramid_fullauth/routing/__init__.py
56
+ pyramid_fullauth/routing/predicates.py
57
+ pyramid_fullauth/views/__init__.py
58
+ pyramid_fullauth/views/social.py
59
+ pyramid_fullauth/views/basic/__init__.py
60
+ pyramid_fullauth/views/basic/activate.py
61
+ pyramid_fullauth/views/basic/forbidden.py
62
+ pyramid_fullauth/views/basic/login.py
63
+ pyramid_fullauth/views/basic/logout.py
64
+ pyramid_fullauth/views/basic/register.py
65
+ pyramid_fullauth/views/basic/profile/__init__.py
66
+ pyramid_fullauth/views/basic/profile/email.py
67
+ pyramid_fullauth/views/basic/profile/password.py
68
+ tests/__init__.py
69
+ tests/conftest.py
70
+ tests/tools.py
71
+ tests/unit/test_default_settings.py
72
+ tests/unit/test_groupfinder.py
73
+ tests/unit/test_social_view.py
74
+ tests/unit/test_tools.py
75
+ tests/unit/test_user_active.py
76
+ tests/unit/test_user_admin.py
77
+ tests/unit/test_user_email.py
78
+ tests/unit/test_user_password.py
79
+ tests/unit/test_user_providers.py
80
+ tests/unit/test_user_repr.py
81
+ tests/unit/test_validators.py
82
+ tests/views/__init__.py
83
+ tests/views/conftest.py
84
+ tests/views/test_activation.py
85
+ tests/views/test_email.py
86
+ tests/views/test_events.py
87
+ tests/views/test_login.py
88
+ tests/views/test_login_social.py
89
+ tests/views/test_logout.py
90
+ tests/views/test_register.py
91
+ tests/views/test_reset.py
@@ -0,0 +1 @@
1
+
EGG-INFO/not-zip-safe ADDED
@@ -0,0 +1 @@
1
+
EGG-INFO/requires.txt ADDED
@@ -0,0 +1,17 @@
1
+ pyramid_localize
2
+ pyramid >=1.4
3
+ pyramid_mako
4
+ tzf.pyramid_yml >=1.0
5
+ pyramid_basemodel
6
+ velruse
7
+
8
+ [docs]
9
+ sphinx
10
+
11
+ [tests]
12
+ mock
13
+ pytest_pyramid
14
+ pytest-dbfixtures
15
+ mysql-python
16
+ psycopg2
17
+ pytest-cov
EGG-INFO/top_level.txt ADDED
@@ -0,0 +1,2 @@
1
+ tests
2
+ pyramid_fullauth
@@ -0,0 +1,105 @@
1
+ # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_fullauth and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Fullauth's configuration module."""
6
+
7
+ import logging
8
+
9
+ from tzf.pyramid_yml import config_defaults
10
+ from pyramid.authorization import ACLAuthorizationPolicy
11
+ from pyramid.authentication import AuthTktAuthenticationPolicy
12
+ from pyramid.interfaces import (
13
+ IAuthorizationPolicy, IAuthenticationPolicy, IRootFactory, ISessionFactory
14
+ )
15
+
16
+ from pyramid_fullauth.auth import groupfinder
17
+ from pyramid_fullauth.routing import predicates
18
+ from pyramid_fullauth.request import login_perform, logout, user
19
+
20
+ __version__ = '0.3.0'
21
+
22
+
23
+ logger = logging.getLogger(__name__)
24
+
25
+
26
+ def includeme(configurator):
27
+ """
28
+ Configure pyramid_fullauth on application.
29
+
30
+ :param pyramid.configurator.Configurator configurator: pyramid's configurator object
31
+ """
32
+ config_defaults(configurator, 'pyramid_fullauth:config/default.yaml')
33
+ configurator.include('pyramid_localize')
34
+ configurator.include('pyramid_mako')
35
+ fullauth_config = configurator.registry['config'].fullauth
36
+
37
+ if configurator.registry.queryUtility(IAuthorizationPolicy) is None:
38
+ configurator.set_authorization_policy(ACLAuthorizationPolicy())
39
+
40
+ # register authentication policy, only if not set already
41
+ if configurator.registry.queryUtility(IAuthenticationPolicy) is None:
42
+ configurator.set_authentication_policy(
43
+ AuthTktAuthenticationPolicy(callback=groupfinder,
44
+ **fullauth_config.AuthTkt))
45
+
46
+ # register root factory, only if not set already
47
+ if configurator.registry.queryUtility(IRootFactory) is None:
48
+ configurator.set_root_factory(
49
+ 'pyramid_fullauth.auth.BaseACLRootFactoryMixin')
50
+
51
+ # register session factory, only, if not already registered
52
+ if configurator.registry.queryUtility(ISessionFactory) is None:
53
+ # loading and setting session factory
54
+ # first, divide provided path for module, and factory name
55
+ module, factory = fullauth_config.session.factory.rsplit('.', 1)
56
+ # import session module first
57
+ session_module = __import__(module, fromlist=[module])
58
+ # get the factory class
59
+ session_factory = getattr(session_module, factory)
60
+
61
+ # set the new session factory
62
+ configurator.set_session_factory(
63
+ session_factory(**fullauth_config.session.settings))
64
+
65
+ configurator.add_view_predicate(
66
+ 'check_csrf', predicates.CSRFCheckPredicate)
67
+
68
+ # add routes
69
+ configurator.add_route(name='login', pattern='/login')
70
+ configurator.add_route(name='logout', pattern='/logout')
71
+ configurator.add_route(name='register', pattern='/register')
72
+ configurator.add_route(
73
+ name='register:activate', pattern='/register/activate/{hash}')
74
+ configurator.add_route(name='password:reset', pattern='/password/reset')
75
+ configurator.add_route(
76
+ name='password:reset:continue', pattern='/password/reset/{hash}',
77
+ custom_predicates=(predicates.reset_hash,))
78
+ configurator.add_route(name='email:change', pattern='/email/change')
79
+ configurator.add_route(
80
+ name='email:change:continue', pattern='/email/change/{hash}',
81
+ custom_predicates=(predicates.change_email_hash,))
82
+ # scan base views
83
+ configurator.scan('pyramid_fullauth.views.basic')
84
+
85
+ # check for the social. If social is not available, we will not turn it on!
86
+ if 'social' in fullauth_config:
87
+ # Velruse init (for social auth)
88
+
89
+ # scan social views
90
+ configurator.scan('pyramid_fullauth.views.social')
91
+ providers = fullauth_config.social
92
+ configurator.registry['config']['login_providers'] = providers
93
+ for provider in providers:
94
+ # Ugly hack for using google oauth2, not OpenID + Oauth2 from google
95
+ provider_settings = fullauth_config['social'][provider]
96
+ if provider == 'google': # pragma: no cover
97
+ provider = 'google_oauth2'
98
+
99
+ configurator.include('velruse.providers.' + provider)
100
+ getattr(configurator, 'add_{0}_login'.format(provider))(**provider_settings)
101
+
102
+ # we'll add some request methods:
103
+ configurator.add_request_method(login_perform, name='login_perform')
104
+ configurator.add_request_method(logout, name='logout')
105
+ configurator.add_request_method(user, name='user', reify=True)
Binary file
@@ -0,0 +1,66 @@
1
+ # Copyright (c) 2013 - 2014 by pyramid_fullauth authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_fullauth and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Auth related methods and classes."""
6
+
7
+ from pyramid.security import Allow, Everyone, ALL_PERMISSIONS
8
+
9
+
10
+ def groupfinder(userid, request):
11
+ """
12
+ Read all user's groups.
13
+
14
+ .. note::
15
+
16
+ Adds **s:inactive** group to users who has not activated their account, and **s:user** group to those, who did.
17
+ If user has is_admin flag, he gets **s:superadmin** group set
18
+
19
+ Might be useful, when you want restrict access to some parts of your application, but still allow log in, and access to some other parts.
20
+
21
+ :param int userid: user identity
22
+ :param pyramid.request.Request request: request object
23
+ :returns: list of groups
24
+ :rtype: list
25
+ """
26
+ user = request.user
27
+ groups = []
28
+ if user and user.id == userid:
29
+ groups = [group.name for group in user.groups]
30
+
31
+ # let's add inactive group for users that have not activated their account
32
+
33
+ if user.is_admin:
34
+ groups.append('s:superadmin')
35
+
36
+ if user.is_active:
37
+ groups.append('s:user')
38
+ else:
39
+ groups.append('s:inactive')
40
+
41
+ return groups
42
+
43
+
44
+ class BaseACLRootFactoryMixin(object):
45
+
46
+ """
47
+ ACL list factory Mixin.
48
+
49
+ __acl__ is the attribute which stores the list.
50
+
51
+ :return: tuple (Allow|Deny, Group name, Permission)
52
+ :rtype: list
53
+
54
+ .. note::
55
+
56
+ Can be converted later to database stored (sqlalchemy session is accessible through request.db)
57
+ """
58
+
59
+ __acl__ = [(Allow, Everyone, 'view'),
60
+ (Allow, 's:superadmin', ALL_PERMISSIONS),
61
+ (Allow, 's:user', ('password_change', 'email_change'))
62
+ ]
63
+
64
+ def __init__(self, request):
65
+ """Assing request as instance attribute."""
66
+ self.request = request
Binary file