Skip to content

feat: Support organization MDC #200

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

Merged
merged 4 commits into from
Apr 25, 2025
Merged

feat: Support organization MDC #200

merged 4 commits into from
Apr 25, 2025

Conversation

jeanpommier
Copy link
Member

Solves #195

Resolving the user and organisation information requires to intervene at a late stage, much later than the logging MDCWebFilter class (after ResolveGeorchestraUserGlobalFilter). Resolving the objects would also imply a circular dependency if implemented in the logging module. So, it seems to make more sense to implement it in the main geOrchestra gateway code.

Solves #195

Resolving the user and organisation information requires to intervene
at a late stage, much later than the logging MDCWebFilter class
(after ResolveGeorchestraUserGlobalFilter). Resolving the objects would
also imply a circular dependency if implemented in the logging module.
So, it seems to make more sense to implement it in the main geOrchestra
gateway code.
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.

Awesome

@groldan
Copy link
Member

groldan commented Apr 22, 2025

I don't know what to do about the failing builds though, they're reporting Cache service responded with 422

@jeanpommier
Copy link
Member Author

I don't know what to do about the failing builds though, they're reporting Cache service responded with 422

They're failing on all pending PRs, right ? I was concerned first, then concluded that the CI was currently a bit broken

@jeanpommier
Copy link
Member Author

Awesome

My first Gateway PR ! Champagne !

@jeanpommier
Copy link
Member Author

About Cache service responded with 422, I believe this is not specificly tied to this PR, but let's quickly discuss it.
I'm really no expert at this, but searching for this kind of issue, I stumbled upon actions/setup-python#1085.
Given how they solved it, I'd suggest we try to upgrade the setup-java action from v2 to v4 (current)

@jeanpommier
Copy link
Member Author

jeanpommier commented Apr 22, 2025

Back to this PR, before thinking about merging it, I'd like your opinion guys about something:
on my filter, I'm adding several MDC:

  • org: uuid, shortname and full name (if logging org is enabled)
  • user: uuid, firstname, lastname (if logging for user is enabled), which complements the already set username.

Why so many MDCs ? Well, since the idea is to provide analytics dataviz, it will help having user-friendly labels available. I could get there some other way afterwards, but it's more complicated
Why the uuids ? Well, AFAIK, geOrchestra now allows for username and org shortname to change over time. Why will cause problem tracking them. I'd rather rely on the objects' uuid for that

And now, here is my question: does it seem OK for you to have just one toggle config (user:true/false, org: true/false) for this bunch of MDCs, or do you think we should have more granular control around which ones we want (e.g. configure them one by one) ?

@jeanpommier
Copy link
Member Author

About Cache service responded with 422, I believe this is not specificly tied to this PR, but let's quickly discuss it. I'm really no expert at this, but searching for this kind of issue, I stumbled upon actions/setup-python#1085. Given how they solved it, I'd suggest we try to upgrade the setup-java action from v2 to v4 (current)

@groldan indeed that was it. Fixed by f77e6c3

@jeanpommier jeanpommier requested a review from groldan April 23, 2025 08:34
@landryb
Copy link
Member

landryb commented Apr 23, 2025

having more granular control would mostly be to allow "downsizing" the amount of data logged, right ? i'm not sure logging firstname & lastname is relevant if you log the uid/username.. but on my platform username is firstname.lastname and not the first letter+lastname default.

while i agree changing uids is an issue, i'm not a fan of uuids either, because that requires an ldap query to resolve the "current" user associated with it, so you still need to keep track of that mapping somewhere.

@jeanpommier
Copy link
Member Author

jeanpommier commented Apr 23, 2025

i'm not a fan of uuids either, because that requires an ldap query to resolve the "current" user associated with it, so you still need to keep track of that mapping somewhere.

Well, that's why I wanted to log user first/last name and org full name, it's to avoid looking up on the LDAP to get nice human-friendly names. And in that case, I don't even need the username (done with uuid and human-friendly labels)

I believe I remember struggling with an org shortname that had changed at some point and it causing trouble, back when I was working on CKAN-georchestra integration, so I'm thinking uuids might help.

@jeanpommier
Copy link
Member Author

What about adding a logging.mdc.include.user.extras switch ?

logging:
  mdc:
    include:
      user:
        id: true           # Include user ID in enduser.id and enduser.uuid
        roles: true        # Include user roles in enduser.roles
        org: true          # Include user's organization in enduser.org.uuid and enduser.org.id (shortname)
        extras: true     # include human-friendly labels enduser.firstname, enduser.lastname, enduser.org.fullname
        auth-method: true  # Include authentication method in enduser.auth-method

Does it seem like a reasonable compromise ?

@landryb
Copy link
Member

landryb commented Apr 23, 2025

What about adding a logging.mdc.include.user.extras switch ?

logging:
  mdc:
    include:
      user:
        id: true           # Include user ID in enduser.id and enduser.uuid
        roles: true        # Include user roles in enduser.roles
        org: true          # Include user's organization in enduser.org.uuid and enduser.org.id (shortname)
        extras: true     # include human-friendly labels enduser.firstname, enduser.lastname, enduser.org.fullname
        auth-method: true  # Include authentication method in enduser.auth-method

Does it seem like a reasonable compromise ?

yes that seems good if that's not too much boilerplate to write, assuming that if a dashboard (or something consuming the data down the line) requires the 'extras' attributes it's stated clearly :)

@jeanpommier
Copy link
Member Author

yes that seems good if that's not too much boilerplate to write,

Nope, no trouble. Let's go for that

jeanpommier added a commit that referenced this pull request Apr 23, 2025
Add the switch in configuration file
Add the logic according to discussion on #200
Give a better name to the filter
Update the doc
Add the switch in configuration file
Add the logic according to discussion on #200
Give a better name to the filter
Update the doc
@jeanpommier jeanpommier force-pushed the add_organization_mdc branch from bd5606c to 3a7d787 Compare April 23, 2025 15:52
@jeanpommier
Copy link
Member Author

done. I also renamed the filter, the name was not very explicit. And updated the doc

@jeanpommier jeanpommier merged commit 6dea5fa into main Apr 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants