Skip to content

Commit

Permalink
Set samesite to strict for cookies
Browse files Browse the repository at this point in the history
Set title to filename instead of filepath in the UI
Bump version
  • Loading branch information
dormant-user committed Feb 23, 2024
1 parent 75bf3d8 commit dbf926e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pystream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .main import start # noqa: F401
from .models import config, images, secure # noqa: F401

version = "2.0"
version = "2.1"
2 changes: 1 addition & 1 deletion pystream/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def redirect_exception_handler(request: Request,
else:
response = RedirectResponse(url=exception.location)
if exception.detail:
response.set_cookie("detail", exception.detail.upper())
response.set_cookie("detail", exception.detail.upper(), httponly=True, samesite="strict")
return response


Expand Down
3 changes: 2 additions & 1 deletion pystream/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ async def login(request: Request) -> JSONResponse:
value=config.static.cipher_suite.encrypt(str(auth_payload).encode("utf-8")).decode(),
max_age=config.env.session_duration,
expires=expiration,
httponly=True)
httponly=True,
samesite="strict")
if config.env.secure_session:
cookie_kwargs["secure"] = True
response.set_cookie(**cookie_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion pystream/routers/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def stream_video(request: Request,
)
if pure_path.exists():
attrs = {
"request": request, "video_title": video_path,
"request": request, "video_title": pure_path.name,
"home": config.static.home_endpoint, "logout": config.static.logout_endpoint,
"path": f"{config.static.streaming_endpoint}?{config.static.query_param}={urlparse.quote(str(pure_path))}"
}
Expand Down
2 changes: 1 addition & 1 deletion pystream/templates/land.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>FastAPI video streaming</title>
<title>{{ video_title }}</title>
<meta property="og:type" content="VideoStreaming">
<meta name="keywords" content="Python, streaming, fastapi, JavaScript, HTML, CSS">
<meta name="author" content="Vignesh Rao">
Expand Down

0 comments on commit dbf926e

Please sign in to comment.