Skip to content

Commit 8678f13

Browse files
authored
Merge pull request #4191 from alephdata/release/4.1.1
Release/4.1.1
2 parents b623206 + c6c47b7 commit 8678f13

File tree

17 files changed

+60
-30
lines changed

17 files changed

+60
-30
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.1.0-rc4
2+
current_version = 4.1.1
33
tag_name = {new_version}
44
commit = True
55
tag = True

aleph/logic/api_keys.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def hash_plaintext_api_keys():
129129
for index, partition in enumerate(results.partitions()):
130130
for role in partition:
131131
role.api_key_digest = hash_api_key(role.api_key)
132-
role.api_key = None
133132
db.session.add(role)
134133
log.info(f"Hashing API key: {role}")
135134
log.info(f"Comitting partition {index}")

aleph/model/role.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from datetime import datetime, timezone
33
from normality import stringify
4-
from sqlalchemy import or_, not_, func
4+
from sqlalchemy import and_, or_, not_, func
55
from itsdangerous import URLSafeTimedSerializer
66
from werkzeug.security import generate_password_hash, check_password_hash
77

@@ -197,13 +197,18 @@ def by_email(cls, email):
197197

198198
@classmethod
199199
def by_api_key(cls, api_key):
200-
if api_key is None:
200+
if api_key is None or not len(api_key.strip()):
201201
return None
202202

203203
q = cls.all()
204204

205205
digest = hash_api_key(api_key)
206-
q = q.filter(cls.api_key_digest == digest)
206+
q = q.filter(
207+
and_(
208+
cls.api_key_digest != None, # noqa: E711
209+
cls.api_key_digest == digest,
210+
)
211+
)
207212

208213
utcnow = datetime.now(timezone.utc)
209214
# TODO: Exclude API keys without expiration date after deadline

aleph/tests/test_api_keys.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ def test_hash_plaintext_api_keys(self):
211211
hash_plaintext_api_keys()
212212

213213
db.session.refresh(user_1)
214-
assert user_1.api_key is None
214+
215+
# Do not delete the plaintext API key to allow for version rollbacks.
216+
# `api_key` column will be removed in the next version at which point all
217+
# plaintext keys will be deleted.
218+
assert user_1.api_key == "1234567890"
219+
215220
assert user_1.api_key_digest == hash_api_key("1234567890")
216221

217222
db.session.refresh(user_2)

aleph/tests/test_view_context.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def test_authz_header_api_key_invalid(self):
7575
res = self.client.get(f"/api/2/roles/{self.role.id}", headers=headers)
7676
assert res.status_code == 403
7777

78+
headers = {"Authorization": "ApiKey "}
79+
res = self.client.get(f"/api/2/roles/{self.role.id}", headers=headers)
80+
assert res.status_code == 403
81+
7882
headers = {"Authorization": ""}
7983
res = self.client.get(f"/api/2/roles/{self.role.id}", headers=headers)
8084
assert res.status_code == 403
@@ -83,6 +87,10 @@ def test_authz_header_api_key_invalid(self):
8387
res = self.client.get(f"/api/2/roles/{self.role.id}", headers=headers)
8488
assert res.status_code == 403
8589

90+
headers = {"Authorization": " "}
91+
res = self.client.get(f"/api/2/roles/{self.role.id}", headers=headers)
92+
assert res.status_code == 403
93+
8694
def test_authz_url_param_api_key(self):
8795
query_string = {"api_key": "1234567890"}
8896
res = self.client.get(f"/api/2/roles/{self.role.id}", query_string=query_string)
@@ -97,3 +105,7 @@ def test_authz_url_params_api_key_invalid(self):
97105
query_string = {"api_key": ""}
98106
res = self.client.get(f"/api/2/roles/{self.role.id}", query_string=query_string)
99107
assert res.status_code == 403
108+
109+
query_string = {"api_key": " "}
110+
res = self.client.get(f"/api/2/roles/{self.role.id}", query_string=query_string)
111+
assert res.status_code == 403

aleph/worker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import time
44
import threading
55
import functools
6-
import queue
76
import copy
87
from typing import Dict, Callable
98
import sqlalchemy
@@ -116,7 +115,13 @@ def __init__(
116115
version=None,
117116
prefetch_count_mapping=defaultdict(lambda: 1),
118117
):
119-
super().__init__(queues, conn=conn, num_threads=num_threads, version=version)
118+
super().__init__(
119+
queues,
120+
conn=conn,
121+
num_threads=num_threads,
122+
version=version,
123+
prefetch_count_mapping=prefetch_count_mapping,
124+
)
120125
self.often = get_rate_limit("often", unit=300, interval=1, limit=1)
121126
self.daily = get_rate_limit("daily", unit=3600, interval=24, limit=1)
122127
# special treatment for indexing jobs - indexing jobs need to be batched
@@ -125,7 +130,6 @@ def __init__(
125130
# run of all available indexing tasks
126131
self.indexing_batch_last_updated = 0.0
127132
self.indexing_batches = defaultdict(list)
128-
self.local_queue = queue.Queue()
129133
self.prefetch_count_mapping = prefetch_count_mapping
130134

131135
def on_signal(self, signal, _):

aleph/wsgi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import logging
2+
13
from aleph.core import create_app
24
from aleph.settings import SETTINGS
35
from aleph import __version__ as aleph_version
46

57
import sentry_sdk
68
from sentry_sdk.integrations.flask import FlaskIntegration
79

10+
log = logging.getLogger(__name__)
811

912
if SETTINGS.SENTRY_DSN:
1013
sentry_sdk.init(
@@ -17,4 +20,5 @@
1720
environment=SETTINGS.SENTRY_ENVIRONMENT,
1821
send_default_pii=False,
1922
)
23+
log.info("aleph.wsgi initialized Sentry SDK")
2024
app = create_app()

contrib/aleph-traefik-minio-keycloak/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ services:
5454
- "traefik.enable=false"
5555

5656
worker:
57-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
57+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
5858
command: aleph worker
5959
restart: on-failure
6060
links:
@@ -79,7 +79,7 @@ services:
7979
- "traefik.enable=false"
8080

8181
shell:
82-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
82+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
8383
command: /bin/bash
8484
depends_on:
8585
- postgres
@@ -99,7 +99,7 @@ services:
9999
- "traefik.enable=false"
100100

101101
api:
102-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
102+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
103103
command: gunicorn -w 6 -b 0.0.0.0:8000 --log-level debug --log-file - aleph.wsgi:app
104104
expose:
105105
- 8000
@@ -121,7 +121,7 @@ services:
121121
- "traefik.enable=false"
122122

123123
ui:
124-
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.0.2}
124+
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.1.1}
125125
depends_on:
126126
- api
127127
- traefik

contrib/keycloak/docker-compose.dev-keycloak.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
elasticsearch:
1717
build:
1818
context: services/elasticsearch
19-
image: ghcr.io/alephdata/aleph-elasticsearch:${ALEPH_TAG:-4.0.2}
19+
image: ghcr.io/alephdata/aleph-elasticsearch:${ALEPH_TAG:-4.1.1}
2020
hostname: elasticsearch
2121
environment:
2222
- discovery.type=single-node
@@ -55,7 +55,7 @@ services:
5555
app:
5656
build:
5757
context: .
58-
image: alephdata/aleph:${ALEPH_TAG:-4.0.2}
58+
image: alephdata/aleph:${ALEPH_TAG:-4.1.1}
5959
hostname: aleph
6060
command: /bin/bash
6161
links:
@@ -83,7 +83,7 @@ services:
8383
api:
8484
build:
8585
context: .
86-
image: alephdata/aleph:${ALEPH_TAG:-4.0.2}
86+
image: alephdata/aleph:${ALEPH_TAG:-4.1.1}
8787
command: aleph run -h 0.0.0.0 -p 5000 --with-threads --reload --debugger
8888
ports:
8989
- "127.0.0.1:5000:5000"
@@ -117,7 +117,7 @@ services:
117117
ui:
118118
build:
119119
context: ui
120-
image: alephdata/aleph-ui:${ALEPH_TAG:-4.0.2}
120+
image: alephdata/aleph-ui:${ALEPH_TAG:-4.1.1}
121121
links:
122122
- api
123123
command: npm run start

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ services:
4646
- aleph.env
4747

4848
worker:
49-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
49+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
5050
command: aleph worker
5151
restart: on-failure
5252
depends_on:
@@ -62,7 +62,7 @@ services:
6262
- aleph.env
6363

6464
shell:
65-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
65+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
6666
command: /bin/bash
6767
depends_on:
6868
- postgres
@@ -80,7 +80,7 @@ services:
8080
- aleph.env
8181

8282
api:
83-
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
83+
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.1.1}
8484
expose:
8585
- 8000
8686
depends_on:
@@ -97,7 +97,7 @@ services:
9797
- aleph.env
9898

9999
ui:
100-
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.0.2}
100+
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.1.1}
101101
depends_on:
102102
- api
103103
ports:

0 commit comments

Comments
 (0)