Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (GL #944) Replace buefy b-select with c-select from `csc-ui`
- (GL #944) Replace buefy b-loading with c-loader from `csc-ui` and remove unused b-loading
- (GL #944) Replace buefy b-table with c-data-table from `csc-ui`
- (GH #1028) Switch from `aioredis` to `redis` library due to deprecation
- (GH #1025) add timeout to `requests` as recommended by `bandit`
- (GL #944) Replace buefy dialogs with c-modal from `csc-ui`
- (GL #944) Replace buefy notifications with c-toasts from `csc-ui`

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
dependencies = [
"aiohttp-session==2.12.0",
"aiohttp==3.8.4",
"aioredis==2.0.1",
"redis==4.5.1",
"asyncpg==0.27.0",
"certifi==2022.12.7",
"click==8.1.3",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aiohttp==3.8.4
aiohttp-session==2.12.0
aioredis==2.0.1
redis==4.5.1
asyncpg==0.27.0
certifi==2022.12.7
click==8.1.3
Expand Down
13 changes: 7 additions & 6 deletions swift_browser_ui/ui/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import aiohttp_session
import aiohttp_session.redis_storage

import aioredis
import aioredis.sentinel
from redis import asyncio as aioredis

from oidcrp.rp_handler import RPHandler

Expand Down Expand Up @@ -122,12 +121,12 @@ async def on_prepare(
redis_user = str(os.environ.get("SWIFT_UI_REDIS_USER", ""))
redis_password = str(os.environ.get("SWIFT_UI_REDIS_PASSWORD", ""))

redis: aioredis.Redis
redis_client: aioredis.Redis
if sentinel_url and sentinel_port:
# we forward the auth to redis so no need for auth on sentinel
sentinel = aioredis.sentinel.Sentinel([(str(sentinel_url), int(sentinel_port))])

redis = sentinel.master_for(
redis_client = sentinel.master_for(
service_name=sentinel_master,
redis_class=aioredis.Redis,
password=redis_password,
Expand All @@ -140,9 +139,11 @@ async def on_prepare(
redis_creds = ""
if redis_user and redis_password:
redis_creds = f"{redis_user}:{redis_password}@"
redis = aioredis.from_url(f"redis://{redis_creds}{redis_host}:{redis_port}")
redis_client = aioredis.from_url(
f"redis://{redis_creds}{redis_host}:{redis_port}"
)
storage = aiohttp_session.redis_storage.RedisStorage(
redis,
redis_client,
cookie_name="SWIFT_UI_SESSION",
)
app["seckey"] = base64.urlsafe_b64decode(cryptography.fernet.Fernet.generate_key())
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ deps =
mypy
types-requests
types-certifi
types-redis
# Mypy fails if 3rd party library doesn't have type hints configured.
# Alternative to ignoring imports would be to write custom stub files, which
# could be done at some point.
Expand Down