cone.tokens 1.1.0__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.
- cone_tokens-1.1.0/.gitignore +19 -0
- cone_tokens-1.1.0/CHANGES.rst +53 -0
- cone_tokens-1.1.0/LICENSE.rst +24 -0
- cone_tokens-1.1.0/PKG-INFO +253 -0
- cone_tokens-1.1.0/README.rst +144 -0
- cone_tokens-1.1.0/pyproject.toml +72 -0
- cone_tokens-1.1.0/src/cone/tokens/__init__.py +41 -0
- cone_tokens-1.1.0/src/cone/tokens/api.py +182 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/__init__.py +27 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/api.py +221 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/settings.py +196 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/static/cone.tokens.css +74 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/static/cone.tokens.js +366 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/static/cone.tokens.min.css +1 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/static/cone.tokens.min.js +1 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/templates/token.pt +118 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/templates/tokens.pt +19 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/templates/tokens_overview.pt +82 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/token.py +267 -0
- cone_tokens-1.1.0/src/cone/tokens/browser/tokens.py +106 -0
- cone_tokens-1.1.0/src/cone/tokens/exceptions.py +58 -0
- cone_tokens-1.1.0/src/cone/tokens/locale/cone.tokens.pot +248 -0
- cone_tokens-1.1.0/src/cone/tokens/locale/de/LC_MESSAGES/cone.tokens.mo +0 -0
- cone_tokens-1.1.0/src/cone/tokens/locale/de/LC_MESSAGES/cone.tokens.po +243 -0
- cone_tokens-1.1.0/src/cone/tokens/locale/en/LC_MESSAGES/cone.tokens.mo +0 -0
- cone_tokens-1.1.0/src/cone/tokens/locale/en/LC_MESSAGES/cone.tokens.po +243 -0
- cone_tokens-1.1.0/src/cone/tokens/model.py +110 -0
- cone_tokens-1.1.0/src/cone/tokens/settings.py +66 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/__init__.py +18 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/test_api.py +340 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/test_json_api.py +449 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/test_model.py +80 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/test_settings.py +111 -0
- cone_tokens-1.1.0/src/cone/tokens/tests/test_token.py +311 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
*egg-info
|
|
2
|
+
*pyc
|
|
3
|
+
/.coverage
|
|
4
|
+
/.mxmake
|
|
5
|
+
/.vscode
|
|
6
|
+
/build/
|
|
7
|
+
/constraints-mxdev.txt
|
|
8
|
+
/coverage
|
|
9
|
+
/dist/
|
|
10
|
+
/htmlcov
|
|
11
|
+
/node_modules/
|
|
12
|
+
/package-lock.json
|
|
13
|
+
/pnpm-lock.yaml
|
|
14
|
+
/requirements-mxdev.txt
|
|
15
|
+
/requirements.txt
|
|
16
|
+
/sources/
|
|
17
|
+
/var/
|
|
18
|
+
/venv/
|
|
19
|
+
__pycache__
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Changes
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
1.1.0 (2026-02-03)
|
|
5
|
+
------------------
|
|
6
|
+
|
|
7
|
+
- Refactor package layout to use ``pyproject.toml`` and implicit namespace packages.
|
|
8
|
+
[rnix]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
0.5 (2024-05-23)
|
|
12
|
+
----------------
|
|
13
|
+
|
|
14
|
+
- Update Makefile.
|
|
15
|
+
[rnix]
|
|
16
|
+
|
|
17
|
+
- ``properties`` and ``metadata`` of ``cone.tokens.model.Tokens`` are instance
|
|
18
|
+
properties now.
|
|
19
|
+
[rnix]
|
|
20
|
+
|
|
21
|
+
- Use ``ts.http_request`` instead of ``ts.ajax.request``.
|
|
22
|
+
[rnix]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
0.4 (2024-02-12)
|
|
26
|
+
----------------
|
|
27
|
+
|
|
28
|
+
- Adopt Settings UI changes from ``cone.app``.
|
|
29
|
+
[rnix]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
0.3 (2023-09-28)
|
|
33
|
+
----------------
|
|
34
|
+
|
|
35
|
+
- Tokens can be bulk deleted.
|
|
36
|
+
[lenadax]
|
|
37
|
+
|
|
38
|
+
- Tokens can be created from scanned value.
|
|
39
|
+
[rnix]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
0.2 (2023-09-27)
|
|
43
|
+
----------------
|
|
44
|
+
|
|
45
|
+
- Actually upload package to pypi.
|
|
46
|
+
[rnix]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
0.1 (2023-09-27)
|
|
50
|
+
----------------
|
|
51
|
+
|
|
52
|
+
- Initial work.
|
|
53
|
+
[rnix, toalba, lenadax]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
License
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2023-2025, Cone Contributors
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cone.tokens
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: cone token api
|
|
5
|
+
Project-URL: Homepage, http://github.com/conestack/cone.tokens
|
|
6
|
+
Author-email: Cone Contributors <dev@conestack.org>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE.rst
|
|
9
|
+
Keywords: cone,node,pyramid,web
|
|
10
|
+
Classifier: Environment :: Web Environment
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: cone-app<2.0.0,>1.0.99
|
|
20
|
+
Requires-Dist: cone-sql>1.0.99
|
|
21
|
+
Requires-Dist: python-dateutil
|
|
22
|
+
Requires-Dist: qrcode[pil]
|
|
23
|
+
Requires-Dist: yafowil-widget-datetime>1.99
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: cone-app[test]; extra == 'test'
|
|
26
|
+
Requires-Dist: cone-ugm[test]; extra == 'test'
|
|
27
|
+
Description-Content-Type: text/x-rst
|
|
28
|
+
|
|
29
|
+
.. image:: https://img.shields.io/pypi/v/cone.tokens.svg
|
|
30
|
+
:target: https://pypi.python.org/pypi/cone.tokens
|
|
31
|
+
:alt: Latest PyPI version
|
|
32
|
+
|
|
33
|
+
.. image:: https://img.shields.io/pypi/dm/cone.tokens.svg
|
|
34
|
+
:target: https://pypi.python.org/pypi/cone.tokens
|
|
35
|
+
:alt: Number of PyPI downloads
|
|
36
|
+
|
|
37
|
+
.. image:: https://github.com/conestack/cone.tokens/actions/workflows/test.yml/badge.svg
|
|
38
|
+
:target: https://github.com/conestack/cone.tokens/actions/workflows/test.yml
|
|
39
|
+
:alt: Test cone.tokens
|
|
40
|
+
|
|
41
|
+
This package provides a unique token generator for ``cone.app``.
|
|
42
|
+
|
|
43
|
+
Features:
|
|
44
|
+
|
|
45
|
+
* QR Code generation
|
|
46
|
+
* JSON API for token management
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Application ini file configuration
|
|
50
|
+
==================================
|
|
51
|
+
|
|
52
|
+
- **cone.tokens.config_file**: Required. Path to tokens json config file.
|
|
53
|
+
|
|
54
|
+
- **cone.tokens.settings_node_path**: Optional. Application node path to token settings node.
|
|
55
|
+
|
|
56
|
+
- **cone.tokens.entryfactory**: Optional. Node class used as entry node factory.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
JSON API
|
|
60
|
+
========
|
|
61
|
+
|
|
62
|
+
``cone.tokens`` provides a JSON API for token management.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
query_token
|
|
66
|
+
-----------
|
|
67
|
+
|
|
68
|
+
Query token by value. It expects a ``GET`` request.
|
|
69
|
+
|
|
70
|
+
**Schema**: URL/tokens/query_token
|
|
71
|
+
|
|
72
|
+
**Params**
|
|
73
|
+
|
|
74
|
+
- ``value``: A string containing the token value to look up.
|
|
75
|
+
|
|
76
|
+
**Response**
|
|
77
|
+
|
|
78
|
+
- ``success``: True or False.
|
|
79
|
+
- ``token``: Token data or null if token not exists.
|
|
80
|
+
- ``message``: On failure the error message is returned.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
add_token
|
|
84
|
+
---------
|
|
85
|
+
|
|
86
|
+
``add_token`` is for generating a new token. It expects a ``POST`` request.
|
|
87
|
+
|
|
88
|
+
**Schema**: URL/tokens/add_token
|
|
89
|
+
|
|
90
|
+
**Params**
|
|
91
|
+
|
|
92
|
+
- ``value``: A string containing the token value. If empty, the token uuid gets used as value.
|
|
93
|
+
- ``valid_from``: A datetime in isoformat. If empty, token has no effective date.
|
|
94
|
+
- ``valid_to``: A datetime in isoformat. If empty, token has no expiration date.
|
|
95
|
+
- ``usage_count``: An integer defining how often the token can be consumed. If -1, token can be consumed unlimited times.
|
|
96
|
+
- ``lock_time``: Time in seconds the token is locked after consumption as integer.
|
|
97
|
+
|
|
98
|
+
**Response**
|
|
99
|
+
|
|
100
|
+
- ``success``: True or False.
|
|
101
|
+
- ``token_uid``: On success the token uid is returned.
|
|
102
|
+
- ``message``: On failure the error message is returned.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
consume_token
|
|
106
|
+
-------------
|
|
107
|
+
|
|
108
|
+
``consume_token`` is for consuming a token. It expects a ``GET`` request.
|
|
109
|
+
|
|
110
|
+
**Schema**: URL/tokens/<UUID>/consume_token
|
|
111
|
+
|
|
112
|
+
**Params**
|
|
113
|
+
|
|
114
|
+
- No parametes expected.
|
|
115
|
+
|
|
116
|
+
**Response**
|
|
117
|
+
|
|
118
|
+
- ``success``: True or False.
|
|
119
|
+
- ``consumed``: On success flag whether token consumption was valid.
|
|
120
|
+
- ``message``: On failure the error message is returned.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
update_token
|
|
124
|
+
------------
|
|
125
|
+
|
|
126
|
+
``edit_token`` is for editing a token. It expects a ``POST`` request.
|
|
127
|
+
|
|
128
|
+
**Schema**: URL/tokens/<UUID>/update_token
|
|
129
|
+
|
|
130
|
+
**Params**
|
|
131
|
+
|
|
132
|
+
- ``value``: A string containing the token value. If empty, the token uuid gets used as value. Unchanged if parameter is omitted.
|
|
133
|
+
- ``valid_from``: A datetime in isoformat. If empty, token has no effective date. Unchanged if parameter is omitted.
|
|
134
|
+
- ``valid_to``: A datetime in isoformat. If empty, token has no expiration date. Unchanged if parameter is omitted.
|
|
135
|
+
- ``usage_count``: An integer defining how often the token can be consumed. If -1, token can be consumed unlimited times. Unchanged if parameter is omitted.
|
|
136
|
+
- ``lock_time``: Time in seconds the token is locked after consumption as integer. Unchanged if parameter is omitted.
|
|
137
|
+
|
|
138
|
+
**Response**
|
|
139
|
+
|
|
140
|
+
- ``success``: True or False.
|
|
141
|
+
- ``message``: On failure the error message is returned.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
delete_token
|
|
145
|
+
------------
|
|
146
|
+
|
|
147
|
+
``delete_token`` is for deleting a token. It expects a ``POST`` request.
|
|
148
|
+
|
|
149
|
+
**Schema**: URL/tokens/<UUID>/delete_token
|
|
150
|
+
|
|
151
|
+
**Params**
|
|
152
|
+
|
|
153
|
+
- No parametes expected.
|
|
154
|
+
|
|
155
|
+
**Response**
|
|
156
|
+
|
|
157
|
+
- ``success``: True or False.
|
|
158
|
+
- ``message``: On failure the error message is returned.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
TODO
|
|
162
|
+
====
|
|
163
|
+
|
|
164
|
+
- Introduce ``consume`` permission for JSON API.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
Contributors
|
|
168
|
+
============
|
|
169
|
+
|
|
170
|
+
- Robert Niederreiter
|
|
171
|
+
- Torben Baumgartner
|
|
172
|
+
- Lena Daxenbichler
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
Changes
|
|
176
|
+
=======
|
|
177
|
+
|
|
178
|
+
1.1.0 (2026-02-03)
|
|
179
|
+
------------------
|
|
180
|
+
|
|
181
|
+
- Refactor package layout to use ``pyproject.toml`` and implicit namespace packages.
|
|
182
|
+
[rnix]
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
0.5 (2024-05-23)
|
|
186
|
+
----------------
|
|
187
|
+
|
|
188
|
+
- Update Makefile.
|
|
189
|
+
[rnix]
|
|
190
|
+
|
|
191
|
+
- ``properties`` and ``metadata`` of ``cone.tokens.model.Tokens`` are instance
|
|
192
|
+
properties now.
|
|
193
|
+
[rnix]
|
|
194
|
+
|
|
195
|
+
- Use ``ts.http_request`` instead of ``ts.ajax.request``.
|
|
196
|
+
[rnix]
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
0.4 (2024-02-12)
|
|
200
|
+
----------------
|
|
201
|
+
|
|
202
|
+
- Adopt Settings UI changes from ``cone.app``.
|
|
203
|
+
[rnix]
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
0.3 (2023-09-28)
|
|
207
|
+
----------------
|
|
208
|
+
|
|
209
|
+
- Tokens can be bulk deleted.
|
|
210
|
+
[lenadax]
|
|
211
|
+
|
|
212
|
+
- Tokens can be created from scanned value.
|
|
213
|
+
[rnix]
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
0.2 (2023-09-27)
|
|
217
|
+
----------------
|
|
218
|
+
|
|
219
|
+
- Actually upload package to pypi.
|
|
220
|
+
[rnix]
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
0.1 (2023-09-27)
|
|
224
|
+
----------------
|
|
225
|
+
|
|
226
|
+
- Initial work.
|
|
227
|
+
[rnix, toalba, lenadax]
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
License
|
|
231
|
+
=======
|
|
232
|
+
|
|
233
|
+
MIT License
|
|
234
|
+
|
|
235
|
+
Copyright (c) 2023-2025, Cone Contributors
|
|
236
|
+
|
|
237
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
238
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
239
|
+
in the Software without restriction, including without limitation the rights
|
|
240
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
241
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
242
|
+
furnished to do so, subject to the following conditions:
|
|
243
|
+
|
|
244
|
+
The above copyright notice and this permission notice shall be included in all
|
|
245
|
+
copies or substantial portions of the Software.
|
|
246
|
+
|
|
247
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
248
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
249
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
250
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
251
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
252
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
253
|
+
SOFTWARE.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
.. image:: https://img.shields.io/pypi/v/cone.tokens.svg
|
|
2
|
+
:target: https://pypi.python.org/pypi/cone.tokens
|
|
3
|
+
:alt: Latest PyPI version
|
|
4
|
+
|
|
5
|
+
.. image:: https://img.shields.io/pypi/dm/cone.tokens.svg
|
|
6
|
+
:target: https://pypi.python.org/pypi/cone.tokens
|
|
7
|
+
:alt: Number of PyPI downloads
|
|
8
|
+
|
|
9
|
+
.. image:: https://github.com/conestack/cone.tokens/actions/workflows/test.yml/badge.svg
|
|
10
|
+
:target: https://github.com/conestack/cone.tokens/actions/workflows/test.yml
|
|
11
|
+
:alt: Test cone.tokens
|
|
12
|
+
|
|
13
|
+
This package provides a unique token generator for ``cone.app``.
|
|
14
|
+
|
|
15
|
+
Features:
|
|
16
|
+
|
|
17
|
+
* QR Code generation
|
|
18
|
+
* JSON API for token management
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Application ini file configuration
|
|
22
|
+
==================================
|
|
23
|
+
|
|
24
|
+
- **cone.tokens.config_file**: Required. Path to tokens json config file.
|
|
25
|
+
|
|
26
|
+
- **cone.tokens.settings_node_path**: Optional. Application node path to token settings node.
|
|
27
|
+
|
|
28
|
+
- **cone.tokens.entryfactory**: Optional. Node class used as entry node factory.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
JSON API
|
|
32
|
+
========
|
|
33
|
+
|
|
34
|
+
``cone.tokens`` provides a JSON API for token management.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
query_token
|
|
38
|
+
-----------
|
|
39
|
+
|
|
40
|
+
Query token by value. It expects a ``GET`` request.
|
|
41
|
+
|
|
42
|
+
**Schema**: URL/tokens/query_token
|
|
43
|
+
|
|
44
|
+
**Params**
|
|
45
|
+
|
|
46
|
+
- ``value``: A string containing the token value to look up.
|
|
47
|
+
|
|
48
|
+
**Response**
|
|
49
|
+
|
|
50
|
+
- ``success``: True or False.
|
|
51
|
+
- ``token``: Token data or null if token not exists.
|
|
52
|
+
- ``message``: On failure the error message is returned.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
add_token
|
|
56
|
+
---------
|
|
57
|
+
|
|
58
|
+
``add_token`` is for generating a new token. It expects a ``POST`` request.
|
|
59
|
+
|
|
60
|
+
**Schema**: URL/tokens/add_token
|
|
61
|
+
|
|
62
|
+
**Params**
|
|
63
|
+
|
|
64
|
+
- ``value``: A string containing the token value. If empty, the token uuid gets used as value.
|
|
65
|
+
- ``valid_from``: A datetime in isoformat. If empty, token has no effective date.
|
|
66
|
+
- ``valid_to``: A datetime in isoformat. If empty, token has no expiration date.
|
|
67
|
+
- ``usage_count``: An integer defining how often the token can be consumed. If -1, token can be consumed unlimited times.
|
|
68
|
+
- ``lock_time``: Time in seconds the token is locked after consumption as integer.
|
|
69
|
+
|
|
70
|
+
**Response**
|
|
71
|
+
|
|
72
|
+
- ``success``: True or False.
|
|
73
|
+
- ``token_uid``: On success the token uid is returned.
|
|
74
|
+
- ``message``: On failure the error message is returned.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
consume_token
|
|
78
|
+
-------------
|
|
79
|
+
|
|
80
|
+
``consume_token`` is for consuming a token. It expects a ``GET`` request.
|
|
81
|
+
|
|
82
|
+
**Schema**: URL/tokens/<UUID>/consume_token
|
|
83
|
+
|
|
84
|
+
**Params**
|
|
85
|
+
|
|
86
|
+
- No parametes expected.
|
|
87
|
+
|
|
88
|
+
**Response**
|
|
89
|
+
|
|
90
|
+
- ``success``: True or False.
|
|
91
|
+
- ``consumed``: On success flag whether token consumption was valid.
|
|
92
|
+
- ``message``: On failure the error message is returned.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
update_token
|
|
96
|
+
------------
|
|
97
|
+
|
|
98
|
+
``edit_token`` is for editing a token. It expects a ``POST`` request.
|
|
99
|
+
|
|
100
|
+
**Schema**: URL/tokens/<UUID>/update_token
|
|
101
|
+
|
|
102
|
+
**Params**
|
|
103
|
+
|
|
104
|
+
- ``value``: A string containing the token value. If empty, the token uuid gets used as value. Unchanged if parameter is omitted.
|
|
105
|
+
- ``valid_from``: A datetime in isoformat. If empty, token has no effective date. Unchanged if parameter is omitted.
|
|
106
|
+
- ``valid_to``: A datetime in isoformat. If empty, token has no expiration date. Unchanged if parameter is omitted.
|
|
107
|
+
- ``usage_count``: An integer defining how often the token can be consumed. If -1, token can be consumed unlimited times. Unchanged if parameter is omitted.
|
|
108
|
+
- ``lock_time``: Time in seconds the token is locked after consumption as integer. Unchanged if parameter is omitted.
|
|
109
|
+
|
|
110
|
+
**Response**
|
|
111
|
+
|
|
112
|
+
- ``success``: True or False.
|
|
113
|
+
- ``message``: On failure the error message is returned.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
delete_token
|
|
117
|
+
------------
|
|
118
|
+
|
|
119
|
+
``delete_token`` is for deleting a token. It expects a ``POST`` request.
|
|
120
|
+
|
|
121
|
+
**Schema**: URL/tokens/<UUID>/delete_token
|
|
122
|
+
|
|
123
|
+
**Params**
|
|
124
|
+
|
|
125
|
+
- No parametes expected.
|
|
126
|
+
|
|
127
|
+
**Response**
|
|
128
|
+
|
|
129
|
+
- ``success``: True or False.
|
|
130
|
+
- ``message``: On failure the error message is returned.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
TODO
|
|
134
|
+
====
|
|
135
|
+
|
|
136
|
+
- Introduce ``consume`` permission for JSON API.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
Contributors
|
|
140
|
+
============
|
|
141
|
+
|
|
142
|
+
- Robert Niederreiter
|
|
143
|
+
- Torben Baumgartner
|
|
144
|
+
- Lena Daxenbichler
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "hatch-fancy-pypi-readme"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cone.tokens"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "cone token api"
|
|
9
|
+
dynamic = ["readme"]
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Cone Contributors", email = "dev@conestack.org"}]
|
|
13
|
+
keywords = ["node", "pyramid", "cone", "web"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Environment :: Web Environment",
|
|
16
|
+
"Programming Language :: Python",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"cone.app>1.0.99,<2.0.0",
|
|
26
|
+
"cone.sql>1.0.99",
|
|
27
|
+
"python-dateutil",
|
|
28
|
+
"qrcode[pil]",
|
|
29
|
+
"yafowil.widget.datetime>1.99",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
test = [
|
|
34
|
+
"cone.app[test]",
|
|
35
|
+
"cone.ugm[test]",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "http://github.com/conestack/cone.tokens"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
|
|
42
|
+
content-type = "text/x-rst"
|
|
43
|
+
fragments = [
|
|
44
|
+
{path = "README.rst"},
|
|
45
|
+
{text = "\n\n"},
|
|
46
|
+
{path = "CHANGES.rst"},
|
|
47
|
+
{text = "\n\n"},
|
|
48
|
+
{path = "LICENSE.rst"},
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
exclude = [
|
|
53
|
+
"/.github/",
|
|
54
|
+
"/js/",
|
|
55
|
+
"/Makefile",
|
|
56
|
+
"/mx.ini",
|
|
57
|
+
"/package.json",
|
|
58
|
+
"/pnpm-lock.yaml",
|
|
59
|
+
"/scss/",
|
|
60
|
+
"/tokens.ini",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.wheel]
|
|
64
|
+
packages = ["src/cone"]
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
consider_namespace_packages = true
|
|
68
|
+
addopts = ["--import-mode=importlib"]
|
|
69
|
+
pythonpath = "src"
|
|
70
|
+
|
|
71
|
+
[tool.zest-releaser]
|
|
72
|
+
create-wheel = true
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from cone.app import import_from_string
|
|
2
|
+
from cone.app import main_hook
|
|
3
|
+
from cone.app import register_config
|
|
4
|
+
from cone.tokens.browser import configure_resources
|
|
5
|
+
from cone.tokens.settings import TokenSettings
|
|
6
|
+
from cone.tokens.settings import tokens_config
|
|
7
|
+
import cone.app
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger('cone.tokens')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@main_hook
|
|
15
|
+
def initialize_tokens(config, global_config, settings):
|
|
16
|
+
# application startup initialization
|
|
17
|
+
|
|
18
|
+
tokens_config.config_file = settings['cone.tokens.config_file']
|
|
19
|
+
tokens_config.settings_node_path = settings.get(
|
|
20
|
+
'cone.tokens.settings_node_path',
|
|
21
|
+
'settings/token_settings'
|
|
22
|
+
).split('/')
|
|
23
|
+
|
|
24
|
+
# register entry node
|
|
25
|
+
tokens_entry_factory = settings.get(
|
|
26
|
+
'cone.tokens.entryfactory',
|
|
27
|
+
'cone.tokens.model.TokenContainer'
|
|
28
|
+
)
|
|
29
|
+
cone.app.register_entry('tokens', import_from_string(tokens_entry_factory))
|
|
30
|
+
|
|
31
|
+
# settings
|
|
32
|
+
register_config('token_settings', TokenSettings)
|
|
33
|
+
|
|
34
|
+
# static resources
|
|
35
|
+
configure_resources(config, settings)
|
|
36
|
+
|
|
37
|
+
# add translation
|
|
38
|
+
config.add_translation_dirs('cone.tokens:locale/')
|
|
39
|
+
|
|
40
|
+
# scan browser package
|
|
41
|
+
config.scan('cone.tokens.browser')
|