Repository navigation
Allow redirect URL to be different than app origin #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||
| import { expect } from '@playwright/test' | ||||||||
| import type { KeycloakInitOptions } from '../../lib/keycloak.js' | ||||||||
| import { REDIRECT_SERVICE_URL } from '../support/common.ts' | ||||||||
| import { createTestBed, test } from '../support/testbed.ts' | ||||||||
|
|
||||||||
| /** | ||||||||
| * This test simulates a scenario where a user has configured the adapter to use a redirect URL | ||||||||
| * on a different domain than the application (e.g. a redirect service), which then redirects | ||||||||
| * back to the actual application. This redirect sits between the application and the auth server. | ||||||||
| */ | ||||||||
| test('logs in with a redirect service between the application and auth server', async ({ page, appUrl, authServerUrl }) => { | ||||||||
| const { executor, updateClient } = await createTestBed(page, { appUrl, authServerUrl }) | ||||||||
|
|
||||||||
| // Update the client to allow redirecting to the redirect service. | ||||||||
| await updateClient({ | ||||||||
| redirectUris: [`${appUrl.origin}/*`, `${REDIRECT_SERVICE_URL.origin}/*`] | ||||||||
| }) | ||||||||
|
|
||||||||
| // Build the redirect URL that points to the redirect service instead of the application. | ||||||||
| const redirectUrl = new URL(REDIRECT_SERVICE_URL) | ||||||||
| redirectUrl.searchParams.set('origin', appUrl.origin) | ||||||||
|
|
||||||||
| const initOptions: KeycloakInitOptions = { | ||||||||
| ...executor.defaultInitOptions(), | ||||||||
| redirectUri: redirectUrl.toString() | ||||||||
| } | ||||||||
|
|
||||||||
| // Initially, no user should be authenticated. | ||||||||
| expect(await executor.initializeAdapter(initOptions)).toBe(false) | ||||||||
| expect(await executor.isAuthenticated()).toBe(false) | ||||||||
|
|
||||||||
| await executor.login() | ||||||||
| await executor.submitLoginForm() | ||||||||
|
|
||||||||
| // After login, the user should be authenticated. | ||||||||
| expect(await executor.initializeAdapter(initOptions)).toBe(true) | ||||||||
| expect(await executor.isAuthenticated()).toBe(true) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe check that the final url is the app one:
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, navigation happens in the background implicitly. So there should be no need to do this. That said, I kind of want to refactor this, so that any navigation is handled explicitly. However, that is a topic separate from this PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logged an issue for it #232 |
||||||||
| }) | ||||||||
Uh oh!
There was an error while loading. Please reload this page.