mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 01:06:15 -04:00
feat(new-tool): added a basic auth generator
This commit is contained in:
parent
08ce407a01
commit
bdee93a9e4
3 changed files with 71 additions and 1 deletions
48
src/tools/basic-auth-generator/basic-auth-generator.vue
Normal file
48
src/tools/basic-auth-generator/basic-auth-generator.vue
Normal file
|
@ -0,0 +1,48 @@
|
|||
<template>
|
||||
<div>
|
||||
<n-form-item label="Username">
|
||||
<n-input v-model:value="username" placeholder="Your username..." clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="Password">
|
||||
<n-input
|
||||
v-model:value="password"
|
||||
placeholder="Your password..."
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
clearable
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<br />
|
||||
<n-card>
|
||||
<n-statistic label="Authorization header:" class="header">
|
||||
<n-scrollbar x-scrollable style="max-width: 550px; margin-bottom: -10px; padding-bottom: 10px" trigger="none">
|
||||
{{ header }}
|
||||
</n-scrollbar>
|
||||
</n-statistic>
|
||||
</n-card>
|
||||
<br />
|
||||
<n-space justify="center">
|
||||
<n-button secondary @click="copy">Copy header</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const header = computed(() => `Authorization: Basic ${window.btoa(`${username.value}:${password.value}`)}`);
|
||||
|
||||
const { copy } = useCopy({ source: header, text: 'Header copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.n-statistic-value__content) {
|
||||
font-family: monospace;
|
||||
font-size: 17px !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
21
src/tools/basic-auth-generator/index.ts
Normal file
21
src/tools/basic-auth-generator/index.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { PasswordRound } from '@vicons/material';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Basic auth generator',
|
||||
path: '/basic-auth-generator',
|
||||
description: 'Generate a base64 basic auth header from an username and a password.',
|
||||
keywords: [
|
||||
'basic',
|
||||
'auth',
|
||||
'generator',
|
||||
'username',
|
||||
'password',
|
||||
'base64',
|
||||
'authentication',
|
||||
'header',
|
||||
'authorization',
|
||||
],
|
||||
component: () => import('./basic-auth-generator.vue'),
|
||||
icon: PasswordRound,
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue