Skip to content

Commit 94e20bd

Browse files
authored
Merge pull request #1028 from CSCfi/refactor/switch-to-redis
switch to redis library
2 parents 168c126 + 1aab788 commit 94e20bd

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6767
- (GL #944) Replace buefy b-select with c-select from `csc-ui`
6868
- (GL #944) Replace buefy b-loading with c-loader from `csc-ui` and remove unused b-loading
6969
- (GL #944) Replace buefy b-table with c-data-table from `csc-ui`
70+
- (GH #1028) Switch from `aioredis` to `redis` library due to deprecation
71+
- (GH #1025) add timeout to `requests` as recommended by `bandit`
7072
- (GL #944) Replace buefy dialogs with c-modal from `csc-ui`
7173
- (GL #944) Replace buefy notifications with c-toasts from `csc-ui`
7274

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
dependencies = [
2323
"aiohttp-session==2.12.0",
2424
"aiohttp==3.8.4",
25-
"aioredis==2.0.1",
25+
"redis==4.5.1",
2626
"asyncpg==0.27.0",
2727
"certifi==2022.12.7",
2828
"click==8.1.3",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
aiohttp==3.8.4
22
aiohttp-session==2.12.0
3-
aioredis==2.0.1
3+
redis==4.5.1
44
asyncpg==0.27.0
55
certifi==2022.12.7
66
click==8.1.3

swift_browser_ui/ui/server.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import aiohttp_session
1919
import aiohttp_session.redis_storage
2020

21-
import aioredis
22-
import aioredis.sentinel
21+
from redis import asyncio as aioredis
2322

2423
from oidcrp.rp_handler import RPHandler
2524

@@ -122,12 +121,12 @@ async def on_prepare(
122121
redis_user = str(os.environ.get("SWIFT_UI_REDIS_USER", ""))
123122
redis_password = str(os.environ.get("SWIFT_UI_REDIS_PASSWORD", ""))
124123

125-
redis: aioredis.Redis
124+
redis_client: aioredis.Redis
126125
if sentinel_url and sentinel_port:
127126
# we forward the auth to redis so no need for auth on sentinel
128127
sentinel = aioredis.sentinel.Sentinel([(str(sentinel_url), int(sentinel_port))])
129128

130-
redis = sentinel.master_for(
129+
redis_client = sentinel.master_for(
131130
service_name=sentinel_master,
132131
redis_class=aioredis.Redis,
133132
password=redis_password,
@@ -140,9 +139,11 @@ async def on_prepare(
140139
redis_creds = ""
141140
if redis_user and redis_password:
142141
redis_creds = f"{redis_user}:{redis_password}@"
143-
redis = aioredis.from_url(f"redis://{redis_creds}{redis_host}:{redis_port}")
142+
redis_client = aioredis.from_url(
143+
f"redis://{redis_creds}{redis_host}:{redis_port}"
144+
)
144145
storage = aiohttp_session.redis_storage.RedisStorage(
145-
redis,
146+
redis_client,
146147
cookie_name="SWIFT_UI_SESSION",
147148
)
148149
app["seckey"] = base64.urlsafe_b64decode(cryptography.fernet.Fernet.generate_key())

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ deps =
3131
mypy
3232
types-requests
3333
types-certifi
34+
types-redis
3435
# Mypy fails if 3rd party library doesn't have type hints configured.
3536
# Alternative to ignoring imports would be to write custom stub files, which
3637
# could be done at some point.

0 commit comments

Comments
 (0)