Conversation
There was a problem hiding this comment.
Pull request overview
Fixes external authentication post-login redirect handling by correctly propagating the UI redirect route through both top-level redirectUrl parameters and nested OIDC/ORCID-style redirect_uri callback URLs.
Changes:
- Update
AuthService.getExternalServerRedirectUrl()to parse & rewrite external login URLs (including nestedredirect_uri) while preserving query/hash. - Add unit tests covering top-level
redirectUrlreplacement, nestedredirect_uriinjection, and preservation of nested query params.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/app/core/auth/auth.service.ts |
Reworks external redirect URL rewriting to support nested callback (redirect_uri) scenarios for OIDC/ORCID. |
src/app/core/auth/auth.service.spec.ts |
Adds specs validating the new redirect URL rewriting behavior. |
Comments suppressed due to low confidence (1)
src/app/core/auth/auth.service.ts:30
Cookiesimport was removed, but this file still referencesCookies.CookieAttributes(e.g., when setting cookie options). This will cause a TypeScript compile error (Cannot find name 'Cookies'). Re-add the import as a type-only import (e.g.,import type Cookies from 'js-cookie') or switch the annotations to use the project’s cookie option type without relying onCookieshere.
Store,
} from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import {
Observable,
of,
} from 'rxjs';
import {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
b347ba7 to
fc49ae9
Compare
|
@jesielviana Thank you for creating this! You may have seen already, but note it's currently failing one of the unit tests. We can try to port this since it was reported on 8.x, and I added 7.x in case that works as well. |
|
Hey @jesielviana, I was wondering if we maybe could fix the root cause of this issue, having two different redirect URL param names? Would it be an option use only |
|
Good point @tinsch, I haven’t tried that approach yet. If you’d like to give it a try, that would be great. |
References
Description
This change fixes the post-login redirect behavior for external authentication providers that rely on a nested callback URL, such as OIDC and ORCID.
Instructions for Reviewers
Root Cause
The logic in AuthService.getExternalServerRedirectUrl() only handled this case:
.../login?redirectUrl=<ui-route>It did not handle this case:
https://provider.example/authorize?...&redirect_uri=https://rest.example/api/authn/oidcAs a result, OIDC/ORCID callbacks reached the backend without the intended redirectUrl.
Implementation
The redirect URL handling was updated in src/app/core/auth/auth.service.ts to support three scenarios:
The implementation also preserves existing query parameters already present on the nested redirect_uri.
List of changes in this PR:
Updated getExternalServerRedirectUrl() so that it:
Added coverage for:
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.