Skip to content

Optional User Session#406

Merged
bjoernricks merged 16 commits into
mainfrom
optional-user-session
May 15, 2026
Merged

Optional User Session#406
bjoernricks merged 16 commits into
mainfrom
optional-user-session

Conversation

@bjoernricks
Copy link
Copy Markdown
Contributor

@bjoernricks bjoernricks commented May 15, 2026

What

Make the User Session optional.

Disclaimer: The session timeout doesn't work correctly with JWT at the moment.

Why

With this change there are two kinds of authentication:

  1. Session based
  2. JWT based

The standard and default mode is the session based mode which uses a token and a cookie to create a session and to identify a user. This mode is stateful.

The new mode is JWT based and uses the Authorization header to get the JSON web token. The JWT is passed to GMP without creating a session within gsad. The session is bound to the lifetime of the JWT currently. This mode is stateless.

References

https://jira.greenbone.net/browse/GEA-1668

@bjoernricks bjoernricks requested review from a team as code owners May 15, 2026 11:22
@greenbonebot greenbonebot enabled auto-merge (rebase) May 15, 2026 11:23
@bjoernricks bjoernricks marked this pull request as draft May 15, 2026 11:23
auto-merge was automatically disabled May 15, 2026 11:23

Pull request was converted to draft

@bjoernricks bjoernricks force-pushed the optional-user-session branch 2 times, most recently from a54e163 to f68f0e6 Compare May 15, 2026 11:27
This seems to be a leftover from ancient XSLT times.
Avoid crashing if the user is not available. This will be the case for
the JWT only mode.
If we don't have a user from the session aka. JWT only mode don't add
the client address, locale, session timeout, timezone or token to the
envelope.
Don't require a token for getting the user out of the session and
support JWT only mode for http get requests.
Setting the timezone is not necessary for gsad anymore. It seems like a
leftover from ancient XSLT times.
Using the params struct allows to get the token for GET **and** POST
requests and also validates the token.
Before the validation of the parameters was done later for POST requests
(or even never). With this change it is ensured that all parameters are
valid for every request getting in our handler chain.
…ests

We don't care about the accept language header value at all therefore we
can safely ignore it.
Don't crash if the user is not available. This will be required for the
JWT mode.
Require user or jwt for all requests to the `/gmp` and `/system_report`
endpoints. Otherwise return a 401 response.
Also only logout all user sessions only if a user is available. This
avoids crashing in JWT mode.
Remove the user and credential setup from the exec_gmp_post method to
reduce duplicated code. Both will be done in a next commit via the
http handler chain instead. With this change exec_gmp_post and
exec_gmp_get are very similar and only handle GMP specific business
logic.
The cookie data is not used anymore.
Refactor setting up user and credentials for all API calls. With the
changed exec_gmp_post function is is possible to use the same handler
chain for all API calls.
Always send all GMP commands even if the user has no capability for the
command. Just let gvmd handle it. We don't have capabilities of the user
in JWT mode. Therefore it doesn't make sense to check it. Also the
functions using command enabled are very special and GSA should not use
their endpoints anymore.
Don't crash if the user is not available. This is the case in the JWT
mode.
@bjoernricks bjoernricks force-pushed the optional-user-session branch from f68f0e6 to ad5d52e Compare May 15, 2026 11:30
@bjoernricks bjoernricks marked this pull request as ready for review May 15, 2026 11:30
@bjoernricks bjoernricks enabled auto-merge (rebase) May 15, 2026 11:30
@bjoernricks bjoernricks merged commit fc7ce4f into main May 15, 2026
21 checks passed
@bjoernricks bjoernricks deleted the optional-user-session branch May 15, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants