identity-keycloak-auth.js Logout injection
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- authentication, frontend
Research direction
Start with extension-jwt/src/main/resources/META-INF/resources/webjars/operaton/app/identity-keycloak/scripts/identity-keycloak-auth.js and compare its logout element lookup with the JWT Example's actual DOM. Run the JWT Example, log in, use the profile dropdown, and verify that clicking Logout visits the Keycloak Logout URL and remains logged out after refresh.
Written by the indexing model from the issue text.
Description
Describe the bug
Logout override in 'identity-keycloak-auth.js' is not working due to wrong HTML DOM expectations.
To Reproduce
Steps to reproduce the behavior:
- Run the JWT Example
- Log in
- In the Nav Menu open the propfile dropdown
- Click on Logout
- See that you land on the Operaton Web-App Login Screen
- Refresh the page, see you have not actually logged out.
Expected behavior
Keycloak Logout URL should be visited.
Desktop (please complete the following information):
- OS: Windows
- Browser Firefox
- Operaton-Version v2.1.0
- Operaton-Keycloak Version v2.1.0
Additional context
The error resides in:
/extension-jwt/src/main/resources/META-INF/resources/webjars/operaton/app/identity-keycloak/scripts/identity-keycloak-auth.js
That script expects the Profile dropdown logout button to be an item of type li with a child a, when it is actually directly the a element.
Fix (use 'a' directly)
const observer = new MutationObserver(() => {
const oldLogoutLink = document.querySelector("li.account a.logout");
if (oldLogoutLink) {
observer.disconnect();
const logoutLink = oldLogoutLink.cloneNode(true);
logoutLink.href = '#'
logoutLink.onclick = () => operatonIdentityKeycloak && operatonIdentityKeycloak.logout();
oldLogoutLink.parentElement.replaceChild(logoutLink, oldLogoutLink);
}
});
observer.observe(document, { attributes: false, childList: true, characterData: false, subtree: true });
Similarly the SSO Example logout button script could be fixed:
/**
* CUSTOM LOGOUT BUTTON FOR OPERATON BPM WEBAPPS
*/
let observer = new MutationObserver(() => {
// find the logout button
const logoutButton = document.querySelectorAll("a.logout")[0];
// once the button is present replace it with new functionality
if (logoutButton) {
const clone = logoutButton.cloneNode(true);
clone.setAttribute('href', 'logout'); // call server side logout handler
logoutButton.replaceWith(clone);
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: false,
characterData: false
});
- Dominant language
- Java
- Stars
- 7
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from operaton/operaton-keycloak
-
Docs, Keycloak screenshots are outdated, add note to enable Direct Access Grants for password grant Opengood first issue
operaton/operaton-keycloak#32 · 4 comments · 1 assignee ·
-
enhancement help wanted
operaton/operaton-keycloak#23 · 3 comments · 1 assignee ·
-
good first issue refactoring
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Update Screenshots Opengood first issue
Difficulty 3/5 1-2 days Newbie friendliness 42/100
operaton/operaton-keycloak#13 · 1 comment ·
-
bug good first issue
Difficulty 4/5 3-5 days Newbie friendliness 45/100
operaton/operaton-keycloak#11 · 2 comments ·
All issues in operaton/operaton-keycloak
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100