From 4f8b0ac9deb0d1ae2dad93aa46dbfc1f1382c0c0 Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Mon, 20 Apr 2020 15:19:38 +0200
Subject: [PATCH] import audit

---
 .../fts3rest/controllers/config/audit.py      | 40 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/fts3rest/fts3rest/controllers/config/audit.py b/src/fts3rest/fts3rest/controllers/config/audit.py
index 1c748fbe..a5b9c48d 100644
--- a/src/fts3rest/fts3rest/controllers/config/audit.py
+++ b/src/fts3rest/fts3rest/controllers/config/audit.py
@@ -1,5 +1,41 @@
-from werkzeug.exceptions import NotFound
+#   Copyright Members of the EMI Collaboration, 2013.
+#   Copyright 2013-2020 CERN
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
 
+import logging
 
+from fts3.model import *
+from fts3rest.model.meta import Session
+from fts3rest.lib.helpers.accept import accept
+from fts3rest.lib.middleware.fts3auth.authorization import authorize
+from fts3rest.lib.middleware.fts3auth.constants import *
+
+log = logging.getLogger(__name__)
+"""
+Config audit
+"""
+
+
+@authorize(CONFIG)
+@accept(html_template="/config/audit.html")
 def audit():
-    raise NotFound
+    """
+    Returns the last 100 entries of the config audit tables
+    """
+    return (
+        Session.query(ConfigAudit)
+        .order_by(ConfigAudit.datetime.desc())
+        .limit(100)
+        .all()
+    )
-- 
GitLab