datasette-secrets 0.1a2__py3-none-any.whl → 0.1a4__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 datasette-secrets might be problematic. Click here for more details.
- datasette_secrets/__init__.py +14 -8
- {datasette_secrets-0.1a2.dist-info → datasette_secrets-0.1a4.dist-info}/METADATA +1 -1
- datasette_secrets-0.1a4.dist-info/RECORD +10 -0
- datasette_secrets-0.1a2.dist-info/RECORD +0 -10
- {datasette_secrets-0.1a2.dist-info → datasette_secrets-0.1a4.dist-info}/LICENSE +0 -0
- {datasette_secrets-0.1a2.dist-info → datasette_secrets-0.1a4.dist-info}/WHEEL +0 -0
- {datasette_secrets-0.1a2.dist-info → datasette_secrets-0.1a4.dist-info}/entry_points.txt +0 -0
- {datasette_secrets-0.1a2.dist-info → datasette_secrets-0.1a4.dist-info}/top_level.txt +0 -0
datasette_secrets/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@ from cryptography.fernet import Fernet
|
|
|
3
3
|
import dataclasses
|
|
4
4
|
from datasette import hookimpl, Forbidden, Permission, Response
|
|
5
5
|
from datasette.plugins import pm
|
|
6
|
-
from datasette.utils import await_me_maybe
|
|
6
|
+
from datasette.utils import await_me_maybe, sqlite3
|
|
7
7
|
import os
|
|
8
8
|
from typing import Optional
|
|
9
9
|
from . import hookspecs
|
|
@@ -23,16 +23,22 @@ async def get_secret(datasette, secret_name, actor_id=None):
|
|
|
23
23
|
return os.environ[env_var]
|
|
24
24
|
# Now look it up in the database
|
|
25
25
|
config = get_config(datasette)
|
|
26
|
+
if config is None:
|
|
27
|
+
return None
|
|
28
|
+
encryption_key = config["encryption_key"]
|
|
26
29
|
db = get_database(datasette)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
try:
|
|
31
|
+
db_secret = (
|
|
32
|
+
await db.execute(
|
|
33
|
+
"select id, encrypted from datasette_secrets where name = ? order by version desc limit 1",
|
|
34
|
+
(secret_name,),
|
|
35
|
+
)
|
|
36
|
+
).first()
|
|
37
|
+
except sqlite3.OperationalError:
|
|
38
|
+
return None
|
|
33
39
|
if not db_secret:
|
|
34
40
|
return None
|
|
35
|
-
key = Fernet(
|
|
41
|
+
key = Fernet(encryption_key.encode("utf-8"))
|
|
36
42
|
decrypted = key.decrypt(db_secret["encrypted"])
|
|
37
43
|
# Update the last used timestamp and actor_id
|
|
38
44
|
params = (actor_id, db_secret["id"])
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
datasette_secrets/__init__.py,sha256=rGTD35WFjkP8uqoW_L5pGBxUqFITGtkg2wQ3glZLP9U,10587
|
|
2
|
+
datasette_secrets/hookspecs.py,sha256=57v14e2Y4o5eZyAgCLpuzp1KZn7CjwLXeKwfq6Zvux8,205
|
|
3
|
+
datasette_secrets/templates/secrets_index.html,sha256=ZgIy_huFZQfnI6GjO0qauWEkTWhkBCM5WrT73Nqq4BY,1737
|
|
4
|
+
datasette_secrets/templates/secrets_update.html,sha256=qMPLVCuKKslqw_In0aSCVobB3maPw9oaYZDQQImdRIU,1678
|
|
5
|
+
datasette_secrets-0.1a4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
+
datasette_secrets-0.1a4.dist-info/METADATA,sha256=HLoZKAlUAhUprGl70egXMaDzi58YZJLn5hJcbLjGqxY,7040
|
|
7
|
+
datasette_secrets-0.1a4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
8
|
+
datasette_secrets-0.1a4.dist-info/entry_points.txt,sha256=2083uWbPpGntxRulh8_hVaelQO-xdtjedG6rGzwPUH0,40
|
|
9
|
+
datasette_secrets-0.1a4.dist-info/top_level.txt,sha256=ZBJKQk-DdDU9Vnwu4x79X9aaEulwGJMoLx62IZJPDaQ,18
|
|
10
|
+
datasette_secrets-0.1a4.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
datasette_secrets/__init__.py,sha256=QFIh9c--SqVDhv-5WXfmI40-UqyyZrngdzYJ9t_hVE4,10409
|
|
2
|
-
datasette_secrets/hookspecs.py,sha256=57v14e2Y4o5eZyAgCLpuzp1KZn7CjwLXeKwfq6Zvux8,205
|
|
3
|
-
datasette_secrets/templates/secrets_index.html,sha256=ZgIy_huFZQfnI6GjO0qauWEkTWhkBCM5WrT73Nqq4BY,1737
|
|
4
|
-
datasette_secrets/templates/secrets_update.html,sha256=qMPLVCuKKslqw_In0aSCVobB3maPw9oaYZDQQImdRIU,1678
|
|
5
|
-
datasette_secrets-0.1a2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
-
datasette_secrets-0.1a2.dist-info/METADATA,sha256=h-UZ9xZYyvTXjwJBNntAqhPp90OY5Y-INqedW2iqLuU,7040
|
|
7
|
-
datasette_secrets-0.1a2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
8
|
-
datasette_secrets-0.1a2.dist-info/entry_points.txt,sha256=2083uWbPpGntxRulh8_hVaelQO-xdtjedG6rGzwPUH0,40
|
|
9
|
-
datasette_secrets-0.1a2.dist-info/top_level.txt,sha256=ZBJKQk-DdDU9Vnwu4x79X9aaEulwGJMoLx62IZJPDaQ,18
|
|
10
|
-
datasette_secrets-0.1a2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|