Repository: privacyidea/privacyidea

Issue:
link to privacy statment (GDPR)
If privacyIDEA is publically facing the company running privacyIDEA should be able to provide a link for the privacystatement.

This link should be available in the footer of the website availble without the need to login.

The URL should be configurable via policy.

As long as no URL is configured the privacy statement would not be displayed.

* [x] Define policy
* [x] pass config to UI
* [x] enhance HTML template


Discussion:
- add webui policy in policy.py
- add policy value to render_context in login.py
- use this value in loginController.js to display the link in baseline.html

Resolving patch:
diff --git a/privacyidea/lib/policy.py b/privacyidea/lib/policy.py
--- a/privacyidea/lib/policy.py
+++ b/privacyidea/lib/policy.py
@@ -351,6 +351,7 @@ class ACTION(object):
     SHOW_SEED = "show_seed"
     CUSTOM_MENU = "custom_menu"
     CUSTOM_BASELINE = "custom_baseline"
+    GDPR_LINK = "privacy_statement_link"
     STATISTICSREAD = "statistics_read"
     STATISTICSDELETE = "statistics_delete"
     LOGIN_TEXT = "login_text"
@@ -2181,6 +2182,10 @@ def get_static_policy_definitions(scope=None):
                 'type': 'str',
                 'desc': _("Use your own html template for the web UI baseline/footer.")
             },
+            ACTION.GDPR_LINK: {
+                'type': 'str',
+                'desc': _("Link your privacy statement to be displayed in the baseline/footer.")
+            },
             ACTION.USERDETAILS: {
                 'type': 'bool',
                 'desc': _("Whether the user ID and the resolver should be "
diff --git a/privacyidea/webui/login.py b/privacyidea/webui/login.py
--- a/privacyidea/webui/login.py
+++ b/privacyidea/webui/login.py
@@ -148,6 +148,13 @@ def single_page_application():
     else:
         login_text = ""
 
+    gdpr_link = Match.action_only(g, action=ACTION.GDPR_LINK, scope=SCOPE.WEBUI) \
+        .action_values(unique=True, allow_white_space_in_action=True, write_to_audit_log=False)
+    if len(gdpr_link) and list(gdpr_link)[0] and sub_state not in [1, 2]:
+        gdpr_link = list(gdpr_link)[0]
+    else:
+        gdpr_link = ""
+
     render_context = {
         'instance': instance,
         'backendUrl': backend_url,
@@ -165,6 +172,7 @@ def single_page_application():
         'realms': realms,
         'external_links': external_links,
         'login_text': login_text,
+        'gdpr_link': gdpr_link,
         'logo': logo,
         'page_title': page_title
     }


Test patch:
diff --git a/tests/test_ui_login.py b/tests/test_ui_login.py
--- a/tests/test_ui_login.py
+++ b/tests/test_ui_login.py
@@ -84,3 +84,12 @@ def test_06_remote_user(self):
             res = self.app.full_dispatch_request()
             self.assertTrue(res.status_code == 200, res)
             self.assertTrue(b"<input type=hidden id=REMOTE_USER value=\"foo\">" in res.data)
+
+    def test_07_privacy_statement_link(self):
+        set_policy("gdpr_link", scope=SCOPE.WEBUI,
+                   action="{0!s}=https://privacyidea.org/".format(ACTION.GDPR_LINK))
+        with self.app.test_request_context('/',
+                                           method='GET'):
+            res = self.app.full_dispatch_request()
+            self.assertTrue(res.status_code == 200, res)
+            self.assertTrue(b"https://privacyidea.org/" in res.data)
\ No newline at end of file