pyramid-fullauth 0.4.0__py3.4.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 (116) hide show
  1. EGG-INFO/PKG-INFO +184 -0
  2. EGG-INFO/SOURCES.txt +93 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/requires.txt +13 -0
  6. EGG-INFO/top_level.txt +2 -0
  7. pyramid_fullauth/__init__.py +106 -0
  8. pyramid_fullauth/__pycache__/__init__.cpython-34.pyc +0 -0
  9. pyramid_fullauth/__pycache__/auth.cpython-34.pyc +0 -0
  10. pyramid_fullauth/__pycache__/events.cpython-34.pyc +0 -0
  11. pyramid_fullauth/__pycache__/exceptions.cpython-34.pyc +0 -0
  12. pyramid_fullauth/__pycache__/request.cpython-34.pyc +0 -0
  13. pyramid_fullauth/__pycache__/tools.cpython-34.pyc +0 -0
  14. pyramid_fullauth/auth.py +67 -0
  15. pyramid_fullauth/config/default.yaml +26 -0
  16. pyramid_fullauth/events.py +281 -0
  17. pyramid_fullauth/exceptions.py +47 -0
  18. pyramid_fullauth/models/__init__.py +190 -0
  19. pyramid_fullauth/models/__pycache__/__init__.cpython-34.pyc +0 -0
  20. pyramid_fullauth/models/extensions/__init__.py +39 -0
  21. pyramid_fullauth/models/extensions/__pycache__/__init__.cpython-34.pyc +0 -0
  22. pyramid_fullauth/models/mixins/__init__.py +9 -0
  23. pyramid_fullauth/models/mixins/__pycache__/__init__.cpython-34.pyc +0 -0
  24. pyramid_fullauth/models/mixins/__pycache__/email.cpython-34.pyc +0 -0
  25. pyramid_fullauth/models/mixins/__pycache__/password.cpython-34.pyc +0 -0
  26. pyramid_fullauth/models/mixins/email.py +128 -0
  27. pyramid_fullauth/models/mixins/password.py +141 -0
  28. pyramid_fullauth/request.py +70 -0
  29. pyramid_fullauth/resources/helpers/social.mako +17 -0
  30. pyramid_fullauth/resources/locale/pyramid_fullauth.pot +216 -0
  31. pyramid_fullauth/resources/templates/403.mako +11 -0
  32. pyramid_fullauth/resources/templates/_form.login.mako +44 -0
  33. pyramid_fullauth/resources/templates/_form.register.mako +47 -0
  34. pyramid_fullauth/resources/templates/_social.login.mako +17 -0
  35. pyramid_fullauth/resources/templates/activate.mako +14 -0
  36. pyramid_fullauth/resources/templates/email_change.mako +33 -0
  37. pyramid_fullauth/resources/templates/layout.mako +13 -0
  38. pyramid_fullauth/resources/templates/login.mako +17 -0
  39. pyramid_fullauth/resources/templates/register.mako +22 -0
  40. pyramid_fullauth/resources/templates/reset.mako +34 -0
  41. pyramid_fullauth/resources/templates/reset.proceed.mako +41 -0
  42. pyramid_fullauth/routing/__init__.py +5 -0
  43. pyramid_fullauth/routing/__pycache__/__init__.cpython-34.pyc +0 -0
  44. pyramid_fullauth/routing/__pycache__/predicates.cpython-34.pyc +0 -0
  45. pyramid_fullauth/routing/predicates.py +86 -0
  46. pyramid_fullauth/tools.py +69 -0
  47. pyramid_fullauth/views/__init__.py +15 -0
  48. pyramid_fullauth/views/__pycache__/__init__.cpython-34.pyc +0 -0
  49. pyramid_fullauth/views/__pycache__/social.cpython-34.pyc +0 -0
  50. pyramid_fullauth/views/basic/__init__.py +5 -0
  51. pyramid_fullauth/views/basic/__pycache__/__init__.cpython-34.pyc +0 -0
  52. pyramid_fullauth/views/basic/__pycache__/activate.cpython-34.pyc +0 -0
  53. pyramid_fullauth/views/basic/__pycache__/forbidden.cpython-34.pyc +0 -0
  54. pyramid_fullauth/views/basic/__pycache__/login.cpython-34.pyc +0 -0
  55. pyramid_fullauth/views/basic/__pycache__/logout.cpython-34.pyc +0 -0
  56. pyramid_fullauth/views/basic/__pycache__/register.cpython-34.pyc +0 -0
  57. pyramid_fullauth/views/basic/activate.py +44 -0
  58. pyramid_fullauth/views/basic/forbidden.py +46 -0
  59. pyramid_fullauth/views/basic/login.py +128 -0
  60. pyramid_fullauth/views/basic/logout.py +28 -0
  61. pyramid_fullauth/views/basic/profile/__init__.py +5 -0
  62. pyramid_fullauth/views/basic/profile/__pycache__/__init__.cpython-34.pyc +0 -0
  63. pyramid_fullauth/views/basic/profile/__pycache__/email.cpython-34.pyc +0 -0
  64. pyramid_fullauth/views/basic/profile/__pycache__/password.cpython-34.pyc +0 -0
  65. pyramid_fullauth/views/basic/profile/email.py +108 -0
  66. pyramid_fullauth/views/basic/profile/password.py +129 -0
  67. pyramid_fullauth/views/basic/register.py +111 -0
  68. pyramid_fullauth/views/social.py +221 -0
  69. tests/__init__.py +1 -0
  70. tests/__pycache__/__init__.cpython-34.pyc +0 -0
  71. tests/__pycache__/conftest.cpython-34.pyc +0 -0
  72. tests/__pycache__/tools.cpython-34.pyc +0 -0
  73. tests/conftest.py +201 -0
  74. tests/tools.py +54 -0
  75. tests/unit/__pycache__/test_default_settings.cpython-34.pyc +0 -0
  76. tests/unit/__pycache__/test_groupfinder.cpython-34.pyc +0 -0
  77. tests/unit/__pycache__/test_social_view.cpython-34.pyc +0 -0
  78. tests/unit/__pycache__/test_tools.cpython-34.pyc +0 -0
  79. tests/unit/__pycache__/test_user_active.cpython-34.pyc +0 -0
  80. tests/unit/__pycache__/test_user_admin.cpython-34.pyc +0 -0
  81. tests/unit/__pycache__/test_user_email.cpython-34.pyc +0 -0
  82. tests/unit/__pycache__/test_user_password.cpython-34.pyc +0 -0
  83. tests/unit/__pycache__/test_user_providers.cpython-34.pyc +0 -0
  84. tests/unit/__pycache__/test_user_repr.cpython-34.pyc +0 -0
  85. tests/unit/__pycache__/test_validators.cpython-34.pyc +0 -0
  86. tests/unit/test_default_settings.py +15 -0
  87. tests/unit/test_groupfinder.py +20 -0
  88. tests/unit/test_social_view.py +69 -0
  89. tests/unit/test_tools.py +24 -0
  90. tests/unit/test_user_active.py +31 -0
  91. tests/unit/test_user_admin.py +61 -0
  92. tests/unit/test_user_email.py +37 -0
  93. tests/unit/test_user_password.py +52 -0
  94. tests/unit/test_user_providers.py +24 -0
  95. tests/unit/test_user_repr.py +29 -0
  96. tests/unit/test_validators.py +44 -0
  97. tests/views/__init__.py +1 -0
  98. tests/views/__pycache__/__init__.cpython-34.pyc +0 -0
  99. tests/views/__pycache__/conftest.cpython-34.pyc +0 -0
  100. tests/views/__pycache__/test_activation.cpython-34.pyc +0 -0
  101. tests/views/__pycache__/test_email.cpython-34.pyc +0 -0
  102. tests/views/__pycache__/test_events.cpython-34.pyc +0 -0
  103. tests/views/__pycache__/test_login.cpython-34.pyc +0 -0
  104. tests/views/__pycache__/test_login_social.cpython-34.pyc +0 -0
  105. tests/views/__pycache__/test_logout.cpython-34.pyc +0 -0
  106. tests/views/__pycache__/test_register.cpython-34.pyc +0 -0
  107. tests/views/__pycache__/test_reset.cpython-34.pyc +0 -0
  108. tests/views/conftest.py +20 -0
  109. tests/views/test_activation.py +86 -0
  110. tests/views/test_email.py +175 -0
  111. tests/views/test_events.py +558 -0
  112. tests/views/test_login.py +172 -0
  113. tests/views/test_login_social.py +289 -0
  114. tests/views/test_logout.py +42 -0
  115. tests/views/test_register.py +138 -0
  116. tests/views/test_reset.py +105 -0
EGG-INFO/PKG-INFO ADDED
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 1.1
2
+ Name: pyramid-fullauth
3
+ Version: 0.4.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
+ Installation
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.4.0
77
+ -------
78
+
79
+ - python 3 compatibility (without oauth2 though)
80
+ - cleared use of deprecated :func:`pyramid.security.authenticated_userid` in favour of :attr:`pyramid.request.Request.authenticated_userid`
81
+ - make email fields case insensitive by using hybrid properties and CaseInsensitive comparator for model.
82
+
83
+ 0.3.3
84
+ -------
85
+
86
+ - Fix issue where groupfined was returning empty list instead of None when user did not existed
87
+
88
+ 0.3.2
89
+ -----
90
+
91
+ - catch all HTTPRedirect instead of just HTTPFound.
92
+ - redirect with HTTPSeeOther instead of HTTPFound where applicable.
93
+
94
+
95
+ 0.3.1
96
+ -----
97
+
98
+ - fixes MANIFEST.in to include yaml files - fixes `#33 <https://github.com/fizyk/pyramid_fullauth/issues/33>`_.
99
+
100
+ 0.3.0
101
+ -----
102
+
103
+ Features
104
+ ++++++++
105
+
106
+ - configure root factory if it hasn't been already done
107
+ - configure session factory only if it hasn't been configured before
108
+ - configure authorization policy only if it hasn't been configured before
109
+ - configure authentication policy only if it hasn't been configured before
110
+ - logged in user will be redirected always away from login page
111
+ - views reorganisation - grouping by their function
112
+ - replaced force_logout decorator with logout request method
113
+ - small login view simplification
114
+
115
+ tests
116
+ +++++
117
+
118
+ - rewritten tests to use pytest_pyramid
119
+ - unified session with pyramid_basemodel's
120
+ - parametrize tests against two most recent pyramid versions and sqlalchemy
121
+ - turned on pylama to check code with linters:
122
+ - pep8
123
+ - pep257
124
+ - pyflakes
125
+ - mccabe
126
+ - add pytest-dbfixtures, and run tests against postgresql and mysql as well
127
+ - drop python 2.6 from tests
128
+ - 100% test coverage
129
+
130
+
131
+ 0.2.3
132
+ -----
133
+ - weaker pyramid_yml requirements. Use ``registry['config']`` instead of ``request.config`` which gets added only when explicitly including tzf.pyramid_yml package.
134
+ - remove default_config with permission set for forbidden views. Throwning errors in pyramid 1.5a3
135
+ - remove lazy='load' for relationship between AuthenticationProvider and User models as it was incorrect. Fixes error while using with sqlalchemy 0.9
136
+
137
+ 0.2.2
138
+ -----
139
+ - copy all headers when login user. fixes issue, when headers set in AfterLogin event would not get passed
140
+
141
+ 0.2.1
142
+ -----
143
+ - fixed csrf_check in password:reset:continue action
144
+ - updated translation files
145
+
146
+ 0.2.0
147
+ -----
148
+ - migrated tests to py.test
149
+ - removed nose and lxml from test requirements
150
+ - extracted UserEmailMixin from User model
151
+ - validation exception improvements
152
+ - set licensing to MIT License
153
+ - fixed general error message for register_POST processing
154
+ - activate action no longer gives 404 error after first use. Default is message about token being invalid or used [veronicazgirvaci]
155
+ - extending csrf_check predicate:
156
+ - Can be turned on/off in settings.
157
+ - Failed check rises 401 Unauthorised error
158
+
159
+ Backwards Incompatibilities
160
+ +++++++++++++++++++++++++++
161
+
162
+ - token variable is changed into csrf_token in fullatuh views
163
+ - view no longer returns error messages on failed csrf token. Rises 401 Unauthorised error instead.
164
+
165
+
166
+ 0.1.0
167
+ -----
168
+ - add localize to requirements. Ability to translate registerlogin communicates
169
+ - ability to set custom session factory [with Veronica Zgirvaci help]
170
+ - moved password validation to one place
171
+
172
+ Keywords: python authentication authorisation pyramid
173
+ Platform: UNKNOWN
174
+ Classifier: Development Status :: 5 - Production/Stable
175
+ Classifier: Environment :: Web Environment
176
+ Classifier: Intended Audience :: Developers
177
+ Classifier: License :: OSI Approved :: MIT License
178
+ Classifier: Natural Language :: English
179
+ Classifier: Operating System :: OS Independent
180
+ Classifier: Programming Language :: Python
181
+ Classifier: Programming Language :: Python :: 2.7
182
+ Classifier: Programming Language :: Python :: 3.3
183
+ Classifier: Programming Language :: Python :: 3.4
184
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
EGG-INFO/SOURCES.txt ADDED
@@ -0,0 +1,93 @@
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/config/default.yaml
39
+ pyramid_fullauth/models/__init__.py
40
+ pyramid_fullauth/models/extensions/__init__.py
41
+ pyramid_fullauth/models/mixins/__init__.py
42
+ pyramid_fullauth/models/mixins/email.py
43
+ pyramid_fullauth/models/mixins/password.py
44
+ pyramid_fullauth/resources/helpers/social.mako
45
+ pyramid_fullauth/resources/locale/pyramid_fullauth.pot
46
+ pyramid_fullauth/resources/templates/403.mako
47
+ pyramid_fullauth/resources/templates/_form.login.mako
48
+ pyramid_fullauth/resources/templates/_form.register.mako
49
+ pyramid_fullauth/resources/templates/_social.login.mako
50
+ pyramid_fullauth/resources/templates/activate.mako
51
+ pyramid_fullauth/resources/templates/email_change.mako
52
+ pyramid_fullauth/resources/templates/layout.mako
53
+ pyramid_fullauth/resources/templates/login.mako
54
+ pyramid_fullauth/resources/templates/register.mako
55
+ pyramid_fullauth/resources/templates/reset.mako
56
+ pyramid_fullauth/resources/templates/reset.proceed.mako
57
+ pyramid_fullauth/routing/__init__.py
58
+ pyramid_fullauth/routing/predicates.py
59
+ pyramid_fullauth/views/__init__.py
60
+ pyramid_fullauth/views/social.py
61
+ pyramid_fullauth/views/basic/__init__.py
62
+ pyramid_fullauth/views/basic/activate.py
63
+ pyramid_fullauth/views/basic/forbidden.py
64
+ pyramid_fullauth/views/basic/login.py
65
+ pyramid_fullauth/views/basic/logout.py
66
+ pyramid_fullauth/views/basic/register.py
67
+ pyramid_fullauth/views/basic/profile/__init__.py
68
+ pyramid_fullauth/views/basic/profile/email.py
69
+ pyramid_fullauth/views/basic/profile/password.py
70
+ tests/__init__.py
71
+ tests/conftest.py
72
+ tests/tools.py
73
+ tests/unit/test_default_settings.py
74
+ tests/unit/test_groupfinder.py
75
+ tests/unit/test_social_view.py
76
+ tests/unit/test_tools.py
77
+ tests/unit/test_user_active.py
78
+ tests/unit/test_user_admin.py
79
+ tests/unit/test_user_email.py
80
+ tests/unit/test_user_password.py
81
+ tests/unit/test_user_providers.py
82
+ tests/unit/test_user_repr.py
83
+ tests/unit/test_validators.py
84
+ tests/views/__init__.py
85
+ tests/views/conftest.py
86
+ tests/views/test_activation.py
87
+ tests/views/test_email.py
88
+ tests/views/test_events.py
89
+ tests/views/test_login.py
90
+ tests/views/test_login_social.py
91
+ tests/views/test_logout.py
92
+ tests/views/test_register.py
93
+ 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,13 @@
1
+ pyramid_localize
2
+ pyramid >=1.4
3
+ pyramid_mako
4
+ tzf.pyramid_yml >=1.0
5
+ pyramid_basemodel
6
+
7
+ [docs]
8
+ sphinx
9
+
10
+ [tests]
11
+ mock
12
+ pytest_pyramid
13
+ pytest-cov
EGG-INFO/top_level.txt ADDED
@@ -0,0 +1,2 @@
1
+ tests
2
+ pyramid_fullauth
@@ -0,0 +1,106 @@
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
+ import sys
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.4.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. (And python 2)
86
+ # If social is not available, we will not turn it on!
87
+ if 'social' in fullauth_config and sys.version_info.major == 2:
88
+ # Velruse init (for social auth)
89
+
90
+ # scan social views
91
+ configurator.scan('pyramid_fullauth.views.social')
92
+ providers = fullauth_config.social
93
+ configurator.registry['config']['login_providers'] = providers
94
+ for provider in providers:
95
+ # Ugly hack for using google oauth2, not OpenID + Oauth2 from google
96
+ provider_settings = fullauth_config['social'][provider]
97
+ if provider == 'google': # pragma: no cover
98
+ provider = 'google_oauth2'
99
+
100
+ configurator.include('velruse.providers.' + provider)
101
+ getattr(configurator, 'add_{0}_login'.format(provider))(**provider_settings)
102
+
103
+ # we'll add some request methods:
104
+ configurator.add_request_method(login_perform, name='login_perform')
105
+ configurator.add_request_method(logout, name='logout')
106
+ configurator.add_request_method(user, name='user', reify=True)
@@ -0,0 +1,67 @@
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
+ return None
43
+
44
+
45
+ class BaseACLRootFactoryMixin(object):
46
+
47
+ """
48
+ ACL list factory Mixin.
49
+
50
+ __acl__ is the attribute which stores the list.
51
+
52
+ :return: tuple (Allow|Deny, Group name, Permission)
53
+ :rtype: list
54
+
55
+ .. note::
56
+
57
+ Can be converted later to database stored (sqlalchemy session is accessible through request.db)
58
+ """
59
+
60
+ __acl__ = [(Allow, Everyone, 'view'),
61
+ (Allow, 's:superadmin', ALL_PERMISSIONS),
62
+ (Allow, 's:user', ('password_change', 'email_change'))
63
+ ]
64
+
65
+ def __init__(self, request):
66
+ """Assing request as instance attribute."""
67
+ self.request = request
@@ -0,0 +1,26 @@
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
+
6
+ # pyramid_fullauth's default configuration
7
+ fullauth:
8
+ check_csrf: True # Whether login processes should work with csrf token, or without
9
+ register:
10
+ password:
11
+ require: True # set to false to not read password during register, and generate random one
12
+ length_min: 6 # will be used either to check password's length or generate this length random password
13
+ confirm: True # by default there will be a field for password confirmation on the registration form
14
+ AuthTkt:
15
+ secret: fullauth_psst # default secret used to hash auth_tk cookie
16
+ hashalg: sha512 # default authentication policy hash algorithm
17
+ login:
18
+ cookie_max_age: 2592000 # 30 days
19
+ redirects: # route name, to redirect to. If False, then redirects just to /
20
+ logout: False
21
+ session: # session factory settings
22
+ # factory key is responsible for providing full path to factory class (module.submodule.SessionFactory)
23
+ factory: pyramid.session.UnencryptedCookieSessionFactoryConfig
24
+ # settings are key: value pairs of all factory initialize attributes
25
+ settings:
26
+ secret: THATS_NOT_SECRET_ITS_A_SECRET