diff --git a/tdrs-backend/docker-compose.yml b/tdrs-backend/docker-compose.yml
index a6624688b..4b29abb1c 100644
--- a/tdrs-backend/docker-compose.yml
+++ b/tdrs-backend/docker-compose.yml
@@ -101,6 +101,7 @@ services:
- CYPRESS_TOKEN
- DJANGO_DEBUG
- SENDGRID_API_KEY
+ - BYPASS_KIBANA_AUTH
volumes:
- .:/tdpapp
image: tdp
diff --git a/tdrs-backend/tdpservice/settings/common.py b/tdrs-backend/tdpservice/settings/common.py
index dc4e4c51e..88733be92 100644
--- a/tdrs-backend/tdpservice/settings/common.py
+++ b/tdrs-backend/tdpservice/settings/common.py
@@ -465,11 +465,13 @@ class Common(Configuration):
}
}
- # Elastic
+ # Elastic/Kibana
ELASTICSEARCH_DSL = {
'default': {
'hosts': os.getenv('ELASTIC_HOST', 'elastic:9200'),
},
}
+ KIBANA_BASE_URL = os.getenv('KIBANA_BASE_URL', 'http://localhost:5601')
+ BYPASS_KIBANA_AUTH = os.getenv("BYPASS_KIBANA_AUTH", 0)
CYPRESS_TOKEN = os.getenv('CYPRESS_TOKEN', None)
diff --git a/tdrs-backend/tdpservice/urls.py b/tdrs-backend/tdpservice/urls.py
index 26858b356..368314c92 100755
--- a/tdrs-backend/tdpservice/urls.py
+++ b/tdrs-backend/tdpservice/urls.py
@@ -11,7 +11,7 @@
from rest_framework.permissions import AllowAny
-from .users.api.authorization_check import AuthorizationCheck
+from .users.api.authorization_check import AuthorizationCheck, KibanaAuthorizationCheck
from .users.api.login import TokenAuthorizationLoginDotGov, TokenAuthorizationAMS
from .users.api.login import CypressLoginDotGovAuthenticationOverride
from .users.api.login_redirect_oidc import LoginRedirectAMS, LoginRedirectLoginDotGov
@@ -52,6 +52,7 @@
urlpatterns = [
path("v1/", include(urlpatterns)),
path("admin/", admin.site.urls, name="admin"),
+ path("kibana/", KibanaAuthorizationCheck.as_view(), name="kibana-authorization-check"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# TODO: Supply `terms_of_service` argument in OpenAPI Info once implemented
diff --git a/tdrs-backend/tdpservice/users/api/authorization_check.py b/tdrs-backend/tdpservice/users/api/authorization_check.py
index 57ed30527..3dc372e1a 100644
--- a/tdrs-backend/tdpservice/users/api/authorization_check.py
+++ b/tdrs-backend/tdpservice/users/api/authorization_check.py
@@ -8,6 +8,8 @@
from rest_framework.response import Response
from rest_framework.views import APIView
from ..serializers import UserProfileSerializer
+from django.http import HttpResponseRedirect
+from django.conf import settings
logger = logging.getLogger(__name__)
@@ -47,3 +49,19 @@ def get(self, request, *args, **kwargs):
else:
logger.info("Auth check FAIL for user on %s", timezone.now())
return Response({"authenticated": False})
+
+class KibanaAuthorizationCheck(APIView):
+ """Check if user is authorized to view Kibana."""
+
+ query_string = False
+ pattern_name = "kibana-authorization-check"
+ permission_classes = [AllowAny]
+
+ def get(self, request, *args, **kwargs):
+ """Handle get request and verify user is authorized."""
+ user = request.user
+
+ if (user.is_authenticated and user.hhs_id is not None) or settings.BYPASS_KIBANA_AUTH:
+ return HttpResponseRedirect(settings.KIBANA_BASE_URL)
+ else:
+ return HttpResponseRedirect(settings.FRONTEND_BASE_URL)
diff --git a/tdrs-frontend/nginx/local/locations.conf b/tdrs-frontend/nginx/local/locations.conf
index 2fc38d3ad..154cda557 100644
--- a/tdrs-frontend/nginx/local/locations.conf
+++ b/tdrs-frontend/nginx/local/locations.conf
@@ -4,7 +4,7 @@ location = /nginx_status {
deny all;
}
-location ~ ^/(v1|admin|static/admin|swagger|redocs) {
+location ~ ^/(v1|admin|static/admin|swagger|redocs|kibana) {
limit_req zone=limitreqsbyaddr delay=5;
proxy_pass http://${BACK_END}:8080$request_uri;
proxy_set_header Host $host:3000;
diff --git a/tdrs-frontend/src/components/Header/Header.jsx b/tdrs-frontend/src/components/Header/Header.jsx
index 2f6c5335b..dfb28d75c 100644
--- a/tdrs-frontend/src/components/Header/Header.jsx
+++ b/tdrs-frontend/src/components/Header/Header.jsx
@@ -137,6 +137,13 @@ function Header() {
href={`${process.env.REACT_APP_BACKEND_HOST}/admin/`}
/>
)}
+ {userIsAdmin && (
+
+ )}
>
)}
diff --git a/tdrs-frontend/src/components/SiteMap/SiteMap.jsx b/tdrs-frontend/src/components/SiteMap/SiteMap.jsx
index 1df805e7d..84144c24f 100644
--- a/tdrs-frontend/src/components/SiteMap/SiteMap.jsx
+++ b/tdrs-frontend/src/components/SiteMap/SiteMap.jsx
@@ -31,6 +31,13 @@ const SiteMap = ({ user }) => {
link={`${process.env.REACT_APP_BACKEND_HOST}/admin/`}
/>
)}
+
+ {userIsAdmin && (
+
+ )}
)
}