Skip to content

[Portal Backend] Optimize GetMember using the IdPUseID #322

@sthanikan2000

Description

@sthanikan2000

Current Limitation

The system currently retrieves member details by calling the GetAllMembers endpoint and filtering the results by IdPUserID. This approach is inefficient and not scalable for scenarios where this lookup is performed frequently, such as:

  • Member login flows: When a member signs in through an identity provider, we need to quickly fetch their member profile using only the IdPUserID.
  • API authorization: During request authorization, the decoded token contains only the IdPUserID. To validate that a member is accessing only their own resources, we must resolve the corresponding memberId efficiently. The current workflow requires calling GetAllMembers and filtering client-side, which is both slow and unnecessary.

This results in wasted processing time, extra network overhead, and unnecessary load on the backend.


Suggested Improvement

To optimize these high-frequency lookups, introduce dedicated support for querying by IdPUserID:

  1. Add a new service function:
    GetMemberByIdPUserID(IdPUserID string) (*Member, error)
    This should provide a direct, efficient lookup rather than relying on scanning all members.

  2. Add a new API endpoint:
    A dedicated endpoint that returns a Member resource filtered by IdPUserID.
    This may be implemented as either:

    • A new route (e.g., GET /members/by-idp/{idpUserId}), or
    • An enhancement to the existing members endpoint allowing a server-side idpUserId filter.

This improvement will reduce latency, improve authorization checks, and remove the need for inefficient client-side filtering.


Version

No response


Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions