kinto 19.6.0__py3-none-any.whl → 20.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of kinto might be problematic. Click here for more details.

Files changed (41) hide show
  1. kinto/__main__.py +0 -17
  2. kinto/config/kinto.tpl +5 -15
  3. kinto/contribute.json +27 -0
  4. kinto/core/__init__.py +14 -0
  5. kinto/core/initialization.py +5 -16
  6. kinto/core/storage/postgresql/pool.py +1 -1
  7. kinto/core/views/errors.py +2 -0
  8. kinto/plugins/accounts/__init__.py +2 -19
  9. kinto/plugins/accounts/authentication.py +8 -54
  10. kinto/plugins/accounts/utils.py +0 -133
  11. kinto/plugins/accounts/{views/__init__.py → views.py} +7 -62
  12. kinto/plugins/admin/VERSION +1 -1
  13. kinto/plugins/admin/build/VERSION +1 -1
  14. kinto/plugins/admin/build/assets/asn1-EdZsLKOL.js +1 -0
  15. kinto/plugins/admin/build/assets/index-Bq62Gei8.js +165 -0
  16. kinto/plugins/admin/build/assets/{index-BdpYyatM.css → index-Cs7JVwIg.css} +1 -1
  17. kinto/plugins/admin/build/assets/javascript-qCveANmP.js +1 -0
  18. kinto/plugins/admin/build/assets/mllike-CXdrOF99.js +1 -0
  19. kinto/plugins/admin/build/assets/sql-D0XecflT.js +1 -0
  20. kinto/plugins/admin/build/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  21. kinto/plugins/admin/build/index.html +2 -2
  22. kinto/views/contribute.py +12 -12
  23. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/METADATA +1 -3
  24. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/RECORD +28 -34
  25. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/WHEEL +1 -1
  26. kinto/plugins/accounts/mails.py +0 -96
  27. kinto/plugins/accounts/views/validation.py +0 -136
  28. kinto/plugins/admin/build/assets/asn1-CGOzndHr.js +0 -1
  29. kinto/plugins/admin/build/assets/index-n-QM_iZE.js +0 -165
  30. kinto/plugins/admin/build/assets/javascript-iSgyE4tI.js +0 -1
  31. kinto/plugins/admin/build/assets/mllike-C_8OmSiT.js +0 -1
  32. kinto/plugins/admin/build/assets/sql-C4g8LzGK.js +0 -1
  33. kinto/plugins/admin/build/assets/ttcn-cfg-BIkV9KBc.js +0 -1
  34. kinto/plugins/quotas/__init__.py +0 -21
  35. kinto/plugins/quotas/listener.py +0 -226
  36. kinto/plugins/quotas/scripts.py +0 -80
  37. kinto/plugins/quotas/utils.py +0 -7
  38. kinto/scripts.py +0 -41
  39. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/LICENSE +0 -0
  40. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/entry_points.txt +0 -0
  41. {kinto-19.6.0.dist-info → kinto-20.1.0.dist-info}/top_level.txt +0 -0
@@ -1,136 +0,0 @@
1
- import re
2
- import uuid
3
-
4
- from pyramid import httpexceptions
5
- from pyramid.events import subscriber
6
-
7
- from kinto.core import Service
8
- from kinto.core.errors import http_error, raise_invalid
9
- from kinto.core.events import ACTIONS, ResourceChanged
10
- from kinto.core.storage import exceptions as storage_exceptions
11
-
12
- from ..mails import Emailer
13
- from ..utils import (
14
- cache_reset_password,
15
- delete_cached_validation_key,
16
- get_cached_validation_key,
17
- hash_password,
18
- )
19
- from . import DEFAULT_EMAIL_REGEXP
20
-
21
-
22
- # Account validation (enable in the settings).
23
- validation = Service(
24
- name="account-validation",
25
- path="/accounts/{user_id}/validate/{activation_key}",
26
- description="Validate an account",
27
- )
28
-
29
-
30
- def check_validation_key(activation_key, username, registry):
31
- """Given a username, compare the activation-key provided with the one from the cache."""
32
- cache_result = get_cached_validation_key(username, registry)
33
-
34
- if cache_result == activation_key:
35
- delete_cached_validation_key(username, registry) # We're done with the activation key.
36
- return True
37
- return False
38
-
39
-
40
- @validation.post()
41
- def post_validation(request):
42
- user_id = request.matchdict["user_id"]
43
- activation_key = request.matchdict["activation_key"]
44
-
45
- parent_id = user_id
46
- try:
47
- user = request.registry.storage.get(
48
- parent_id=parent_id, resource_name="account", object_id=user_id
49
- )
50
- except storage_exceptions.ObjectNotFoundError:
51
- # Don't give information on the existence of a user id: return a generic error message.
52
- error_details = {"message": "Account ID and activation key do not match"}
53
- raise http_error(httpexceptions.HTTPForbidden(), **error_details)
54
-
55
- if not check_validation_key(activation_key, user_id, request.registry):
56
- error_details = {"message": "Account ID and activation key do not match"}
57
- raise http_error(httpexceptions.HTTPForbidden(), **error_details)
58
-
59
- # User is now validated.
60
- new = user.copy()
61
- new["validated"] = True
62
-
63
- result = request.registry.storage.update(
64
- parent_id=parent_id, resource_name="account", object_id=user_id, obj=new
65
- )
66
- request.notify_resource_event(
67
- parent_id=parent_id,
68
- timestamp=result["last_modified"],
69
- data=result,
70
- action=ACTIONS.UPDATE,
71
- old=user,
72
- resource_name="account",
73
- )
74
- return new
75
-
76
-
77
- # Password reset.
78
- reset_password = Service(
79
- name="reset-password",
80
- path="/accounts/{user_id}/reset-password",
81
- description="Send a temporary reset password by mail for an account",
82
- )
83
-
84
-
85
- @reset_password.post()
86
- def post_reset_password(request):
87
- user_id = request.matchdict["user_id"]
88
-
89
- parent_id = user_id
90
- try:
91
- user = request.registry.storage.get(
92
- parent_id=parent_id, resource_name="account", object_id=user_id
93
- )
94
- except storage_exceptions.ObjectNotFoundError:
95
- # Don't give information on the existence of a user id: return a generic message.
96
- return {"message": "A temporary reset password has been sent by mail"}
97
-
98
- settings = request.registry.settings
99
-
100
- user_email = user["id"]
101
- email_regexp = settings.get("account_validation.email_regexp", DEFAULT_EMAIL_REGEXP)
102
- compiled_email_regexp = re.compile(email_regexp)
103
- if not compiled_email_regexp.match(user_email):
104
- error_details = {
105
- "name": "data.id",
106
- "description": f"The user id should match {email_regexp}.",
107
- }
108
- raise_invalid(request, **error_details)
109
-
110
- reset_password = str(uuid.uuid4())
111
- hashed_reset_password = hash_password(reset_password)
112
- cache_reset_password(hashed_reset_password, user_id, request.registry)
113
-
114
- # Send a temporary reset password by mail.
115
- Emailer(request, user).send_temporary_reset_password(reset_password)
116
-
117
- return {"message": "A temporary reset password has been sent by mail"}
118
-
119
-
120
- # Send confirmation email on account activation if account validation is enabled.
121
- @subscriber(ResourceChanged, for_resources=("account",), for_actions=(ACTIONS.UPDATE,))
122
- def on_account_activated(event):
123
- request = event.request
124
- settings = request.registry.settings
125
- if not settings.get("account_validation", False):
126
- return
127
-
128
- for impacted_object in event.impacted_objects:
129
- old_account = impacted_object["old"]
130
- account = impacted_object["new"]
131
- if old_account.get("validated", True) or not account.get("validated", False):
132
- # It's not an account activation, bail.
133
- continue
134
-
135
- # Send a confirmation email.
136
- Emailer(request, account).send_confirmation()
@@ -1 +0,0 @@
1
- function u(i){for(var s={},c=i.split(" "),T=0;T<c.length;++T)s[c[T]]=!0;return s}const o={keywords:u("DEFINITIONS OBJECTS IF DERIVED INFORMATION ACTION REPLY ANY NAMED CHARACTERIZED BEHAVIOUR REGISTERED WITH AS IDENTIFIED CONSTRAINED BY PRESENT BEGIN IMPORTS FROM UNITS SYNTAX MIN-ACCESS MAX-ACCESS MINACCESS MAXACCESS REVISION STATUS DESCRIPTION SEQUENCE SET COMPONENTS OF CHOICE DistinguishedName ENUMERATED SIZE MODULE END INDEX AUGMENTS EXTENSIBILITY IMPLIED EXPORTS"),cmipVerbs:u("ACTIONS ADD GET NOTIFICATIONS REPLACE REMOVE"),compareTypes:u("OPTIONAL DEFAULT MANAGED MODULE-TYPE MODULE_IDENTITY MODULE-COMPLIANCE OBJECT-TYPE OBJECT-IDENTITY OBJECT-COMPLIANCE MODE CONFIRMED CONDITIONAL SUBORDINATE SUPERIOR CLASS TRUE FALSE NULL TEXTUAL-CONVENTION"),status:u("current deprecated mandatory obsolete"),tags:u("APPLICATION AUTOMATIC EXPLICIT IMPLICIT PRIVATE TAGS UNIVERSAL"),storage:u("BOOLEAN INTEGER OBJECT IDENTIFIER BIT OCTET STRING UTCTime InterfaceIndex IANAifType CMIP-Attribute REAL PACKAGE PACKAGES IpAddress PhysAddress NetworkAddress BITS BMPString TimeStamp TimeTicks TruthValue RowStatus DisplayString GeneralString GraphicString IA5String NumericString PrintableString SnmpAdminString TeletexString UTF8String VideotexString VisibleString StringStore ISO646String T61String UniversalString Unsigned32 Integer32 Gauge Gauge32 Counter Counter32 Counter64"),modifier:u("ATTRIBUTE ATTRIBUTES MANDATORY-GROUP MANDATORY-GROUPS GROUP GROUPS ELEMENTS EQUALITY ORDERING SUBSTRINGS DEFINED"),accessTypes:u("not-accessible accessible-for-notify read-only read-create read-write"),multiLineStrings:!0};function L(i){var s=i.keywords||o.keywords,c=i.cmipVerbs||o.cmipVerbs,T=i.compareTypes||o.compareTypes,N=i.status||o.status,d=i.tags||o.tags,f=i.storage||o.storage,m=i.modifier||o.modifier,C=i.accessTypes||o.accessTypes,R=i.multiLineStrings||o.multiLineStrings,y=i.indentStatements!==!1,A=/[\|\^]/,E;function D(e,n){var t=e.next();if(t=='"'||t=="'")return n.tokenize=g(t),n.tokenize(e,n);if(/[\[\]\(\){}:=,;]/.test(t))return E=t,"punctuation";if(t=="-"&&e.eat("-"))return e.skipToEnd(),"comment";if(/\d/.test(t))return e.eatWhile(/[\w\.]/),"number";if(A.test(t))return e.eatWhile(A),"operator";e.eatWhile(/[\w\-]/);var r=e.current();return s.propertyIsEnumerable(r)?"keyword":c.propertyIsEnumerable(r)?"variableName":T.propertyIsEnumerable(r)?"atom":N.propertyIsEnumerable(r)?"comment":d.propertyIsEnumerable(r)?"typeName":f.propertyIsEnumerable(r)||m.propertyIsEnumerable(r)||C.propertyIsEnumerable(r)?"modifier":"variableName"}function g(e){return function(n,t){for(var r=!1,l,O=!1;(l=n.next())!=null;){if(l==e&&!r){var I=n.peek();I&&(I=I.toLowerCase(),(I=="b"||I=="h"||I=="o")&&n.next()),O=!0;break}r=!r&&l=="\\"}return(O||!(r||R))&&(t.tokenize=null),"string"}}function p(e,n,t,r,l){this.indented=e,this.column=n,this.type=t,this.align=r,this.prev=l}function a(e,n,t){var r=e.indented;return e.context&&e.context.type=="statement"&&(r=e.context.indented),e.context=new p(r,n,t,null,e.context)}function S(e){var n=e.context.type;return(n==")"||n=="]"||n=="}")&&(e.indented=e.context.indented),e.context=e.context.prev}return{name:"asn1",startState:function(){return{tokenize:null,context:new p(-2,0,"top",!1),indented:0,startOfLine:!0}},token:function(e,n){var t=n.context;if(e.sol()&&(t.align==null&&(t.align=!1),n.indented=e.indentation(),n.startOfLine=!0),e.eatSpace())return null;E=null;var r=(n.tokenize||D)(e,n);if(r=="comment")return r;if(t.align==null&&(t.align=!0),(E==";"||E==":"||E==",")&&t.type=="statement")S(n);else if(E=="{")a(n,e.column(),"}");else if(E=="[")a(n,e.column(),"]");else if(E=="(")a(n,e.column(),")");else if(E=="}"){for(;t.type=="statement";)t=S(n);for(t.type=="}"&&(t=S(n));t.type=="statement";)t=S(n)}else E==t.type?S(n):y&&((t.type=="}"||t.type=="top")&&E!=";"||t.type=="statement"&&E=="newstatement")&&a(n,e.column(),"statement");return n.startOfLine=!1,r},languageData:{indentOnInput:/^\s*[{}]$/,commentTokens:{line:"--"}}}}export{L as asn1};