View auth factors in admin panel

This commit is contained in:
LittleSheep 2024-07-04 23:12:43 +08:00
parent 13c26486b6
commit 8c7f255473
7 changed files with 730 additions and 303 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
#n:public #n:public
!<md> [7430, 0, null, null, -2147483648, -2147483648] !<md> [10102, 0, null, null, -2147483648, -2147483648]

75
.idea/workspace.xml generated
View File

@ -4,17 +4,14 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Admin check users' auth factor"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix clear function doesn't real clear items in slice">
<change afterPath="$PROJECT_DIR$/web/src/components/admin/UserAssignPermsPanel.vue" afterDir="false" /> <change afterPath="$PROJECT_DIR$/web/src/components/admin/UserFactorPanel.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/src/components/admin/UserDetailPanel.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/src/layouts/administrator.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/src/views/admin/dashboard.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/src/views/admin/users.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/src/components/navigation/AppBar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/components/navigation/AppBar.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/web/src/components/admin/UserAssignPermsPanel.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/components/admin/UserAssignPermsPanel.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/src/layouts/user-center.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/layouts/user-center.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/web/src/components/admin/UserDetailPanel.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/components/admin/UserDetailPanel.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/src/router/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/router/index.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/web/src/views/admin/users.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/views/admin/users.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/src/views/security.vue" beforeDir="false" afterPath="$PROJECT_DIR$/web/src/views/security.vue" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -49,41 +46,41 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;DefaultGoTemplateProperty&quot;: &quot;Go File&quot;, "DefaultGoTemplateProperty": "Go File",
&quot;Go Build.Backend.executor&quot;: &quot;Run&quot;, "Go Build.Backend.executor": "Run",
&quot;Go 构建.Backend.executor&quot;: &quot;Run&quot;, "Go 构建.Backend.executor": "Run",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;RunOnceActivity.go.formatter.settings.were.checked&quot;: &quot;true&quot;, "RunOnceActivity.go.formatter.settings.were.checked": "true",
&quot;RunOnceActivity.go.migrated.go.modules.settings&quot;: &quot;true&quot;, "RunOnceActivity.go.migrated.go.modules.settings": "true",
&quot;RunOnceActivity.go.modules.automatic.dependencies.download&quot;: &quot;true&quot;, "RunOnceActivity.go.modules.automatic.dependencies.download": "true",
&quot;RunOnceActivity.go.modules.go.list.on.any.changes.was.set&quot;: &quot;true&quot;, "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
&quot;git-widget-placeholder&quot;: &quot;master&quot;, "git-widget-placeholder": "master",
&quot;go.import.settings.migrated&quot;: &quot;true&quot;, "go.import.settings.migrated": "true",
&quot;go.sdk.automatically.set&quot;: &quot;true&quot;, "go.sdk.automatically.set": "true",
&quot;last_opened_file_path&quot;: &quot;/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/src/views&quot;, "last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/src/components/admin",
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, "node.js.detected.package.eslint": "true",
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.eslint": "(autodetect)",
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, "nodejs_package_manager_path": "npm",
&quot;run.code.analysis.last.selected.profile&quot;: &quot;pProject Default&quot;, "run.code.analysis.last.selected.profile": "pProject Default",
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;, "settings.editor.selected.configurable": "preferences.pluginManager",
&quot;ts.external.directory.path&quot;: &quot;/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/node_modules/typescript/lib&quot;, "ts.external.directory.path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/node_modules/typescript/lib",
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; "vue.rearranger.settings.migration": "true"
}, },
&quot;keyToStringList&quot;: { "keyToStringList": {
&quot;DatabaseDriversLRU&quot;: [ "DatabaseDriversLRU": [
&quot;postgresql&quot; "postgresql"
] ]
} }
}</component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/web/src/components/admin" />
<recent name="$PROJECT_DIR$/web/src/views" /> <recent name="$PROJECT_DIR$/web/src/views" />
<recent name="$PROJECT_DIR$/pkg/internal/server/api" /> <recent name="$PROJECT_DIR$/pkg/internal/server/api" />
<recent name="$PROJECT_DIR$/web" /> <recent name="$PROJECT_DIR$/web" />
<recent name="$PROJECT_DIR$/pkg/services" /> <recent name="$PROJECT_DIR$/pkg/services" />
<recent name="$PROJECT_DIR$/pkg/server/ui" />
</key> </key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/web/src/views/flow" /> <recent name="$PROJECT_DIR$/web/src/views/flow" />
@ -160,8 +157,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":sparkles: Edit, delete current status" />
<MESSAGE value=":bug: Fix clear status affected the statutes cleared before" />
<MESSAGE value=":sparkles: Get self-current status API" /> <MESSAGE value=":sparkles: Get self-current status API" />
<MESSAGE value=":sparkles: Get myself current status API" /> <MESSAGE value=":sparkles: Get myself current status API" />
<MESSAGE value=":bug: Fix miscall function" /> <MESSAGE value=":bug: Fix miscall function" />
@ -185,7 +180,9 @@
<MESSAGE value=":sparkles: Admin force confirm account" /> <MESSAGE value=":sparkles: Admin force confirm account" />
<MESSAGE value=":sparkles: Admin notify one user" /> <MESSAGE value=":sparkles: Admin notify one user" />
<MESSAGE value=":sparkles: Admin check users' auth factor" /> <MESSAGE value=":sparkles: Admin check users' auth factor" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Admin check users' auth factor" /> <MESSAGE value=":sparkles: Admin panel &amp; users, users' permissions management" />
<MESSAGE value=":bug: Fix clear function doesn't real clear items in slice" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix clear function doesn't real clear items in slice" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -1,5 +1,5 @@
<template> <template>
<v-dialog class="max-w-[720px]" :model-value="data != null" @update:model-value="(val) => !val && emits('close')"> <v-dialog class="max-w-[720px]" :model-value="props.data != null" @update:model-value="(val) => !val && emits('close')">
<template v-slot:default="{ isActive }"> <template v-slot:default="{ isActive }">
<v-card title="Assign permissions" :subtitle="`To user @${props.data?.name}`" :loading="submitting"> <v-card title="Assign permissions" :subtitle="`To user @${props.data?.name}`" :loading="submitting">
<v-card-text> <v-card-text>

View File

@ -1,5 +1,5 @@
<template> <template>
<v-dialog class="max-w-[720px]" :model-value="data != null" @update:model-value="(val) => !val && emits('close')"> <v-dialog class="max-w-[720px]" :model-value="props.data != null" @update:model-value="(val) => !val && emits('close')">
<template v-slot:default="{ isActive }"> <template v-slot:default="{ isActive }">
<v-card :title="`User @${props.data?.name}`"> <v-card :title="`User @${props.data?.name}`">
<v-card-text> <v-card-text>

View File

@ -0,0 +1,74 @@
<template>
<v-dialog class="max-w-[720px]" :model-value="props.data != null"
@update:model-value="(val) => !val && emits('close')"
:loading="reverting">
<template v-slot:default="{ isActive }">
<v-card title="Auth Factors" :subtitle="`Of user @${props.data?.name}`">
<v-card-text>
<v-sheet elevation="2" rounded="lg">
<v-table density="compact">
<thead>
<tr>
<th class="text-left">
Name
</th>
<th class="text-left">
Secret
</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in factors"
:key="item.name"
>
<td class="w-1/2">{{ item.id }}</td>
<td class="w-1/2"><code>{{ item.secret }}</code></td>
</tr>
</tbody>
</v-table>
</v-sheet>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
text="Close"
@click="isActive.value = false"
></v-btn>
</v-card-actions>
</v-card>
</template>
</v-dialog>
</template>
<script setup lang="ts">
import { ref, watch } from "vue"
import { request } from "@/scripts/request"
const props = defineProps<{ data: any }>()
const emits = defineEmits(["close", "error"])
const reverting = ref(false)
const factors = ref<any[]>([])
async function load() {
reverting.value = true
const res = await request(`/api/admin/users/${props.data.id}/factors`)
if (res.status !== 200) {
emits("error", await res.text())
} else {
factors.value = await res.json()
}
reverting.value = false
}
watch(props, (v) => {
if (v.data != null) {
factors.value = []
load()
}
}, { immediate: true, deep: true })
</script>

View File

@ -52,6 +52,18 @@
/> />
</template> </template>
</v-tooltip> </v-tooltip>
<v-tooltip text="View Auth Factors">
<template #activator="{ props }">
<v-btn
v-bind="props"
variant="text"
size="x-small"
color="warning"
icon="mdi-lock"
@click="viewingFactorUser = item"
/>
</template>
</v-tooltip>
</td> </td>
</tr> </tr>
</template> </template>
@ -61,6 +73,7 @@
<user-assign-perms-panel :data="assigningPermUser" @close="assigningPermUser = null" <user-assign-perms-panel :data="assigningPermUser" @close="assigningPermUser = null"
@success="readUsers(pagination)" @success="readUsers(pagination)"
@error="val => error = val" /> @error="val => error = val" />
<user-factor-panel :data="viewingFactorUser" @close="viewingFactorUser = null" @error="val => error = val" />
<v-snackbar :timeout="3000" :model-value="error != null" @update:model-value="_ => error = null"> <v-snackbar :timeout="3000" :model-value="error != null" @update:model-value="_ => error = null">
{{ error }} {{ error }}
@ -74,12 +87,14 @@ import { request } from "@/scripts/request"
import { getAtk } from "@/stores/userinfo" import { getAtk } from "@/stores/userinfo"
import UserDetailPanel from "@/components/admin/UserDetailPanel.vue" import UserDetailPanel from "@/components/admin/UserDetailPanel.vue"
import UserAssignPermsPanel from "@/components/admin/UserAssignPermsPanel.vue" import UserAssignPermsPanel from "@/components/admin/UserAssignPermsPanel.vue"
import UserFactorPanel from "@/components/admin/UserFactorPanel.vue"
const error = ref<string | null>(null) const error = ref<string | null>(null)
const users = ref<any[]>([]) const users = ref<any[]>([])
const viewingUser = ref<any>(null) const viewingUser = ref<any>(null)
const viewingFactorUser = ref<any>(null)
const assigningPermUser = ref<any>(null) const assigningPermUser = ref<any>(null)
const dataDefinitions: { [id: string]: any[] } = { const dataDefinitions: { [id: string]: any[] } = {