Skip to content

JAMES-4205: Fix OIDC mailbox provisioning#3044

Draft
felixauringer wants to merge 6 commits into
apache:masterfrom
giz-berlin:fix-oidc-mailbox-provisioning
Draft

JAMES-4205: Fix OIDC mailbox provisioning#3044
felixauringer wants to merge 6 commits into
apache:masterfrom
giz-berlin:fix-oidc-mailbox-provisioning

Conversation

@felixauringer
Copy link
Copy Markdown
Contributor

@felixauringer felixauringer commented May 19, 2026

Benoit asked in https://issues.apache.org/jira/browse/JAMES-4205 that independent of the authentication mechanism, James should perform provisioning.

To fulfill that requirement, I introduced (or rather repurposed) the method authSuccess to perform all operations that are necessary after a successful operation.
While I was at it, I also introduced authFailure which is called quite often and therefore should reduce the complexity quite a bit.
This also changes the semantics a little in some places, mainly because every failure is now consistently logged with AuditTrail and effects the failure count.

I am still running tests but I would also appreciate if somebody more familiar with the code base could validate that I did not accidentally change the semantics in some place other than log messages.

Additionally, I am not sure where session.stopDetectingCommandInjection(); is supposed to be used but I could not find any logic to how it was used before and changed it so that it is consistently called after every processed request.

Copy link
Copy Markdown
Contributor

@chibenwa chibenwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good with me.

A 🍏 AI run and it shall be good to go!

@chibenwa
Copy link
Copy Markdown
Contributor

chibenwa commented May 19, 2026

session.stopDetectingCommandInjection();

We are either authenticated or STARTTLS is active

changed it so that it is consistently called after every processed request

It will do

Rationals: we need to verify STARTTLS command is not altered midayy to batch extra commands in. This costly check is no longer needed as soon as auth or starttls is passed. CF https://nostarttls.secvuln.info/ for rationnals.

@felixauringer felixauringer force-pushed the fix-oidc-mailbox-provisioning branch from 4e6e265 to 17ee7c8 Compare May 20, 2026 08:00
@felixauringer
Copy link
Copy Markdown
Contributor Author

We are either authenticated or STARTTLS is active

Okay, I removed all calls of stopDetectingCommandInjection except one in authSuccess. Before, it was also called if authentication had failed.

Another question: After a successful authentication, the server tries to provision the mailboxes for the user but ignores potential errors. The authentication is not aborted. Is that the behavior you would like in that case?

Before my changes, the server would send a NO reply but not reset the session, so I guess the session would have been authenticated. That's weird behavior that I would like to get rid off but I am not sure what the correct behavior would be.

@chibenwa
Copy link
Copy Markdown
Contributor

Another question: After a successful authentication, the server tries to provision the mailboxes for the user but ignores potential errors. The authentication is not aborted. Is that the behavior you would like in that case?

Good question

I think being lenient prevents not accessing his mail...

So current behaviour is likely good.

Before my changes, the server would send a NO reply but not reset the session, so I guess the session would have been authenticated. That's weird behavior that I would like to get rid off but I am not sure what the correct behavior would be.

I think answering yes anyway and doing provisionning in a best effort way is indeed better.

@felixauringer felixauringer force-pushed the fix-oidc-mailbox-provisioning branch from 17ee7c8 to 4e5aa79 Compare May 20, 2026 08:30
Currently, mailboxes (even INBOX) are only created when logging
in using PLAIN or LOGIN.
There are now two methods (authFailure and authSuccess) and all
paths that result in successful authentication or an error caused
by the user are now handled in those two places.

There are still some errors that are caused by James itself which
are not handled by those two methods.
@felixauringer felixauringer force-pushed the fix-oidc-mailbox-provisioning branch from 4e5aa79 to 310073a Compare May 20, 2026 08:42
@felixauringer felixauringer changed the title Fix OIDC mailbox provisioning JAMES-4205: Fix OIDC mailbox provisioning May 20, 2026
@felixauringer felixauringer force-pushed the fix-oidc-mailbox-provisioning branch from 310073a to f2ecd05 Compare May 20, 2026 11:48
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