Skip to content

Commit d1ab3a6

Browse files
committed
fix(api): deny all API requests
Fixes packit/packit-service#2529 Signed-off-by: Matej Focko <mfocko@redhat.com>
1 parent 3bc9e5c commit d1ab3a6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packit_dashboard/api/routes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright Contributors to the Packit project.
2+
# SPDX-License-Identifier: MIT
3+
4+
from logging import getLogger
5+
6+
from flask import Blueprint
7+
from flask_cors import CORS
8+
9+
10+
logger = getLogger("packit_dashboard")
11+
api = Blueprint(
12+
"api",
13+
__name__,
14+
)
15+
CORS(api)
16+
17+
18+
@api.route("/api/", defaults={"path": ""})
19+
@api.route("/api/<path:path>")
20+
def drop(path):
21+
return ("", 421)

packit_dashboard/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from flask import Flask
77
from flask_talisman import Talisman
88

9+
from packit_dashboard.api.routes import api
910
from packit_dashboard.home.routes import home
1011

1112
app = Flask(
@@ -16,6 +17,7 @@
1617
# Note: Declare any other flask blueprints or routes above this.
1718
# Routes declared below this will be rendered by React
1819
app.register_blueprint(home)
20+
app.register_blueprint(api)
1921

2022

2123
# Enable CSP and HSTS

0 commit comments

Comments
 (0)