mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Added better debugging
This commit is contained in:
28
roles/srv-web-7-7-inj-logout/meta/main.yml
Normal file
28
roles/srv-web-7-7-inj-logout/meta/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Injects a catcher, which catches the actions of all logout elements and redirects them to the central logout."
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Archlinux
|
||||
versions:
|
||||
- rolling
|
||||
galaxy_tags:
|
||||
- nginx
|
||||
- javascript
|
||||
- csp
|
||||
- sub_filter
|
||||
- injection
|
||||
- global
|
||||
repository: "https://s.veen.world/cymais"
|
||||
documentation: "https://s.veen.world/cymais"
|
||||
issue_tracker_url: "https://s.veen.world/cymaisissues"
|
||||
|
||||
dependencies:
|
||||
- srv-web-7-4-core
|
13
roles/srv-web-7-7-inj-logout/tasks/main.yml
Normal file
13
roles/srv-web-7-7-inj-logout/tasks/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
# run_once_srv_web_7_7_inj_javascript: deactivated
|
||||
- name: "Load JavaScript code for '{{ application_id }}'"
|
||||
set_fact:
|
||||
javascript_code: "{{ lookup('template', modifier_javascript_template_file) }}"
|
||||
|
||||
- name: "Collapse Javascript code into one-liner for '{{application_id}}'"
|
||||
set_fact:
|
||||
javascript_code_one_liner: "{{ javascript_code | to_one_liner }}"
|
||||
|
||||
- name: "Append Javascript CSP hash for '{{application_id}}'"
|
||||
set_fact:
|
||||
applications: "{{ applications | append_csp_hash(application_id, javascript_code_one_liner) }}"
|
||||
changed_when: false
|
1
roles/srv-web-7-7-inj-logout/templates/head_sub.j2
Normal file
1
roles/srv-web-7-7-inj-logout/templates/head_sub.j2
Normal file
@@ -0,0 +1 @@
|
||||
<script>{{ javascript_code_one_liner | replace("'", "\\'") }}</script>
|
38
roles/srv-web-7-7-inj-logout/templates/logout.js.j2
Normal file
38
roles/srv-web-7-7-inj-logout/templates/logout.js.j2
Normal file
@@ -0,0 +1,38 @@
|
||||
(function() {
|
||||
const logoutUrlBase = 'https://auth.cymais.cloud/realms/cymais.cloud/protocol/openid-connect/logout';
|
||||
const redirectUri = encodeURIComponent('https://cymais.cloud');
|
||||
const logoutUrl = `${logoutUrlBase}?redirect_uri=${redirectUri}`;
|
||||
|
||||
// Check if a string matches logout keywords
|
||||
function matchesLogout(str) {
|
||||
return str && /logout|log\s*out|abmelden/i.test(str);
|
||||
}
|
||||
|
||||
// Check if any attribute name contains "logout" (case-insensitive)
|
||||
function hasLogoutAttribute(el) {
|
||||
for (let attr of el.attributes) {
|
||||
if (/logout/i.test(attr.name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find all elements
|
||||
const allElements = document.querySelectorAll('*');
|
||||
allElements.forEach(el => {
|
||||
if (
|
||||
matchesLogout(el.getAttribute('name')) ||
|
||||
matchesLogout(el.id) ||
|
||||
matchesLogout(el.className) ||
|
||||
matchesLogout(el.innerText) ||
|
||||
hasLogoutAttribute(el)
|
||||
) {
|
||||
el.style.cursor = 'pointer';
|
||||
el.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
window.location.href = logoutUrl;
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
1
roles/srv-web-7-7-inj-logout/vars/main.yml
Normal file
1
roles/srv-web-7-7-inj-logout/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
modifier_javascript_template_file: "{{ application_id | abs_role_path_by_application_id }}/templates/javascript.js.j2"
|
Reference in New Issue
Block a user