Skip to content

feat(auth): implement sub-organization login selection#5522

Merged
IgorHorta merged 31 commits intomainfrom
igor/eng-4584-implement-authentication-into-specific-sub-organizations
Mar 3, 2026
Merged

feat(auth): implement sub-organization login selection#5522
IgorHorta merged 31 commits intomainfrom
igor/eng-4584-implement-authentication-into-specific-sub-organizations

Conversation

@IgorHorta
Copy link
Contributor

@IgorHorta IgorHorta commented Feb 19, 2026

Context

Adds support for sub-organizations in the login flow. Previously, users could only select a root organization at login. This PR introduces a new select-organization page that displays the org hierarchy and allows users to log directly into a sub-organization or its root org.

Closes ENG-4584

Key changes:

  • New backend endpoint GET /api/v1/organization/accessible-with-sub-orgs returns orgs with their accessible sub-orgs
  • New useGetOrganizationsWithSubOrgs hook to consume the endpoint
  • Redesigned org selection page using Infisical's auth page design identity
  • Drill-down UX: clicking on a root org shows its sub-orgs with a breadcrumb to navigate back
  • Sub-orgs automatically expand inline when the search term matches
  • Sub-orgs inherit the root org's SSO enforcement (SAML/OIDC/Google) at login
  • Auto-login is skipped when a user has one org with sub-orgs (they must pick which to enter)

Screenshots

Screenshare.-.2026-02-20.12_21_09.PM.mp4

Steps to verify the change

  1. Log in as a user with access to multiple orgs (or one org with sub-orgs)
  2. Confirm the org selection page appears instead of auto-login
  3. Click on an org with sub-orgs — verify breadcrumb appears and sub-orgs are listed
  4. Log into a root org and a sub-org — verify each lands in the correct workspace
  5. For an org with SSO enforced, verify sub-org login correctly triggers the SSO redirect
  6. Search for a sub-org by name — verify the parent org expands automatically

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

@linear
Copy link

linear bot commented Feb 19, 2026

@maidul98
Copy link
Collaborator

maidul98 commented Feb 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@IgorHorta IgorHorta changed the title Igor/eng 4584 implement authentication into specific sub organizations feat(auth): implement sub-organization login selection Feb 20, 2026
@IgorHorta IgorHorta marked this pull request as ready for review February 20, 2026 15:14
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

This PR adds sub-organization support to the login flow, allowing users to select and log into sub-organizations or their root organizations. The implementation includes a new backend endpoint that returns organization hierarchies with proper authorization checks, and a redesigned frontend UI with drill-down navigation and search functionality.

Key changes:

  • New GET /api/v1/organization/accessible-with-sub-orgs endpoint returns root orgs with accessible sub-orgs
  • Backend properly validates user membership via direct assignment or group membership using grouped OR queries
  • Frontend inherits SSO enforcement settings from root org when logging into sub-orgs
  • Auto-login is skipped when a user has one org with accessible sub-orgs
  • Search functionality automatically expands parent orgs when sub-org names match

Security: Authorization is properly enforced - users can only see sub-orgs they have explicit membership in (direct or via groups). The existing selectOrganization flow validates membership before issuing tokens.

Confidence Score: 4/5

  • This PR is safe to merge with only minor spelling corrections needed
  • The implementation is well-structured with proper authorization checks and follows security best practices. OR queries are correctly grouped to prevent filter bypass. Only minor typos in function names need correction.
  • No files require special attention beyond fixing the spelling typos in backend/src/services/org/org-service.ts and backend/src/server/routes/v1/organization-router.ts

Important Files Changed

Filename Overview
backend/src/server/routes/v1/organization-router.ts Added new GET endpoint /accessible-with-sub-orgs to return organizations with sub-org hierarchy
backend/src/services/org/org-dal.ts Implemented listOrganizationsWithSubOrgs with proper authorization checks and grouped OR queries
frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx Redesigned org selection UI with drill-down navigation, search filtering, and sub-org support; inherits SSO from root org

Last reviewed commit: bd524e6

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Adds sub-organization navigation and enhances the
organization selection interface. Improves the
visual hierarchy and provides a smoother user
experience.
Calculates and stores total organization count in
a variable which is used to determine whether the
search input should be displayed or not.
Copy link
Member

@varonix0 varonix0 left a comment

Choose a reason for hiding this comment

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

I think we need the "Member since" here, looks very empty

Image

Copy link
Member

@varonix0 varonix0 left a comment

Choose a reason for hiding this comment

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

This arrow is pretty invisible, maybe we should make it more clear? @scott-ray-wilson might be good to loop in on this

Image

Copy link
Member

@varonix0 varonix0 left a comment

Choose a reason for hiding this comment

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

Sent a video to you privately showing a UI discrepancy with selecting root organizations

IgorCorrea and others added 8 commits March 2, 2026 15:58
This adds tracking of when a user joined an organization by retrieving
the createdAt timestamp from the Membership table. The schema now includes
userJoinedAt to expose this information in API responses. This enables
the frontend to display "Member since" information on the organization
selection screen.

The actor type check in listOrganizationsWithSubOrgs has been removed to
support future use cases beyond just user actors.
Updates the organization selection screen to display "Member since"
information for both root and sub-organizations. The frontend type has
been updated to include the userJoinedAt field, and the UI now renders
the formatted join date for each organization using date-fns.

This provides users with context about when they joined each organization,
enhancing transparency in multi-organization environments.
Consolidate the two separate queries (root orgs and sub-orgs) into a single
efficient query with proper left joins to resolve userJoinedAt for both direct
membership and group-based access. Remove the unused actorType parameter from
the function signature.
Extend the sub-organization schema to include the userJoinedAt field, which
tracks when a user joined a specific sub-organization through direct membership
or group membership.
Update the org service to pass only actorId when calling listOrganizationsWithSubOrgs,
matching the simplified function signature in the DAL.
Extend the sub-organization schema to include the userJoinedAt field, which
tracks when a user joined a specific sub-organization through direct membership
or group membership.
Update the org service to pass only actorId when calling listOrganizationsWithSubOrgs,
matching the simplified function signature in the DAL.
Extend the frontend type definition to include userJoinedAt on sub-organization
objects, enabling the UI to display when users joined sub-organizations.
Refactor the organization selection UI to:
- Make root org login section a semantic button element instead of div
- Display user join dates in both root org and sub-org sections
- Show join dates in the format 'Member since MMM d yyyy'
- Improve accessibility with proper button semantics and ARIA labels
- Update styling to work with the new button structure
@IgorHorta IgorHorta force-pushed the igor/eng-4584-implement-authentication-into-specific-sub-organizations branch from 2df1b4b to 102b185 Compare March 2, 2026 23:53
@IgorHorta IgorHorta requested a review from varonix0 March 2, 2026 23:54
@IgorHorta IgorHorta merged commit 3c48e12 into main Mar 3, 2026
12 checks passed
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