Back-channel logout failed: Unable to perform requested lazy initialization [org.booklore.model.entity.BookLoreUserEntity.username] - no session and settings disallow loading outside the Session #1601
albertmichaelj
started this conversation in
Issue Triage
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What went wrong?
I have set up OIDC (using Authentik) as an identity provider for Grimmory. I was trying to get single logout working, but it appears that there is some issue with grimmory that prevents the correct processing of the logout request. The specific error that I am receiving in the logs is:
Note that the above indicates that Authentik is correctly calling the back-channel logout endpoint, but their is a failure with Grimmory processing the request.
I got ChatGPT to look at the error and it suggested some fixes. I am copying and pasting the response below, but I am not qualified to determine if it is correct, so please feel free to ignore the below information if it is not helpful.
Back-channel logout fails with Hibernate lazy initialization error
Summary
I am using Grimmory with Authentik OIDC. Normal OIDC login works, and Authentik is successfully reaching Grimmory’s back-channel logout endpoint. However, back-channel logout fails inside Grimmory with a Hibernate lazy initialization error.
Error
Back-channel logout failed: Unable to perform requested lazy initialization [org.booklore.model.entity.BookLoreUserEntity.username] - no session and settings disallow loading outside the Session
Expected behavior
When Authentik sends a valid OIDC back-channel logout request, Grimmory should revoke the associated OIDC/local session and log the user out of Grimmory.
Actual behavior
The back-channel logout request reaches Grimmory, but Grimmory fails while processing it. The local Grimmory session remains active.
Likely cause
This looks like a lazy-loading issue in the back-channel logout path.
From the current code structure, OidcSessionEntity.user appears to be lazy-loaded, and BackchannelLogoutService accesses fields such as:
session.getUser().getUsername()
during logout processing. If the persistence session is already closed, this throws a Hibernate LazyInitializationException.
Suggested direction for fix
The back-channel logout handling should probably be adjusted so that the user entity is available while the persistence context is active. Possible fixes:
@transactional
public void handleLogoutToken(String logoutToken) {
...
}
Notes
This does not appear to be an Authentik networking/configuration issue, because Grimmory logs show that the back-channel logout request is being received and processed by Grimmory before failing internally.
How can we reproduce it?
What Build of Grimmory are you on?
Stable
Your setup
Screenshots or error messages (optional)
No response
Before submitting
Beta Was this translation helpful? Give feedback.
All reactions