Skip to content

Conversation

@neSpecc
Copy link
Member

@neSpecc neSpecc commented Jan 15, 2026

This pull request introduces Single Sign-On (SSO) with SAML support, adds a local Keycloak IdP for integration testing, and updates Node.js and related dependencies. The main changes include new SSO-related models, resolvers, and directives, as well as updates to Docker and CI/CD configurations to support the new authentication flow.

SSO/SAML Support and User Model Enhancements

  • Introduced SAML SSO support with new user identity fields, methods to link SAML identities, and a factory method to find users by SAML identity (UserModel, UsersFactory). [1] [2] [3]
  • Added SSO configuration to WorkspaceModel, including methods to update SSO settings. [1] [2]
  • Enhanced authentication logic to enforce SSO for users in workspaces with enforced SSO, and adjusted token lifetimes accordingly. [1] [2] [3] [4]

Testing and Local Development Improvements

  • Added a local Keycloak service to docker-compose.test.yml for integration testing SSO flows, including health checks and setup scripts. [1] [2] [3] [4]
  • Updated .env.sample with a new SSO_SP_ENTITY_ID variable for SAML configuration.

Node.js and Dependency Upgrades

  • Upgraded Node.js version to 24.11.1 across .nvmrc, Dockerfiles, and CI/CD workflows, and made the Node.js version configurable in Docker builds. [1] [2] [3] [4] [5] [6]
  • Added and updated dependencies for SAML, XML parsing, and type definitions in package.json. [1] [2] [3]

GraphQL and Middleware Enhancements

  • Added a definedOnlyForAdmins GraphQL directive to restrict field visibility to workspace admins, returning null for non-admins.
  • Improved MongoDB metrics middleware to skip setup in test environments.

SSO Route Integration

  • Integrated SSO routes into the main Express app, initializing shared factories for SSO endpoints. [1] [2]

SSO/SAML Support:

  • Added SAML identity storage and linking methods to UserModel, and a method to find users by SAML identity in UsersFactory. [1] [2] [3]
  • Included SSO configuration in WorkspaceModel and added a method for updating SSO settings. [1] [2]
  • Enforced SSO authentication flow in user resolvers, including error handling and token expiry changes for SSO users. [1] [2] [3] [4]

Testing/Dev Infrastructure:

  • Added a local Keycloak IdP to docker-compose.test.yml for SSO integration tests, including health checks and setup. [1] [2] [3] [4]
  • Updated .env.sample with SSO-related configuration.

Platform/Dependency Updates:

  • Upgraded Node.js to 24.11.1 in .nvmrc, Dockerfiles, and CI/CD, and made Node.js version configurable in Docker builds. [1] [2] [3] [4] [5] [6]
  • Added/updated SAML and XML dependencies in package.json. [1] [2] [3]

GraphQL/Middleware:

  • Introduced a definedOnlyForAdmins directive for admin-only field visibility in GraphQL schemas.
  • Skipped MongoDB metrics setup in test environments.

App Integration:

  • Appended SSO routes to the Express app with shared factories for SSO endpoints. [1] [2]

neSpecc and others added 29 commits December 20, 2025 17:24
Moved SAML audience, recipient, and time condition validation functions from SamlService to a new utils module for better separation of concerns. Added comprehensive unit tests for these utility functions and for SAML service logic. Improved test data isolation by introducing a unique test string generator. Updated existing user and usersFactory tests to use the new generator and ensure test isolation. Also, prevented MongoDB metrics setup in test environments.
Replaces custom SAML assertion validation logic with @node-saml/node-saml for signature, audience, and time validation. Updates error handling to map node-saml errors to SamlValidationError types, adds fallback error type, and removes now-unnecessary utility functions and tests. Extends and improves test coverage for SAML response parsing, error cases, and attribute extraction.
Added logic to generate SAML AuthnRequest using node-saml, extract the request ID from the encoded request, and handle errors. Updated and expanded unit tests to cover successful generation, error cases, and correct invocation of SAML library methods.
Added SAML SSO login and ACS endpoint logic to the controller, including user provisioning and session creation. Updated Jest config to use a dedicated test tsconfig. Added comprehensive tests for SAML controller behavior and created a test tsconfig.json.
Introduces a new @definedOnlyForAdmins directive to restrict certain fields to workspace admins, returning null for non-admins. Adds SSO configuration types, inputs, and resolvers to the workspace schema, including the sso field and updateWorkspaceSso mutation, both protected for admin access. Updates schema wiring to register the new directive and its transformer.
Dockerfiles and GitHub Actions workflow now use a dynamic Node.js version via build args, reading from .nvmrc for consistency. SAML SSO controller adds workspace ID validation, improved error handling, and clearer error responses for SSO initiation and ACS callback. Also documents REDIS_URL in environment types.
Introduces the ssoWorkspace query to fetch public workspace info (id, name, image) for SSO login pages. Updates GraphQL type definitions with WorkspacePreview type and exposes ssoWorkspace query for unauthenticated access.
Added enforcement of SSO login for users in workspaces with enforced SSO. Refactored SSO configuration update logic by introducing setSsoConfig method in WorkspaceModel and updating resolver to use it, ensuring only SSO config is modified.
Refresh token lifetime is now 2 days instead of 30 for users in workspaces with enforced SSO. This change applies to both standard and SAML SSO flows to improve security by requiring more frequent re-authentication.
@neSpecc neSpecc requested a review from Copilot January 15, 2026 16:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces comprehensive Single Sign-On (SSO) support with SAML authentication to the Hawk tracking system. The implementation includes backend authentication flows, user identity management, GraphQL API updates, and integration testing infrastructure.

Changes:

  • Added SAML SSO authentication flow with Identity Provider integration, user provisioning, and workspace-based SSO enforcement
  • Upgraded Node.js from v22.12.0 to v24.11.1 across all environments and CI/CD pipelines
  • Integrated Keycloak IdP for local development and integration testing with automated setup scripts

Reviewed changes

Copilot reviewed 39 out of 42 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
yarn.lock Updated dependencies for SAML support (@node-saml/node-saml, xml libraries) and @hawk.so/types
package.json Added SAML dependencies and updated @hawk.so/types to v0.4.2
src/sso/* Complete SAML service implementation with controller, store, service, and utilities
src/models/user.ts Added SAML identity linking methods and shorter token lifetime for SSO users
src/models/usersFactory.ts Added findBySamlIdentity method for SSO user lookup
src/models/workspace.ts Added SSO configuration storage and update methods
src/resolvers/*.{js,ts} Implemented SSO enforcement in login flow and workspace SSO configuration queries/mutations
src/directives/definedOnlyForAdmins.ts New directive to restrict field visibility to workspace admins
src/typeDefs/workspace.ts Added SSO configuration types and WorkspacePreview for public SSO login pages
src/index.ts Integrated SSO routes into Express application
test/sso/* Comprehensive unit tests for SAML utils, store, service, and controller
test/models/* Unit tests for user SAML identity management
test/integration/* End-to-end SSO tests with Keycloak integration
docker-compose.test.yml Added Keycloak service for integration testing
.nvmrc, docker/Dockerfile.* Upgraded Node.js version to v24.11.1
.github/workflows/* Updated CI/CD to use Node.js version from .nvmrc

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Refactored SAML state management to support both Redis and in-memory stores via a new SamlStateStoreInterface. Added Redis-backed implementation for multi-instance deployments and a factory to select the store type based on the SAML_STORE_TYPE environment variable. Updated controller and router to use the new store abstraction, and extended environment and type definitions accordingly.
@neSpecc neSpecc changed the title Sso feat(sso): sso support added Jan 15, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 82.35294% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.13%. Comparing base (0f8dad9) to head (d95d526).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/sso/saml/controller.ts 78.23% 32 Missing ⚠️
src/sso/saml/store/memory.store.ts 75.92% 11 Missing and 2 partials ⚠️
src/models/workspace.ts 0.00% 3 Missing ⚠️
src/sso/saml/service.ts 94.64% 3 Missing ⚠️
src/models/user.ts 84.61% 2 Missing ⚠️
src/metrics/mongodb.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #614      +/-   ##
==========================================
- Coverage   58.30%   55.13%   -3.17%     
==========================================
  Files          19       32      +13     
  Lines         518     1032     +514     
  Branches       95      198     +103     
==========================================
+ Hits          302      569     +267     
- Misses        216      427     +211     
- Partials        0       36      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@neSpecc neSpecc merged commit c8b18bf into master Jan 15, 2026
11 checks passed
@neSpecc neSpecc deleted the sso branch January 15, 2026 21:46
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