Skip to content

Add Groundlight.me() for authenticated identity - #468

Open
timmarkhuff wants to merge 9 commits into
mainfrom
thuff/add-me-method
Open

Add Groundlight.me() for authenticated identity#468
timmarkhuff wants to merge 9 commits into
mainfrom
thuff/add-me-method

Conversation

@timmarkhuff

@timmarkhuff timmarkhuff commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This PR allows SDK users to discover the group (name and id) of a user. A simple check of user's group without triggering token rotation would look something like:

with Groundlight(enable_token_rotation=False) as gl:
    me = gl.me()

group_id = me.groups[0].id

Summary of Changes

  • Adds Groundlight.me() returning a small Me model (id, email, username, groups) from GET /v1/me.
  • groups are customer/org tenants (id + name), not detector groups.
  • Extra /me fields (feature flags, etc.) are ignored.
  • whoami() now returns me().email; CLI picks up me under Account.
  • Syncs spec/public-api.yaml and generated models from the zuuul OpenAPI update.

Merge order

  1. Merge zuuul #6707 first (OpenAPI Me / CustomerGroup schema).
  2. Then merge this PR.

Do not merge the SDK until the zuuul OpenAPI change is on main (or otherwise deployed as the source of the synced YAML).

Test plan

  • poetry run pytest test/unit/test_user.py
  • Live smoke: gl.me() returns email/groups for a real token

Tim Huff and others added 3 commits July 30, 2026 18:34
Expose id, email, username, and customer groups from GET /v1/me so
callers can inspect the token's tenant without parsing the raw response.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid colliding with detector-group concepts; callers that need the
type can import it from groundlight.identity.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/groundlight/identity.py Outdated
name: str = Field(..., description="Name of the customer group.")


class Me(BaseModel): # pylint: disable=too-few-public-methods

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should be able to get this model for free from the api spec if we model it appropriately in the BE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I opened a separate PR to update the backend.

Tim Huff and others added 6 commits July 31, 2026 12:58
Replace hand-written identity models with codegen from the updated
/v1/me schema, and sync spec/public-api.yaml from zuuul.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Import generated models from model, matching other unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Revert accidental full-client regenerate noise and keep only the
/v1/me schema and generated Me/CustomerGroup wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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