pyams-security 2.2.0__tar.gz → 2.6.1__tar.gz

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 (73) hide show
  1. {pyams_security-2.2.0 → pyams_security-2.6.1}/PKG-INFO +65 -1
  2. {pyams_security-2.2.0 → pyams_security-2.6.1}/docs/HISTORY.rst +64 -0
  3. {pyams_security-2.2.0 → pyams_security-2.6.1}/setup.py +1 -1
  4. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/credential.py +1 -1
  5. pyams_security-2.6.1/src/pyams_security/doctests/credentials.rst +55 -0
  6. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/manager.rst +3 -3
  7. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/policy.rst +23 -0
  8. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/roles.rst +8 -3
  9. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/users.rst +67 -1
  10. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/include.py +31 -4
  11. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/base.py +6 -0
  12. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/names.py +42 -0
  13. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/plugin.py +5 -0
  14. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/profile.py +2 -0
  15. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/site.py +13 -1
  16. pyams_security-2.6.1/src/pyams_security/locales/fr/LC_MESSAGES/pyams_security.mo +0 -0
  17. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/locales/fr/LC_MESSAGES/pyams_security.po +300 -260
  18. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/locales/pyams_security.pot +267 -226
  19. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/admin.py +28 -4
  20. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/templates/register-body.pt +1 -2
  21. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/userfolder.py +32 -9
  22. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/policy.py +8 -6
  23. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/principal.py +17 -1
  24. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/role.py +15 -9
  25. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/security.py +6 -5
  26. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/site.py +2 -0
  27. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/tests/__init__.py +1 -4
  28. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/PKG-INFO +65 -1
  29. pyams_security-2.2.0/src/pyams_security/doctests/credentials.rst +0 -21
  30. pyams_security-2.2.0/src/pyams_security/locales/fr/LC_MESSAGES/pyams_security.mo +0 -0
  31. {pyams_security-2.2.0 → pyams_security-2.6.1}/LICENSE +0 -0
  32. {pyams_security-2.2.0 → pyams_security-2.6.1}/MANIFEST.in +0 -0
  33. {pyams_security-2.2.0 → pyams_security-2.6.1}/docs/README.rst +0 -0
  34. {pyams_security-2.2.0 → pyams_security-2.6.1}/setup.cfg +0 -0
  35. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/__init__.py +0 -0
  36. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/api/__init__.py +0 -0
  37. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/README.rst +0 -0
  38. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/notifications.rst +0 -0
  39. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/passwords.rst +0 -0
  40. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/plugins.rst +0 -0
  41. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/principals.rst +0 -0
  42. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/profiles.rst +0 -0
  43. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/rest.rst +0 -0
  44. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/doctests/security.rst +0 -0
  45. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/generations/__init__.py +0 -0
  46. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/generations/evolve1.py +0 -0
  47. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/index.py +0 -0
  48. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/__init__.py +0 -0
  49. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/notification.py +0 -0
  50. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/interfaces/rest.py +0 -0
  51. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/notification.py +0 -0
  52. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/password.py +0 -0
  53. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/permission.py +0 -0
  54. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/__init__.py +0 -0
  55. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/group.py +0 -0
  56. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/templates/password-reset.pt +0 -0
  57. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/templates/register-info.pt +0 -0
  58. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/plugin/templates/register-message.pt +0 -0
  59. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/profile.py +0 -0
  60. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/property.py +0 -0
  61. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/rest.py +0 -0
  62. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/schema.py +0 -0
  63. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/tests/test_utilsdocs.py +0 -0
  64. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/tests/test_utilsdocstrings.py +0 -0
  65. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/utility.py +0 -0
  66. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security/vocabulary.py +0 -0
  67. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/SOURCES.txt +0 -0
  68. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/dependency_links.txt +0 -0
  69. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/entry_points.txt +0 -0
  70. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/namespace_packages.txt +0 -0
  71. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/not-zip-safe +0 -0
  72. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/requires.txt +0 -0
  73. {pyams_security-2.2.0 → pyams_security-2.6.1}/src/pyams_security.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyams_security
3
- Version: 2.2.0
3
+ Version: 2.6.1
4
4
  Summary: PyAMS security management package
5
5
  Home-page: https://pyams.readthedocs.io
6
6
  Author: Thierry Florac
@@ -54,6 +54,70 @@ store roles assigned to principals.
54
54
  Changelog
55
55
  =========
56
56
 
57
+ 2.6.1
58
+ -----
59
+ - updated configuration settings keys
60
+
61
+ 2.6.0
62
+ -----
63
+ - added permissions and associated roles to handle internal and public API access
64
+ - added support for Python 3.12
65
+
66
+ 2.5.0
67
+ -----
68
+ - added principal annotations utility sublocations adapter
69
+ - replaced deprecated PersistentDict class with PersistentMapping
70
+
71
+ 2.4.5
72
+ -----
73
+ - removed duplicated information in user profile registration message
74
+
75
+ 2.4.4
76
+ -----
77
+ - updated user profile confirmation delay management
78
+
79
+ 2.4.3
80
+ -----
81
+ - rollback on setuptools package upgrade
82
+
83
+ 2.4.2
84
+ -----
85
+ - activate user profile on password reset
86
+ - replaced "datetime.utcnow()" with "datetime.now(timezone.utc)"
87
+
88
+ 2.4.1
89
+ -----
90
+ - added SonarCloud support
91
+
92
+ 2.4.0
93
+ -----
94
+ - added internal service credentials plug-in
95
+
96
+ 2.3.4
97
+ -----
98
+ - disable authentication of pre-authenticated credentials as defined by remote user
99
+ authentication package
100
+
101
+ 2.3.3
102
+ -----
103
+ - added exception handler in identity getter
104
+
105
+ 2.3.2
106
+ -----
107
+ - updated internal service identity checker
108
+
109
+ 2.3.1
110
+ -----
111
+ - updated translations
112
+
113
+ 2.3.0
114
+ -----
115
+ - allow case-insensitive local user login
116
+
117
+ 2.2.1
118
+ -----
119
+ - added support for custom attributes in roles
120
+
57
121
  2.2.0
58
122
  -----
59
123
  - added marker interface to handle unknown or missing principals
@@ -1,6 +1,70 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 2.6.1
5
+ -----
6
+ - updated configuration settings keys
7
+
8
+ 2.6.0
9
+ -----
10
+ - added permissions and associated roles to handle internal and public API access
11
+ - added support for Python 3.12
12
+
13
+ 2.5.0
14
+ -----
15
+ - added principal annotations utility sublocations adapter
16
+ - replaced deprecated PersistentDict class with PersistentMapping
17
+
18
+ 2.4.5
19
+ -----
20
+ - removed duplicated information in user profile registration message
21
+
22
+ 2.4.4
23
+ -----
24
+ - updated user profile confirmation delay management
25
+
26
+ 2.4.3
27
+ -----
28
+ - rollback on setuptools package upgrade
29
+
30
+ 2.4.2
31
+ -----
32
+ - activate user profile on password reset
33
+ - replaced "datetime.utcnow()" with "datetime.now(timezone.utc)"
34
+
35
+ 2.4.1
36
+ -----
37
+ - added SonarCloud support
38
+
39
+ 2.4.0
40
+ -----
41
+ - added internal service credentials plug-in
42
+
43
+ 2.3.4
44
+ -----
45
+ - disable authentication of pre-authenticated credentials as defined by remote user
46
+ authentication package
47
+
48
+ 2.3.3
49
+ -----
50
+ - added exception handler in identity getter
51
+
52
+ 2.3.2
53
+ -----
54
+ - updated internal service identity checker
55
+
56
+ 2.3.1
57
+ -----
58
+ - updated translations
59
+
60
+ 2.3.0
61
+ -----
62
+ - allow case-insensitive local user login
63
+
64
+ 2.2.1
65
+ -----
66
+ - added support for custom attributes in roles
67
+
4
68
  2.2.0
5
69
  -----
6
70
  - added marker interface to handle unknown or missing principals
@@ -23,7 +23,7 @@ DOCS = os.path.join(os.path.dirname(__file__),
23
23
  README = os.path.join(DOCS, 'README.rst')
24
24
  HISTORY = os.path.join(DOCS, 'HISTORY.rst')
25
25
 
26
- version = '2.2.0'
26
+ version = '2.6.1'
27
27
  long_description = open(README).read() + '\n\n' + open(HISTORY).read()
28
28
 
29
29
  tests_require = [
@@ -35,4 +35,4 @@ class Credentials:
35
35
  def __init__(self, prefix, id, **attributes): # pylint: disable=invalid-name,redefined-builtin
36
36
  self.prefix = prefix
37
37
  self.id = id # pylint: disable=invalid-name
38
- self.attributes.update(**attributes)
38
+ self.attributes = attributes
@@ -0,0 +1,55 @@
1
+
2
+ ============================
3
+ Extracting users credentials
4
+ ============================
5
+
6
+ As explained before, PyAMS authentication policy relies on several kinds of plugins, which
7
+ are used to extract credentials from a given request, and then to authenticate these credentials
8
+ (if any) against an internal or external users database (being a local users folder, an LDAP
9
+ directory or an external OAuth authority provider).
10
+
11
+ Credentials extraction is done by plugins which are external to PyAMS_security package; some
12
+ example are PyAMS_auth_http (to extract credentials from an Authorization header),
13
+ PyAMS_auth_jwt (to generate and validate JWT tokens), PyAMS_auth_oauth (to handle authentication
14
+ based on an OAuth provider) or PyAMS_auth_form (to authenticate using a classic login form).
15
+
16
+ All credentials plugins are tested sequentially, until one of them returns accepted credentials;
17
+ if none of them is returning credentials, the request is left as "unauthenticated"; otherwise,
18
+ these credentials are checked against the users database to authenticate the request.
19
+
20
+ Some authentication mechanisms can store credentials information into a cookie or an
21
+ authorization token, so that credentials are not always re-authenticated on every request.
22
+
23
+
24
+ Internal service credentials
25
+ ----------------------------
26
+
27
+ Some utilities, like tasks scheduler, can create custom requests using a specific "internal
28
+ service" principal. These requests are authenticated using a custom credentials getter:
29
+
30
+ >>> from pyams_utils.request import check_request
31
+ >>> from pyams_security.interfaces.names import ADMIN_USER_ID, INTERNAL_USER_ID
32
+ >>> from pyams_security.plugin.admin import InternalUserCredentialsPlugin
33
+
34
+ >>> plugin = InternalUserCredentialsPlugin()
35
+
36
+ >>> request = check_request(principal_id=INTERNAL_USER_ID)
37
+ >>> credentials = plugin.extract_credentials(request)
38
+ >>> credentials is None
39
+ False
40
+ >>> credentials.prefix
41
+ 'internal'
42
+ >>> credentials.id
43
+ 'system:internal'
44
+ >>> credentials.attributes.get('pre_authenticated')
45
+ True
46
+
47
+ >>> request = check_request()
48
+ >>> credentials = plugin.extract_credentials(request)
49
+ >>> credentials is None
50
+ True
51
+
52
+ >>> request = check_request(principal_id=ADMIN_USER_ID)
53
+ >>> credentials = plugin.extract_credentials(request)
54
+ >>> credentials is None
55
+ True
@@ -85,9 +85,9 @@ use them:
85
85
 
86
86
  >>> request = new_test_request('user1', 'passwd', registry=config.registry)
87
87
  >>> list(sm.credentials_plugins_names)
88
- []
88
+ ['internal-auth']
89
89
  >>> list(sm.credentials_plugins)
90
- []
90
+ [<pyams_security.plugin.admin.InternalUserCredentialsPlugin object at 0x...>]
91
91
  >>> list(sm.authentication_plugins)
92
92
  [<...AdminAuthenticationPlugin object at 0x...>, <...AdminAuthenticationPlugin object at 0x...>, <...UsersFolder object at 0x...>]
93
93
  >>> list(sm.directory_plugins)
@@ -174,7 +174,7 @@ Deleting plugins
174
174
  >>> del sm['__system__']
175
175
  >>> del sm['users']
176
176
  >>> list(sm.credentials_plugins)
177
- []
177
+ [<pyams_security.plugin.admin.InternalUserCredentialsPlugin object at 0x...>]
178
178
  >>> list(sm.authentication_plugins)
179
179
  [<...AdminAuthenticationPlugin object at 0x...>]
180
180
  >>> list(sm.directory_plugins)
@@ -142,6 +142,29 @@ Security policy is also used when you have to remember a user's session, using c
142
142
  >>> headers[0]
143
143
  ('Set-Cookie', 'auth_ticket=; Domain=example.com; Max-Age=0; Path=/; expires=Wed, 31-Dec-97 23:59:59 GMT; HttpOnly; SameSite=Lax')
144
144
 
145
+
146
+ Internal service identity
147
+ -------------------------
148
+
149
+ Some tasks, like scheduler ones, can be run using a specific internal user ID:
150
+
151
+ >>> from pyramid.threadlocal import RequestContext, manager
152
+ >>> from pyams_security.interfaces.names import INTERNAL_USER_ID
153
+ >>> from pyams_utils.request import check_request
154
+
155
+ >>> manager.clear()
156
+ >>> request = check_request(registry=config.registry, principal_id=INTERNAL_USER_ID)
157
+ >>> manager.push({'registry': config.registry, 'request': request})
158
+
159
+ >>> identity = request.identity
160
+ >>> identity is None
161
+ False
162
+ >>> identity['userid'] == INTERNAL_USER_ID
163
+ True
164
+ >>> sorted(identity['principals'])
165
+ ['system.Authenticated', 'system.Everyone', 'system:internal']
166
+
167
+
145
168
  Authentication plugins are available as external packages, which can be included individually
146
169
  into Pyramid's application configuration; some examples are "pyams_auth_http", "pyams_auth_jwt",
147
170
  "pyams_auth_oauth" or "pyams_ldap".
@@ -92,18 +92,23 @@ or revoke this role to principals.
92
92
  ... permissions={view_permission.id, manage_permission.id})
93
93
  >>> register_role(config, manager_role)
94
94
 
95
+ You can also add custom properties to a role, which are stored in it's "custom_data" attribute:
96
+
95
97
  >>> contributor_role = Role(id='pyams.ocntributor',
96
98
  ... title='Contributor',
97
99
  ... permissions={view_permission.id},
98
- ... managers={manager_role.id})
100
+ ... managers={manager_role.id},
101
+ ... custom_value='Value')
99
102
  >>> register_role(config, contributor_role)
100
103
 
101
104
  >>> from pyams_security.interfaces.base import IRole
102
105
  >>> queryUtility(IRole, name=manager_role.id)
103
106
  <....Role object at 0x...>
107
+ >>> queryUtility(IRole, name=contributor_role.id).custom_data
108
+ {'custom_value': 'Value'}
104
109
 
105
- If you try to register the same role multiple times, this will comple his permissions and
106
- managers sets, but will not update it's other properties:
110
+ If you try to register the same role multiple times, this will complete his permissions,
111
+ managers sets and custom data, but will not update it's other properties:
107
112
 
108
113
  >>> another_role = Role(id='pyams.manager',
109
114
  ... title='Another manager role',
@@ -249,7 +249,7 @@ user:
249
249
 
250
250
  Notification settings also allows to o set a custom notification message; please note that you can
251
251
  also change password manager (plain text storage can be required, for example, if you have to get
252
- access to a user passord, but it's a huge security issue if your database is compromized!!!):
252
+ access to a user password, but it's a huge security issue if your database is compromised!!!):
253
253
 
254
254
  >>> settings.registration_template = {'en': '<p>This is a custom registration message.</p>'}
255
255
  >>> user3 = LocalUser()
@@ -350,6 +350,37 @@ A vocabulary is available to select between users folders:
350
350
  {'users': <zope.schema.vocabulary.SimpleTerm object at 0x...>}
351
351
 
352
352
 
353
+ Case insensitive login
354
+ ----------------------
355
+
356
+ By default, local users folder login is case sensitive:
357
+
358
+ >>> folder.case_insensitive_login
359
+ False
360
+
361
+ >>> 'user1' in folder
362
+ True
363
+ >>> 'User1' in folder
364
+ False
365
+ >>> folder.get('User1') is None
366
+ True
367
+
368
+ You can switch case sensitive property to False:
369
+
370
+ >>> folder.case_insensitive_login = True
371
+
372
+ >>> 'user1' in folder
373
+ True
374
+ >>> 'User1' in folder
375
+ True
376
+ >>> folder.get('User1') is user1
377
+ True
378
+
379
+ >>> folder['User4'] = LocalUser()
380
+ >>> sorted(folder.keys())
381
+ ['user1', 'user2@example.com', 'user3@example.com', 'user4']
382
+
383
+
353
384
  Principals groups
354
385
  -----------------
355
386
 
@@ -547,6 +578,41 @@ principals will be stored:
547
578
  >>> IUserRegistrationInfo.validateInvariants(info)
548
579
 
549
580
 
581
+ Password reset
582
+ --------------
583
+
584
+ A local user can ask for a password reset; a password reset request will generate a new email with a reset link:
585
+
586
+ >>> user3.reset_password(user3.password_hash, 'newPassword')
587
+ Traceback (most recent call last):
588
+ ...
589
+ zope.interface.exceptions.Invalid: Invalid reset request!
590
+
591
+ >>> user3.generate_reset_hash(notify=False)
592
+ >>> user3.password_hash is None
593
+ False
594
+ >>> user3.password_hash_validity is None
595
+ False
596
+
597
+ >>> user3.activated
598
+ False
599
+
600
+ >>> user3.reset_password('bad_hash', 'newPassword')
601
+ Traceback (most recent call last):
602
+ ...
603
+ zope.interface.exceptions.Invalid: Can't reset password with given params!
604
+
605
+ >>> user3.reset_password(user3.password_hash, 'newPassword')
606
+ >>> user3.password_hash is None
607
+ True
608
+ >>> user3.password_hash_validity is None
609
+ True
610
+ >>> user3.activated
611
+ True
612
+ >>> user3.activation_date is None
613
+ False
614
+
615
+
550
616
  Tests cleanup:
551
617
 
552
618
  >>> tearDown()
@@ -24,8 +24,9 @@ from zope.password.password import MD5PasswordManager, PlainTextPasswordManager,
24
24
  from pyams_security.interfaces import IDefaultProtectionPolicy
25
25
  from pyams_security.interfaces.base import MANAGE_PERMISSION, MANAGE_ROLES_PERMISSION, \
26
26
  MANAGE_SECURITY_PERMISSION, MANAGE_SYSTEM_PERMISSION, PUBLIC_PERMISSION, \
27
- ROLE_ID, USE_INTERNAL_API_PERMISSION, VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
28
- from pyams_security.interfaces.names import ADMIN_USER_ID, SYSTEM_ADMIN_ROLE, SYSTEM_VIEWER_ROLE
27
+ ROLE_ID, USE_INTERNAL_API_PERMISSION, USE_PUBLIC_API_PERMISSION, VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
28
+ from pyams_security.interfaces.names import ADMIN_USER_ID, INTERNAL_API_ROLE, PUBLIC_API_ROLE, SYSTEM_ADMIN_ROLE, \
29
+ SYSTEM_VIEWER_ROLE
29
30
  from pyams_security.permission import register_permission
30
31
  from pyams_security.plugin import PluginSelector
31
32
  from pyams_security.role import RoleSelector, register_role, upgrade_role
@@ -99,6 +100,10 @@ def include_package(config):
99
100
  'id': USE_INTERNAL_API_PERMISSION,
100
101
  'title': _("Use internal API")
101
102
  })
103
+ config.register_permission({
104
+ 'id': USE_PUBLIC_API_PERMISSION,
105
+ 'title': _("Use public API")
106
+ })
102
107
 
103
108
  # register standard roles
104
109
  config.register_role({
@@ -107,7 +112,7 @@ def include_package(config):
107
112
  'permissions': {
108
113
  PUBLIC_PERMISSION, VIEW_PERMISSION, MANAGE_PERMISSION,
109
114
  MANAGE_SYSTEM_PERMISSION, VIEW_SYSTEM_PERMISSION, MANAGE_SECURITY_PERMISSION,
110
- MANAGE_ROLES_PERMISSION
115
+ MANAGE_ROLES_PERMISSION, USE_INTERNAL_API_PERMISSION, USE_PUBLIC_API_PERMISSION
111
116
  },
112
117
  'managers': {
113
118
  ADMIN_USER_ID,
@@ -125,9 +130,31 @@ def include_package(config):
125
130
  ROLE_ID.format(SYSTEM_ADMIN_ROLE)
126
131
  }
127
132
  })
133
+ config.register_role({
134
+ 'id': INTERNAL_API_ROLE,
135
+ 'title': _("Private API user (role)"),
136
+ 'permissions': {
137
+ PUBLIC_PERMISSION, VIEW_PERMISSION, USE_INTERNAL_API_PERMISSION
138
+ },
139
+ 'managers': {
140
+ ADMIN_USER_ID,
141
+ ROLE_ID.format(SYSTEM_ADMIN_ROLE)
142
+ }
143
+ })
144
+ config.register_role({
145
+ 'id': PUBLIC_API_ROLE,
146
+ 'title': _("Public API user (role)"),
147
+ 'permissions': {
148
+ PUBLIC_PERMISSION, VIEW_PERMISSION, USE_PUBLIC_API_PERMISSION
149
+ },
150
+ 'managers': {
151
+ ADMIN_USER_ID,
152
+ ROLE_ID.format(SYSTEM_ADMIN_ROLE)
153
+ }
154
+ })
128
155
 
129
156
  # custom classes implementations
130
- if not asbool(config.registry.settings.get('pyams.security.disable_default_policy', False)):
157
+ if not asbool(config.registry.settings.get('pyams_security.disable_default_policy', False)):
131
158
  classImplements(BaseSiteRoot, IDefaultProtectionPolicy)
132
159
  BaseSiteRoot.__acl__ = ProtectedObjectMixin.__acl__
133
160
 
@@ -50,6 +50,9 @@ MANAGE_ROLES_PERMISSION = 'pyams.ManageRoles'
50
50
  USE_INTERNAL_API_PERMISSION = 'pyams.UseInternalAPI'
51
51
  '''Permission used to access read-only APIs'''
52
52
 
53
+ USE_PUBLIC_API_PERMISSION = 'pyams.UsePublicAPI'
54
+ '''Permission used to access public APIs'''
55
+
53
56
 
54
57
  class IPermission(Interface):
55
58
  """Permission interface"""
@@ -97,6 +100,9 @@ class IRole(Interface):
97
100
  value_type=TextLine(),
98
101
  required=False)
99
102
 
103
+ custom_data = Dict(title="Custom role data",
104
+ required=False)
105
+
100
106
 
101
107
  class IPrincipalInfo(Interface):
102
108
  """Principal info class
@@ -21,30 +21,72 @@ from pyams_security import _
21
21
 
22
22
 
23
23
  SYSTEM_PREFIX = 'system'
24
+ '''System principals prefix'''
25
+
24
26
  ADMIN_USER_NAME = '__system__'
27
+ '''System manager principal name'''
28
+
25
29
  ADMIN_USER_LOGIN = 'admin'
30
+ '''System manager principal login'''
31
+
26
32
  ADMIN_USER_ID = '{0}:{1}'.format(SYSTEM_PREFIX, ADMIN_USER_LOGIN)
33
+ '''System manager principal ID'''
34
+
27
35
 
28
36
  INTERNAL_USER_NAME = '__internal__'
37
+ '''Internal principal name'''
38
+
29
39
  INTERNAL_USER_LOGIN = 'internal'
40
+ '''Internal principal login'''
41
+
30
42
  INTERNAL_USER_ID = '{0}:{1}'.format(SYSTEM_PREFIX, INTERNAL_USER_LOGIN)
43
+ '''Internal principal ID'''
44
+
31
45
 
32
46
  SYSTEM_ADMIN_ROLE = 'system.Manager'
47
+ '''System manager role ID'''
48
+
33
49
  SYSTEM_VIEWER_ROLE = 'system.Viewer'
50
+ '''System viewer role ID'''
51
+
52
+
53
+ INTERNAL_API_ROLE = 'system.InternalAPI'
54
+ '''Internal API user role ID'''
55
+
56
+ PUBLIC_API_ROLE = 'system.PublicAPI'
57
+ '''Public API user role ID'''
58
+
34
59
 
35
60
  USER_LOGIN_TITLE = _("User login")
61
+ '''User login form title'''
62
+
36
63
 
37
64
  UNKNOWN_PRINCIPAL_ID = '__UNKNOWN__'
65
+ '''Unknown principal ID'''
66
+
38
67
  UNCHANGED_PASSWORD = '*****'
68
+ '''Unchanged password static value'''
69
+
39
70
 
40
71
  PRINCIPAL_ID_FORMATTER = '{prefix}:{login}'
72
+ '''Principal ID formatter string'''
73
+
41
74
  GROUP_ID_FORMATTER = '{prefix}:{group_id}'
75
+ '''Group ID formatter string'''
42
76
 
43
77
 
44
78
  PERMISSIONS_VOCABULARY_NAME = 'pyams_security.permissions'
79
+ '''Permissions vocabulary name'''
80
+
45
81
  ROLES_VOCABULARY_NAME = 'pyams_security.roles'
82
+ '''Roles vocabulary name'''
83
+
46
84
  PASSWORD_MANAGERS_VOCABULARY_NAME = 'pyams_security.password.managers'
85
+ '''Password managers vocabulary name'''
47
86
 
48
87
 
49
88
  USERS_FOLDERS_VOCABULARY_NAME = 'pyams_security.plugin.users-folders'
89
+ '''Users folders vocabulary name'''
90
+
50
91
  LOCAL_GROUPS_VOCABULARY_NAME = 'pyams_security.plugin.local-groups'
92
+ '''Local groups vocabulary name'''
@@ -200,6 +200,11 @@ class IUsersFolderPlugin(IAuthenticationPlugin, IDirectorySearchPlugin):
200
200
 
201
201
  contains('pyams_security.interfaces.ILocalUser')
202
202
 
203
+ case_insensitive_login = Bool(title=_("Use case insensitive login"),
204
+ description=_("If enabled, users login will not be case sensitive"),
205
+ required=True,
206
+ default=False)
207
+
203
208
  def check_login(self, login):
204
209
  """Check for existence of given login"""
205
210
 
@@ -43,7 +43,9 @@ class IUserRegistrationViews(Interface):
43
43
  register_view = Attribute("Register view URL")
44
44
  register_ok_view = Attribute("Register OK view URL")
45
45
  register_confirm_view = Attribute("Registration confirmation view URL")
46
+ register_confirm_delay = Attribute("Registration confirmation delay")
46
47
  register_final_view = Attribute("Registration final view")
48
+
47
49
  password_reset_view = Attribute("Password reset view")
48
50
  password_reset_final_view = Attribute("Password reset final view")
49
51
  password_change_view = Attribute("Password change view")
@@ -16,7 +16,7 @@ This module defines site root roles interface.
16
16
  """
17
17
 
18
18
  from pyams_security.interfaces import IContentRoles
19
- from pyams_security.interfaces.names import SYSTEM_ADMIN_ROLE, SYSTEM_VIEWER_ROLE
19
+ from pyams_security.interfaces.names import INTERNAL_API_ROLE, PUBLIC_API_ROLE, SYSTEM_ADMIN_ROLE, SYSTEM_VIEWER_ROLE
20
20
  from pyams_security.schema import PrincipalsSetField
21
21
 
22
22
 
@@ -28,6 +28,18 @@ from pyams_security import _
28
28
  class ISiteRootRoles(IContentRoles):
29
29
  """Site root roles"""
30
30
 
31
+ internal_api = PrincipalsSetField(title=_("Internal API"),
32
+ description=_("These principals are allowed to access "
33
+ "internal API"),
34
+ role_id=INTERNAL_API_ROLE,
35
+ required=False)
36
+
37
+ public_api = PrincipalsSetField(title=_("Public API"),
38
+ description=_("These principals are allowed to access "
39
+ "public API"),
40
+ role_id=PUBLIC_API_ROLE,
41
+ required=False)
42
+
31
43
  managers = PrincipalsSetField(title=_("Site managers"),
32
44
  description=_("These principals are allowed to manage the "
33
45
  "whole application environment"),