Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions apps/frontend/src/components/ui/auth/SignIn.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<template>
<div v-if="subtleLauncherRedirectUri">
<iframe
:src="subtleLauncherRedirectUri"
class="fixed left-0 top-0 z-[9999] m-0 h-full w-full border-0 p-0"
></iframe>
</div>
<div
v-else
class="universal-card mx-auto flex w-full max-w-[27rem] flex-col gap-6 border border-solid border-surface-5 !p-6"
>
<template v-if="flow && !subtleLauncherRedirectUri">
<template v-if="flow">
<div class="flex flex-col items-end gap-4">
<div class="flex flex-col gap-1.5">
<label for="two-factor-code">
Expand Down Expand Up @@ -196,7 +189,6 @@ interface AuthGlobals {
}

interface Props {
subtleLauncherRedirectUri?: string
flow?: string
redirectTarget?: string
routeQuery?: LocationQuery
Expand All @@ -208,7 +200,6 @@ interface Props {
}

const {
subtleLauncherRedirectUri = '',
flow = '',
redirectTarget = '',
routeQuery = {},
Expand Down
19 changes: 4 additions & 15 deletions apps/frontend/src/pages/auth/create/oauth.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<template>
<div v-if="subtleLauncherRedirectUri">
<iframe
:src="subtleLauncherRedirectUri"
class="fixed left-0 top-0 z-[9999] m-0 h-full w-full border-0 p-0"
></iframe>
</div>
<CreateAccountView
v-else
v-model:date-of-birth="dateOfBirth"
v-model:username="username"
v-model:token="token"
Expand Down Expand Up @@ -109,7 +102,6 @@ const dateOfBirth = ref('')
const username = ref(defaultUsername.value)
const token = ref('')
const subscribe = ref(false)
const subtleLauncherRedirectUri = ref<string>()

const captcha = ref<{ reset?: () => void } | null>(null)
const setCaptchaRef = (captchaRef: unknown) => {
Expand Down Expand Up @@ -166,13 +158,10 @@ async function finishSignIn(sessionToken?: string | null) {

const redirectUrl = `${getLauncherRedirectUrl(route)}/?code=${token}`

if (redirectUrl.startsWith('https://launcher-files.modrinth.com/')) {
await navigateTo(redirectUrl, {
external: true,
})
} else {
subtleLauncherRedirectUri.value = redirectUrl
}
await navigateTo(redirectUrl, {
external: true,
replace: true,
})

return
}
Expand Down
20 changes: 4 additions & 16 deletions apps/frontend/src/pages/auth/sign-in.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
v-model:password="password"
v-model:token="token"
v-model:two-factor-code="twoFactorCode"
:subtle-launcher-redirect-uri="subtleLauncherRedirectUri"
:flow="flow"
:redirect-target="redirectTarget"
:route-query="route.query"
Expand Down Expand Up @@ -114,7 +113,6 @@ if (route.query.state !== undefined) {
}

const redirectTarget = getQueryString(route.query.redirect)
const subtleLauncherRedirectUri = ref<string>()

if (route.query.code) {
await finishSignIn()
Expand Down Expand Up @@ -230,20 +228,10 @@ async function finishSignIn(sessionToken?: string | null) {

const redirectUrl = `${getLauncherRedirectUrl(route)}/?code=${token}`

if (redirectUrl.startsWith('https://launcher-files.modrinth.com/')) {
await navigateTo(redirectUrl, {
external: true,
})
} else {
// When redirecting to localhost, the auth token is very visible in the URL to the user.
// While we could make it harder to find with a POST request, such is security by obscurity:
// the user and other applications would still be able to sniff the token in the request body.
// So, to make the UX a little better by not changing the displayed URL, while keeping the
// token hidden from very casual observation and keeping the protocol as close to OAuth's
// standard flows as possible, let's execute the redirect within an iframe that visually
// covers the entire page.
subtleLauncherRedirectUri.value = redirectUrl
}
await navigateTo(redirectUrl, {
external: true,
replace: true,
})

return
}
Expand Down
Loading