Skip to content

GDB-14665: Fix regression to allow multiple login strategies#2995

Open
yordanalexandrov wants to merge 1 commit into
masterfrom
gdb-14665-fix-regression-allow-multiple-login-strategies
Open

GDB-14665: Fix regression to allow multiple login strategies#2995
yordanalexandrov wants to merge 1 commit into
masterfrom
gdb-14665-fix-regression-allow-multiple-login-strategies

Conversation

@yordanalexandrov
Copy link
Copy Markdown
Contributor

What

Refactored authentication logic to support multiple login strategies based on user tokens.

Why

This change addresses a regression that prevented the application from correctly handling multiple authentication strategies, improving user experience and flexibility in login options.

How

  • Introduced setStrategy method to manually set authentication strategies.
  • Updated resolveStrategy to return the appropriate strategy based on user authentication state.
  • Modified login component to show correct multiple login strategies.
  • Modified login method of AuthenticationService to set appropriate strategy based on login details.
  • Adjusted tests to reflect changes in the login method signature.

Testing

Screenshots

image

Checklist

  • Branch name
  • Target branch
  • Commit messages
  • Squash commits
  • MR name
  • MR Description
  • Tests
  • Browser support verified

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 refactors the authentication flow to support multiple login strategies (GraphDB token vs OpenID) by introducing explicit strategy selection in the API layer and updating the Workbench login UI and tests to match the new AuthenticationService.login(...) signature.

Changes:

  • Updated login UI to display both GraphDB and OpenID login options and route login through a single handler.
  • Modified AuthenticationService.login to accept a single loginData object (optional) and set the appropriate auth strategy.
  • Refined auth strategy resolution based on authenticated user state and token prefix, and updated unit/integration tests accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/workbench/src/app/pages/login/login-page.component.ts Updates login handler to support OpenID vs username/password via a single method and new service signature.
packages/workbench/src/app/pages/login/login-page.component.html Renders multiple login strategy buttons within one form.
packages/workbench/src/app/pages/login/login-page.component.scss Adjusts layout for multiple login actions.
packages/shared-components/src/components/onto-test-context/onto-test-context.tsx Updates helper to call AuthenticationService.login({ username, password }).
packages/api/src/services/tracking/test/tracking.service.spec.ts Updates tests to match the new login signature.
packages/api/src/services/domain/security/test/security.service.spec.ts Updates tests to match the new login signature.
packages/api/src/services/domain/security/test/authentication.service.spec.ts Updates tests for new login signature (but still has an async assertion issue).
packages/api/src/services/domain/security/authentication.service.ts Changes login to accept optional LoginData and select/set strategy accordingly.
packages/api/src/services/domain/security/authentication-storage.service.ts Splits token-type detection into isGDBToken vs isOpenIDToken.
packages/api/src/services/domain/security/auth-strategy-resolver.ts Adds setStrategy and enhances resolution logic based on user/token state.

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

Comment thread packages/workbench/src/app/pages/login/login-page.component.html
Comment thread packages/workbench/src/app/pages/login/login-page.component.ts
Comment thread packages/api/src/services/domain/security/test/authentication.service.spec.ts Outdated
Comment thread packages/api/src/services/domain/security/authentication.service.ts
@yordanalexandrov yordanalexandrov force-pushed the gdb-14665-fix-regression-allow-multiple-login-strategies branch from 6ca1f21 to 6e4646b Compare June 4, 2026 11:30
## What
Refactored authentication logic to support multiple login strategies based on user tokens.

## Why
This change addresses a regression that prevented the application from correctly handling multiple authentication strategies, improving user experience and flexibility in login options.

## How
- Introduced `setStrategy` method to manually set authentication strategies.
- Updated `resolveStrategy` to return the appropriate strategy based on user authentication state.
- Modified login component to show correct multiple login strategies.
- Modified `login` method of `AuthenticationService` to set appropriate strategy based on login details.
- Adjusted tests to reflect changes in the login method signature.
- As the login manually forces a strategy, the `BaseGdbLoginStrategy` is no longer needed and the login method can go th the `GdbTokenAuthStrategy` directly. No need to update strategy after login either.
@yordanalexandrov yordanalexandrov force-pushed the gdb-14665-fix-regression-allow-multiple-login-strategies branch from 6e4646b to c70b894 Compare June 4, 2026 11:48
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 4, 2026


private assertIsLoginData(value: unknown): asserts value is LoginData {
if (typeof value !== 'object' || value === null || !('username' in value) || !('password' in value)) {
throw new Error('Invalid login data. Expected an object with username and password properties.');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Create custom error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The above is minor, but in general I wonder do we really need this runtime validation here?

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