-
Notifications
You must be signed in to change notification settings - Fork 27
add list session method #470
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
Added ListSessions method to retrieve user sessions from the WorkOS API with pagination support.
- Introduced
Sessionstruct with comprehensive fields including user/org IDs, status, auth method, IP address, timestamps - Created
ListSessionsOptsfor filtering and pagination (UserID,Limit,Before,After,Order) - Implemented
ListSessionsclient method following existing patterns with proper error handling - Added wrapper function in
usermanagement.gofor default client usage - Included comprehensive test coverage with mock handlers
Issue found: The ListSessionsOpts struct is missing url struct tags, which means query parameters won't be properly encoded when calling the API. This will cause filtering/pagination to not work correctly.
Confidence Score: 3/5
- Missing struct tags will prevent query parameters from working, but no security issues
- The implementation follows existing patterns and includes proper tests, but the missing
urlstruct tags onListSessionsOptsis a functional bug that will prevent query parameters from being sent to the API. This needs to be fixed before merging. pkg/usermanagement/client.goneeds struct tags added toListSessionsOpts(lines 618-624)
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| pkg/usermanagement/client.go | 3/5 | Added Session struct, ListSessionsOpts, ListSessionsResponse, and ListSessions method; missing URL struct tags in ListSessionsOpts will cause query params to be ignored |
| pkg/usermanagement/client_test.go | 5/5 | Added listSessionsTestHandler test handler following existing test patterns |
| pkg/usermanagement/usermanagement.go | 5/5 | Added ListSessions wrapper function that delegates to DefaultClient.ListSessions |
| pkg/usermanagement/usermanagement_test.go | 5/5 | Added TestUserManagementListSessions test using standard patterns from existing tests |
Sequence Diagram
sequenceDiagram
participant Client as Application
participant UM as usermanagement.ListSessions()
participant DC as DefaultClient
participant API as WorkOS API
Client->>UM: ListSessions(ctx, opts)
UM->>DC: DefaultClient.ListSessions(ctx, opts)
DC->>DC: Create HTTP GET request to /user_management/sessions
DC->>DC: Set default Limit=10 if opts.Limit==0
DC->>DC: Set default Order=Desc if opts.Order==""
DC->>DC: Encode opts to query params using query.Values()
DC->>API: GET /user_management/sessions?query_params
Note over DC,API: Headers: Authorization, User-Agent, Content-Type
API-->>DC: ListSessionsResponse (JSON)
DC->>DC: Decode JSON response
DC-->>UM: ListSessionsResponse
UM-->>Client: ListSessionsResponse
4 files reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
mattgd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR - left a few comments. Feel free to tag me when ready for re-review.
|
@mattgd Hi Matt, its ready for review |
Description
Add List Session Method that will call workOS API for list session
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.