Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid providing internal notes to /whoami endpoint (fixes #170) #171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pmauduit
Copy link
Member

@pmauduit pmauduit commented Jan 21, 2025

See mentioned issue #170 and related one (georchestra/georchestra#4280). This PR aims to avoid having the /whoami endpoint revealing the "internal notes" field from the LDAP, as it is an internal note on the user and is not meant to be available from the endpoint.

Tests: 2 tests added, also making sure that the /whoami endpoint will work when not connected (user is null).

@pmauduit pmauduit force-pushed the knowledge-info-whoami-170 branch from 6823a48 to da242bf Compare January 21, 2025 15:35
@pmauduit pmauduit requested a review from groldan January 21, 2025 15:38
@pmauduit pmauduit marked this pull request as ready for review January 21, 2025 15:39
@pmauduit pmauduit requested a review from f-necas January 21, 2025 15:40
@@ -106,6 +106,11 @@ public Mono<Map<String, Object>> whoami(Authentication principal, ServerWebExcha
}

Map<String, Object> ret = new LinkedHashMap<>();
if (user != null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

(Auto-reviewing myself): I am not very fond of null testing user, as using an Optional some lines above should be about avoiding it, but is there another way ?

Choose a reason for hiding this comment

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

but is there another way ?

I don't think so.

@pmauduit
Copy link
Member Author

Also I am wondering if we should handle sensitive fields one by one (hashed passwords from the LDAP, internal CRM notes, ...), or if there are no other means for doing so ?

@pmauduit pmauduit linked an issue Jan 21, 2025 that may be closed by this pull request
@Gaetanbrl
Copy link

Gaetanbrl commented Jan 21, 2025

Perhaps it would be interesting to be able to configure these fields ?

@pmauduit
Copy link
Member Author

pmauduit commented Jan 21, 2025

Perhaps it would be interesting to be able to configure these fields ?

why not, but we can't really predict what would be needed on the GeorchestraUser object in the coming months / years / ... and what should be stripped from the whoami endpoint, in my opinion.

Also making it configureable would leave the opportunity to the administrators to have flawed configurations revealing undesired fields, so I am a bit puzzled.

Copy link
Member

@groldan groldan left a comment

Choose a reason for hiding this comment

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

LGTM.
On a separate note, I think the whole point of the /whoami endpoint is being a debugging aid and should be disabled in any production deployment.
Or maybe, the default should be to only return the username and roles, but all the rest only when explicitly enabled either with a spring profile or a config property?

@f-necas
Copy link
Collaborator

f-necas commented Feb 13, 2025

should be disabled in any production deployment.

It's used for the header to set it up on each page. But maybe we should have a dedicated route in the console.

@pmauduit
Copy link
Member Author

It's used for the header to set it up on each page. But maybe we should have a dedicated route in the console.

My concern is that having the same endpoint on the console would break the "modular" approach of geOrchestra. In some cases, the console is not even deployed (e.g. DT was not even using the geOrchestra LDAP in their "external" geOrchestra instance, so there were no console either), at least we can consider that the SP or the gateway would always be deployed. So for me having this endpoint on the GW / the SP makes sense.

@pmauduit
Copy link
Member Author

Or maybe, the default should be to only return the username and roles, but all the rest only when explicitly enabled either with a spring profile or a config property?

Yes, sounds good

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.

gateway leaks internal notes to user
4 participants