Skip to content

Commit

Permalink
Use new SAML login paths in frontend and e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekkio committed Dec 11, 2024
1 parent 5fda7a9 commit 8260346
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions frontend/src/citizen-frontend/navigation/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ export const logoutUrl = `/api/citizen/auth/logout?RelayState=/`

export const getWeakLoginUri = (
url = `${window.location.pathname}${window.location.search}${window.location.hash}`
) =>
`/api/application/auth/evaka-customer/login?RelayState=${encodeURIComponent(url)}`
) => `/api/citizen/auth/keycloak/login?RelayState=${encodeURIComponent(url)}`

export const getStrongLoginUri = (
url = `${window.location.pathname}${window.location.search}${window.location.hash}`
) => `/api/application/auth/saml/login?RelayState=${encodeURIComponent(url)}`
) => `/api/citizen/auth/sfi/login?RelayState=${encodeURIComponent(url)}`

export const headerHeightDesktop = 80
export const headerHeightMobile = 60
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/e2e-test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const config = {
env('BROWSER', parseEnum(['chromium', 'firefox', 'webkit'] as const)) ??
'chromium'
},
apiUrl: `${browserUrl}/api/internal`,
citizenApiUrl: `${browserUrl}/api/application`,
apiUrl: `${browserUrl}/api`,
adminUrl: `${browserUrl}/employee/applications`,
employeeUrl: `${browserUrl}/employee`,
employeeLoginUrl: `${browserUrl}/employee/login`,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/e2e-test/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function enduserLogin(page: Page, person: DevPerson) {
throw new Error('Person does not have an SSN: cannot login')
}

const authUrl = `${config.citizenApiUrl}/auth/saml/login/callback?RelayState=%2Fapplications`
const authUrl = `${config.apiUrl}/citizen/auth/sfi/login/callback?RelayState=%2Fapplications`
if (!page.url.startsWith(config.enduserUrl)) {
// We must be in the correct domain to be able to fetch()
await page.goto(config.enduserLoginUrl)
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function employeeLogin(
email?: string | null
}
) {
const authUrl = `${config.apiUrl}/auth/saml/login/callback?RelayState=%2Femployee`
const authUrl = `${config.apiUrl}/employee/auth/ad/login/callback?RelayState=%2Femployee`
const preset = JSON.stringify({
externalId,
firstName,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/employee-frontend/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const redirectUri = (() => {
}${searchParams}${window.location.hash}`
})()

export function getLoginUrl(type: 'evaka' | 'saml' = 'saml') {
export function getLoginUrl(type: 'ad' | 'keycloak' = 'ad') {
const relayState = encodeURIComponent(redirectUri)
return `/api/internal/auth/${type}/login?RelayState=${relayState}`
return `/api/employee/auth/${type}/login?RelayState=${relayState}`
}

export async function getAuthStatus(): Promise<AuthStatus<User>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ function Login({ error }: Props) {
{i18n.login.subtitle}
</Title>
<Center>
<LinkButton data-qa="login-btn" href={getLoginUrl('saml')}>
<LinkButton data-qa="login-btn" href={getLoginUrl('ad')}>
<span>{i18n.login.loginAD}</span>
</LinkButton>
<Gap horizontal />
<LinkButton data-qa="login-btn" href={getLoginUrl('evaka')}>
<LinkButton data-qa="login-btn" href={getLoginUrl('keycloak')}>
<span>{i18n.login.loginEvaka}</span>
</LinkButton>
</Center>
Expand Down

0 comments on commit 8260346

Please sign in to comment.