Skip to content

Add authentication service factory for extensibility#1737

Merged
cezudas merged 2 commits intomainfrom
cezudas/OPS-3009-auth-service-factory
Dec 5, 2025
Merged

Add authentication service factory for extensibility#1737
cezudas merged 2 commits intomainfrom
cezudas/OPS-3009-auth-service-factory

Conversation

@cezudas
Copy link
Copy Markdown
Contributor

@cezudas cezudas commented Dec 5, 2025

Part of OPS-3009.

This refactoring allows for easier extension and customization of authentication behavior while preserving type safety and maintaining backward compatibility.

Copilot AI review requested due to automatic review settings December 5, 2025 10:41
@linear
Copy link
Copy Markdown

linear Bot commented Dec 5, 2025

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 5, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cezudas/OPS-3009-auth-service-factory

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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 PR introduces a factory pattern for authentication services to improve extensibility and enable easier customization of authentication behavior. The change establishes a level of indirection that will facilitate future implementations of alternative authentication strategies.

Key changes:

  • Created a new authentication-service-factory.ts file with a factory function and type definition
  • Updated the authentication controller to use the factory function instead of directly importing the service

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
authentication-service-factory.ts Introduces factory function and AuthenticationService type for abstracting authentication service creation
authentication.controller.ts Updates imports and call sites to use the new factory pattern instead of direct service imports

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Dec 5, 2025

Greptile Overview

Greptile Summary

Introduced a factory pattern for the authentication service to enable extensibility while maintaining type safety. The refactoring extracts the AuthenticationService interface and provides a getAuthenticationService() factory function that currently returns the basic authentication service implementation.

Key Changes:

  • Created new authentication-service-factory.ts with type definition and factory function
  • Updated authentication.controller.ts to use factory function instead of direct import
  • Maintains backward compatibility with existing seed files that still use direct imports
  • No changes to actual authentication logic or behavior

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The refactoring is a clean implementation of the factory pattern with no changes to business logic. Type safety is preserved, the interface exactly matches the implementation, and backward compatibility is maintained. The changes are isolated to two files with straightforward modifications.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/server/api/src/app/authentication/authentication-service-factory.ts 5/5 Introduced factory pattern with type definition for authentication service extensibility
packages/server/api/src/app/authentication/authentication.controller.ts 5/5 Updated to use factory function instead of direct service import for sign-up and sign-in routes

Sequence Diagram

sequenceDiagram
    participant Controller as authentication.controller
    participant Factory as getAuthenticationService
    participant Service as authenticationService
    participant Utils as Authentication Utils

    Note over Controller,Utils: Sign Up Flow
    Controller->>Factory: call factory function
    Factory-->>Controller: returns service
    Controller->>Service: signUp(params)
    Service->>Utils: createUser
    Service->>Utils: assignDefaultOrganization
    Service->>Utils: getProjectAndToken
    Service-->>Controller: AuthenticationResponse

    Note over Controller,Utils: Sign In Flow
    Controller->>Factory: call factory function
    Factory-->>Controller: returns service
    Controller->>Service: signIn(request)
    Service->>Utils: getByOrganizationAndEmail
    Service->>Utils: assertUserIsAllowedToSignIn
    Service->>Utils: assertPasswordMatches
    Service->>Utils: authenticateUser
    Service->>Utils: getProjectAndToken
    Service-->>Controller: AuthenticationResponse
Loading

Copy link
Copy Markdown
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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Dec 5, 2025

@cezudas cezudas merged commit 10985cf into main Dec 5, 2025
24 checks passed
@cezudas cezudas deleted the cezudas/OPS-3009-auth-service-factory branch December 5, 2025 11:23
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