Skip to content

feat: add user agent field and updatedAt to session endpoint#534

Merged
mattdjenkinson merged 10 commits intomainfrom
feat/improve-user-session-data
Apr 28, 2026
Merged

feat: add user agent field and updatedAt to session endpoint#534
mattdjenkinson merged 10 commits intomainfrom
feat/improve-user-session-data

Conversation

@mattdjenkinson
Copy link
Copy Markdown
Contributor

@mattdjenkinson mattdjenkinson commented Mar 23, 2026

This PR adds fields for location, client details and last active to the user session. Once this is merged i'll raise a PR for auth-provider-zitadel to populate these fields.

@joggrbot
Copy link
Copy Markdown
Contributor

joggrbot Bot commented Mar 23, 2026

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: 1de1096 | Powered by Joggr

@mattdjenkinson mattdjenkinson marked this pull request as ready for review March 23, 2026 17:14
Comment thread pkg/apis/identity/v1alpha1/types.go Outdated
Comment thread pkg/apis/identity/v1alpha1/types.go Outdated
Comment thread pkg/apis/identity/v1alpha1/types.go
kevwilliams
kevwilliams previously approved these changes Mar 23, 2026
@mattdjenkinson mattdjenkinson changed the title feat: add location, client and last active fields to session endpoint feat: add location and client fields to session endpoint Mar 23, 2026
@mattdjenkinson
Copy link
Copy Markdown
Contributor Author

@scotwells could you take a look at this again please? I've added an updatedAt field that will be updated when things like the ip, user-agent etc on the session change.

scotwells
scotwells previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@scotwells scotwells left a comment

Choose a reason for hiding this comment

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

Looks good. Let's test with Zitadel before we merge this in. Assume you confirmed all these fields are available from Zitadel?

@mattdjenkinson
Copy link
Copy Markdown
Contributor Author

@scotwells yeah, will push my branch for Zitadel and put on staging.

@mattdjenkinson mattdjenkinson changed the title feat: add location and client fields to session endpoint feat: add user agent field and updatedAt to session endpoint Mar 25, 2026
Add Location, Browser, and OS string fields to identity SessionStatus
so authentication providers can return enriched session data. The
fields are populated by the auth-provider-zitadel apiserver, which
calls an internal GraphQL gateway (parseUserAgent + geolocateIP) to
resolve them from the raw IP and User-Agent before returning the
session. All three are optional and remain empty when enrichment is
unavailable or the source field is unknown.
…sion-data

# Conflicts:
#	docs/api/identity.md
@JoseSzycho
Copy link
Copy Markdown
Contributor

@mattdjenkinson seems that when you executed task generate , some manual generated API docs got deleted, as the identity API

The earlier task generate run on this branch produced 4-line stubs for
docs/api/identity.md and docs/api/crm.md because the generate:docs
script iterates config/crd/bases/* and the identity and crm groups
have empty subdirectories there (their docs are hand-maintained). The
same regression was seen and fixed previously in 90c6b57.

Restore both files from main and update the SessionStatus table on
identity.md to match the current types: drop expiresAt, add
lastUpdatedAt and userAgent (introduced earlier on this branch), and
add location, browser, and os populated by the GraphQL gateway
enrichment path.
JoseSzycho
JoseSzycho previously approved these changes Apr 28, 2026
scotwells
scotwells previously approved these changes Apr 28, 2026
The userinvitation controller's RBAC markers were missing patch on
userinvitations and the userinvitations/finalizers subresource. The
generated role.yaml on main had the rules anyway but they were drift
from the markers; running task generate during the recent merge
removed them, which would have broken patch operations and finalizer
removal in the controller.

Add the missing markers so controller-gen produces the same role.yaml
that main was carrying, and the source of truth lives next to the
controller logic that depends on it.
@mattdjenkinson mattdjenkinson dismissed stale reviews from scotwells and JoseSzycho via 1de1096 April 28, 2026 16:30
@mattdjenkinson mattdjenkinson merged commit a8a1ae7 into main Apr 28, 2026
10 checks passed
@mattdjenkinson mattdjenkinson deleted the feat/improve-user-session-data branch April 28, 2026 18:57
mattdjenkinson added a commit that referenced this pull request Apr 28, 2026
…ds (#585)

## Summary
- Removes `location`, `browser`, and `os` from `SessionStatus` (added in
#534).
- Keeps `ip`, `fingerprintID`, `lastUpdatedAt`, and `userAgent` — those
are the raw fields the auth provider actually populates.
- Regenerates `zz_generated.openapi.go` via \`task
generate:openapi:identity\`.
- Hand-edits `docs/api/identity.md` to remove the three rows from the
SessionStatus table (this file is hand-maintained because
`config/crd/bases/identity/` is empty).

## Why
The session-enrichment topology has been re-aligned: the GraphQL gateway
now fetches sessions from this API and produces its own
`ExtendedSession` type with geolocation and parsed user-agent attached.
The `auth-provider-zitadel` apiserver only writes raw values, so these
three derived-data fields on `SessionStatus` are never populated.
Leaving them in place would suggest the API surfaces data it doesn't
actually carry.

## Companion PRs
- `datum-cloud/auth-provider-zitadel#81` — corrected to expose raw IP /
fingerprint / lastUpdatedAt / userAgent only (no enrichment).
- `datum-cloud/graphql-gateway` — new sessions resolver coming next.
- `datum-cloud/infra#2268` — auth-provider gateway-call wiring removed;
gateway-side MaxMind plumbing retained.

## Test plan
- [x] \`task generate:code\` and \`task generate:openapi:identity\`
clean.
- [x] \`go build ./pkg/apis/...\` clean.
- [ ] After this lands and milo cuts \`v0.24.6\`, bump
\`go.miloapis.com/milo\` in auth-provider-zitadel to drop the now-stale
dependency on the removed fields (no code changes needed there since the
auth provider never set them).
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.

4 participants