Skip to content

Commit

Permalink
Merge pull request #15 from numerique-gouv/serve-static-assets
Browse files Browse the repository at this point in the history
✨(static) add static frontend to serve assets
  • Loading branch information
jonathanperret authored Sep 11, 2024
2 parents 6424679 + 039d9a1 commit 3b518b9
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- serve static files

## [1.0.3] - 2024-09-02
- set SAML signing algorithm to use SHA256 for compatibility with AccessCheck

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN mkdir -p /usr/local/etc/gunicorn
COPY docker/files/usr/local/etc/gunicorn/satosa.py /usr/local/etc/gunicorn/satosa.py

# The default command runs gunicorn WSGI server in satosa's main module
CMD ["gunicorn", "-c", "/usr/local/etc/gunicorn/satosa.py", "satosa.wsgi:app"]
CMD ["gunicorn", "-c", "/usr/local/etc/gunicorn/satosa.py"]

# ---- Development image ----
FROM common as development
Expand Down
1 change: 1 addition & 0 deletions docker/files/usr/local/etc/gunicorn/satosa.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def json_record(
bind = ["0.0.0.0:8000"]
name = "satosa"
python_path = "/app"
wsgi_app = "oidc2fer.wsgi:app"

# Run
graceful_timeout = 90
Expand Down
3 changes: 2 additions & 1 deletion src/satosa/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ disable=bad-inline-option,
useless-suppression,
missing-module-docstring,
missing-class-docstring,
missing-function-docstring
missing-function-docstring,
wrong-import-order

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
9 changes: 9 additions & 0 deletions src/satosa/oidc2fer/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

from satosa.wsgi import app as satosa_app
from whitenoise import WhiteNoise

# Wrap the SATOSA WSGI app in WhiteNoise to serve static files
app = WhiteNoise(
satosa_app, root=os.path.join(os.curdir, "static"), index_file="index.html"
)
1 change: 1 addition & 0 deletions src/satosa/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies = [
"gunicorn==22.0.0",
"redis==5.0.4",
"JSON-log-formatter==1.0",
"WhiteNoise==6.7.0",
]

[project.urls]
Expand Down
10 changes: 10 additions & 0 deletions src/satosa/static/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/satosa/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="1; url=https://agentconnect.gouv.fr/">
</head>
<body>
<h1>Passerelle ProConnect vers RENATER. Redirection en cours…</h1>
</body>
</html>
8 changes: 8 additions & 0 deletions src/satosa/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ def test_agent_connect_to_renater_student_not_allowed(page: Page):
renater_test_idp(page, login="etudiant1")

expect(page.locator("body")).to_contain_text("Une erreur technique est survenue.")


@pytest.mark.skipif(
"TEST_E2E" not in os.environ, reason="Depends on app running locally"
)
def test_serve_static_assets(page: Page):
page.goto("https://satosa.traefik.me/images/logo.svg")
expect(page.locator("svg")).to_be_visible()

0 comments on commit 3b518b9

Please sign in to comment.