Skip to content

feat(identity-mapper): MVP tool to apply user groups compliant with incoming cluster admin policies#1366

Open
davehadley wants to merge 1 commit into
mainfrom
drh/identity-mapper-mvp-3
Open

feat(identity-mapper): MVP tool to apply user groups compliant with incoming cluster admin policies#1366
davehadley wants to merge 1 commit into
mainfrom
drh/identity-mapper-mvp-3

Conversation

@davehadley
Copy link
Copy Markdown
Collaborator

No description provided.

@davehadley davehadley force-pushed the drh/identity-mapper-mvp-3 branch from bd96ad5 to 9fa9190 Compare June 2, 2026 15:07
@davehadley davehadley marked this pull request as ready for review June 2, 2026 15:08
@davehadley davehadley requested a review from a team June 2, 2026 15:41
@davehadley davehadley requested a review from TBThomas56 June 4, 2026 09:49
Comment thread .github/workflows/ci.yaml

jobs:

changes:
Copy link
Copy Markdown
Contributor

@TBThomas56 TBThomas56 Jun 5, 2026

Choose a reason for hiding this comment

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

should there be a better name for this ci?
My understanding is that it is "changes"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fine for MVP but this is a lot of memory being used at once to create identity for every person at Diamond. Maybe implementing some form of pagination / multiple K8s API calls could be done?

def lookup_identities_in_ldap(
ldap: ldap3.Connection,
) -> dict[int, Identity]:
people_base_dn = _BASE_DN
Copy link
Copy Markdown
Contributor

@TBThomas56 TBThomas56 Jun 5, 2026

Choose a reason for hiding this comment

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

the key here is int. but in sync it is a string. Is that on purpose? Wouldn't that cause the difference in the K8s state always? And user identity to be recreated every 30 minutes?

kubernetes_data: dict[int, Identity],
) -> None:
desired_state = {
str(uid_num): {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

referencing to different key type from above

path_parts = operation["path"].strip("/").split("/")
username = path_parts[0] # The user ID string (e.g., "10023")

if op_type == "add" and len(path_parts) == 1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for next review. Probably better to use a match -> case instead of if / elif

IdentityCrd.GROUP, IdentityCrd.VERSION, IdentityCrd.PLURAL, body
)

elif op_type == "remove" and len(path_parts) == 1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what happens if you try remove a suplementalgroup? {"op": "remove", "path": "/1001/suplementalGroups/dasc"}. How is this handled as the len of path_parts are 3 here

)


def test_lookup_identities_in_kubernetes() -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could add a test case of syncing / updating to ensure that the things are not being deleted and brought back

dependencies = [
"kubernetes==35.0.0",
"ldap3>=2.9.1",
"structlog>=25.5.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do not see structlog being used but logging is used throughout.

securityContext:
runAsUser: "{{`{{ request.object.spec.securityContext.runAsUser }}`}}"
runAsGroup: "{{`{{ request.object.spec.securityContext.runAsGroup }}`}}"
{{- end }} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no new line

name: noop
spec:
steps:
- try: No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no new line

targetRevision: HEAD
extraValueFiles:
- staging-values.yaml
valuesObject: {} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no new line

enabled: false
targetRevision: HEAD
extraValueFiles:
- dev-values.yaml No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no new line

WORKDIR /app
RUN uv sync --locked

CMD ["uv", "run", "--no-sync", "identity-mapper"] No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no new line

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.

3 participants