mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-20 15:03:00 +10:00
Depot API & v4 (#298)
* feat: nginx + torrential basics & services system * fix: lint + i18n * fix: update torrential to remove openssl * feat: add torrential to Docker build * feat: move to self hosted runner * fix: move off self-hosted runner * fix: update nginx.conf * feat: torrential cache invalidation * fix: update torrential for cache invalidation * feat: integrity check task * fix: lint * feat: move to version ids * fix: client fixes and client-side checks * feat: new depot apis and version id fixes * feat: update torrential * feat: droplet bump and remove unsafe update functions * fix: lint * feat: v4 featureset: emulators, multi-launch commands * fix: lint * fix: mobile ui for game editor * feat: launch options * fix: lint * fix: remove axios, use $fetch * feat: metadata and task api improvements * feat: task actions * fix: slight styling issue * feat: fix style and lints * feat: totp backend routes * feat: oidc groups * fix: update drop-base * feat: creation of passkeys & totp * feat: totp signin * feat: webauthn mfa/signin * feat: launch selecting ui * fix: manually running tasks * feat: update add company game modal to use new SelectorGame * feat: executor selector * fix(docker): update rust to rust nightly for torrential build (#305) * feat: new version ui * feat: move package lookup to build time to allow for deno dev * fix: lint * feat: localisation cleanup * feat: apply localisation cleanup * feat: potential i18n refactor logic * feat: remove args from commands * fix: lint * fix: lockfile --------- Co-authored-by: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<main class="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8">
|
||||
<DropLogo class="mx-auto h-10 w-auto sm:h-12" />
|
||||
<div class="mx-auto mt-20 max-w-md text-center sm:mt-24">
|
||||
<h1
|
||||
class="mt-4 text-3xl font-semibold tracking-tight text-balance text-white sm:text-4xl"
|
||||
>
|
||||
Two-factor authentication
|
||||
</h1>
|
||||
<p class="mt-6 text-sm font-medium text-pretty text-zinc-400 sm:text-md">
|
||||
Two-factor authentication is enabled on your account. Choose one of the
|
||||
options below to continue.
|
||||
</p>
|
||||
</div>
|
||||
<div class="mx-auto mt-16 flow-root max-w-lg sm:mt-20">
|
||||
<NuxtPage />
|
||||
<div v-if="route.path !== '/auth/mfa'" class="mt-10 flex justify-center">
|
||||
<NuxtLink
|
||||
:href="{ path: '/auth/mfa', query: route.query }"
|
||||
class="text-sm/6 font-semibold text-blue-400"
|
||||
><span aria-hidden="true">←</span> Back to options</NuxtLink
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const route = useRoute();
|
||||
|
||||
definePageMeta({
|
||||
layout: false,
|
||||
});
|
||||
|
||||
useHead({
|
||||
titleTemplate(title) {
|
||||
return title ? `${title} - Drop` : "Two-factor authentication - Drop";
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<ul
|
||||
role="list"
|
||||
class="-mt-6 divide-y divide-white/10 border-b border-white/10"
|
||||
>
|
||||
<li v-if="mfa.includes(MFAMec.TOTP)" class="relative flex gap-x-6 py-6">
|
||||
<div
|
||||
class="flex size-10 flex-none items-center justify-center rounded-lg bg-zinc-800/50 shadow-xs outline-1 -outline-offset-1 outline-white/10"
|
||||
>
|
||||
<ClockIcon class="size-6 text-blue-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="flex-auto">
|
||||
<h3 class="text-sm/6 font-semibold text-white">
|
||||
<NuxtLink :to="{ path: '/auth/mfa/totp', query: route.query }">
|
||||
<span class="absolute inset-0" aria-hidden="true"></span>
|
||||
TOTP
|
||||
</NuxtLink>
|
||||
</h3>
|
||||
<p class="mt-2 text-sm/6 text-zinc-400">
|
||||
Use a one-time code to sign in to your Drop account.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-none self-center">
|
||||
<ChevronRightIcon class="size-5 text-zinc-500" aria-hidden="true" />
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="mfa.includes(MFAMec.WebAuthn)" class="relative flex gap-x-6 py-6">
|
||||
<div
|
||||
class="flex size-10 flex-none items-center justify-center rounded-lg bg-zinc-800/50 shadow-xs outline-1 -outline-offset-1 outline-white/10"
|
||||
>
|
||||
<KeyIcon class="size-6 text-blue-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="flex-auto">
|
||||
<h3 class="text-sm/6 font-semibold text-white">
|
||||
<NuxtLink :to="{ path: '/auth/mfa/webauthn', query: route.query }">
|
||||
<span class="absolute inset-0" aria-hidden="true"></span>
|
||||
WebAuthn
|
||||
</NuxtLink>
|
||||
</h3>
|
||||
<p class="mt-2 text-sm/6 text-zinc-400">
|
||||
Use a passkey, like biometrics, a hardware security device, or other
|
||||
compatible device to sign in to your Drop account.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-none self-center">
|
||||
<ChevronRightIcon class="size-5 text-zinc-500" aria-hidden="true" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ChevronRightIcon,
|
||||
ClockIcon,
|
||||
KeyIcon,
|
||||
} from "@heroicons/vue/24/outline";
|
||||
import { MFAMec } from "~/prisma/client/enums";
|
||||
|
||||
const mfa = await $dropFetch("/api/v1/auth/mfa");
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
if (mfa.length == 0) router.push("/");
|
||||
</script>
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="flex flex-col items-center">
|
||||
<div v-if="success">
|
||||
<CheckIcon class="w-8 h-8 text-green-600" />
|
||||
</div>
|
||||
<div v-else-if="loading">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-8 h-8 text-transparent animate-spin fill-blue-600"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div v-else class="inline-flex gap-x-2">
|
||||
<CodeInput
|
||||
:length="6"
|
||||
placeholder="123456"
|
||||
@complete="(code) => signin(code)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="mt-8 rounded-md bg-red-600/10 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-600">
|
||||
{{ error }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { XCircleIcon } from "@heroicons/vue/20/solid";
|
||||
import { CheckIcon } from "@heroicons/vue/24/outline";
|
||||
import type { FetchError } from "ofetch";
|
||||
|
||||
definePageMeta({
|
||||
layout: false,
|
||||
});
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
const success = ref(false);
|
||||
const error = ref<undefined | string>(undefined);
|
||||
|
||||
async function signin(code: string) {
|
||||
loading.value = true;
|
||||
error.value = undefined;
|
||||
try {
|
||||
await $dropFetch("/api/v1/auth/mfa/totp", {
|
||||
method: "POST",
|
||||
body: { code },
|
||||
});
|
||||
} catch (e) {
|
||||
error.value = (e as FetchError)?.data?.message ?? e;
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
success.value = true;
|
||||
|
||||
await completeSignin();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<div class="flex flex-col items-center">
|
||||
<div v-if="success">
|
||||
<CheckIcon class="w-8 h-8 text-green-600" />
|
||||
</div>
|
||||
<div v-else-if="loading">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-8 h-8 text-transparent animate-spin fill-blue-600"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div v-else class="inline-flex gap-x-2">
|
||||
<LoadingButton :loading="false" @click="() => tryAuthWrapper()">
|
||||
Sign in with WebAuthn</LoadingButton
|
||||
>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="mt-8 rounded-md bg-red-600/10 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-600">
|
||||
{{ error }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { startAuthentication } from "@simplewebauthn/browser";
|
||||
import type { FetchError } from "ofetch";
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
const success = ref(false);
|
||||
const error = ref<undefined | string>(undefined);
|
||||
|
||||
async function tryAuth() {
|
||||
const optionsJSON = await $dropFetch("/api/v1/auth/mfa/webauthn/start", {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
let asseResp;
|
||||
try {
|
||||
asseResp = await startAuthentication({ optionsJSON });
|
||||
} catch {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: "Passkey sign-in cancelled.",
|
||||
});
|
||||
}
|
||||
if (!asseResp)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: "Passkey sign-in cancelled.",
|
||||
});
|
||||
|
||||
await $dropFetch("/api/v1/auth/mfa/webauthn/finish", {
|
||||
method: "POST",
|
||||
body: asseResp,
|
||||
});
|
||||
|
||||
await completeSignin();
|
||||
}
|
||||
|
||||
async function tryAuthWrapper() {
|
||||
loading.value = true;
|
||||
try {
|
||||
await tryAuth();
|
||||
success.value = true;
|
||||
} catch (e) {
|
||||
error.value = (e as FetchError)?.data?.message ?? e;
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
</script>
|
||||
+16
-3
@@ -9,10 +9,18 @@
|
||||
<h2
|
||||
class="mt-8 text-2xl font-bold font-display leading-9 tracking-tight text-zinc-100"
|
||||
>
|
||||
{{ $t("auth.signin.title") }}
|
||||
{{
|
||||
superlevel
|
||||
? "Sign in to access protected action"
|
||||
: $t("auth.signin.title")
|
||||
}}
|
||||
</h2>
|
||||
<p class="mt-2 text-sm leading-6 text-zinc-400">
|
||||
{{ $t("auth.signin.noAccount") }}
|
||||
{{
|
||||
superlevel
|
||||
? "We need you to sign in again for security reasons while attempting to access more sensitive actions."
|
||||
: $t("auth.signin.noAccount")
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -49,11 +57,16 @@ import DropLogo from "~/components/DropLogo.vue";
|
||||
const { t } = useI18n();
|
||||
const enabledAuths = await $dropFetch("/api/v1/auth");
|
||||
|
||||
const route = useRoute();
|
||||
const superlevel = route.query.superlevel;
|
||||
|
||||
definePageMeta({
|
||||
layout: false,
|
||||
});
|
||||
|
||||
useHead({
|
||||
title: t("auth.signin.pageTitle"),
|
||||
title: superlevel
|
||||
? "Sign in to access protected action"
|
||||
: t("auth.signin.pageTitle"),
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user