Skip to content

Allow authenticted users to view sso login page#58

Open
balsama wants to merge 3 commits into
mainfrom
sso403
Open

Allow authenticted users to view sso login page#58
balsama wants to merge 3 commits into
mainfrom
sso403

Conversation

@balsama
Copy link
Copy Markdown
Contributor

@balsama balsama commented May 22, 2026

Motivation

Trials links to /acquia-id/sso. But once a user is logged in and has a token, that route will return a 403. This was by design and mimics the behavior of the /user/login route from core. But given that Trials links directly to it, we should account for it.

Proposed changes

Alternatives considered

In HaaS, the user is linked to an edit page and redirected to login if they're not. So we could do that. But since this is supposed to be a more general solution, I think it makes sense to handle people who arrive on acquia-id/sso more gracefully.

Testing steps

Current behavior:

  1. Open a browser and navigate to: <DRUPAL_CMS_TRIAL_URL>/acquia-id/sso?destination=/admin/dashboard
  2. Observe that the first visit succeeds — user is redirected to /admin/dashboard
  3. Navigate to the same URL again: <DRUPAL_CMS_TRIAL_URL>/acquia-id/sso?destination=/admin/dashboard in new tab
  4. Observe: Access Denied error is returned on the second request

New behavior:

  1. Open a browser and navigate to: <DRUPAL_CMS_TRIAL_URL>/acquia-id/sso?destination=/admin/dashboard
  2. Observe that the first visit succeeds — user is redirected to /admin/dashboard
  3. Navigate to the same URL again: <DRUPAL_CMS_TRIAL_URL>/acquia-id/sso?destination=/admin/dashboard in new tab
  4. Observe: User is redirected to /admin/dashboard
  5. Navigate to: <DRUPAL_CMS_TRIAL_URL>/acquia-id/sso (no destination param)
  6. User is shown a message indicating they are already logged in with a link to the frontpage.

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 changes the Acquia ID SSO route so authenticated users with an existing token are allowed through route access and receive an “already logged in” experience instead of a 403.

Changes:

  • Injects the current user into OAuth2Controller.
  • Adds an authenticated-with-token branch that returns a render array with a Continue link.
  • Updates the kernel access test to expect the SSO route to be allowed for authenticated users with tokens.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docroot/modules/custom/acquia_id/src/Controller/OAuth2Controller.php Allows SSO route access and adds already-logged-in handling for authenticated users with stored tokens.
docroot/modules/custom/acquia_id/tests/src/Kernel/Controller/OAuth2ControllerTest.php Updates the route access expectation for authenticated users with tokens.

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

Comment thread docroot/modules/custom/acquia_id/src/Controller/OAuth2Controller.php Outdated
Comment thread docroot/modules/custom/acquia_id/src/Controller/OAuth2Controller.php Outdated
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

2 participants