PGP import feature
This commit is contained in:
parent
9436220685
commit
de4bb43e86
12 changed files with 547 additions and 0 deletions
|
|
@ -125,6 +125,7 @@
|
|||
<img class="rounded-circle" src="//photos.cri.epita.fr/square/{$user.login}" alt="Menu" style="margin: -0.75em 0; max-height: 2.5em; border: 2px solid white;">
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" class:active={rroute === 'keys'} href="keys">Clef PGP</a></li>
|
||||
<li><a class="dropdown-item" class:active={rroute === 'help'} href="help">Besoin d'aide ?</a></li>
|
||||
<li><a class="dropdown-item" class:active={rroute === 'bug-bounty'} href="bug-bounty">Bug Bounty</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
|
|
|||
102
ui/src/routes/keys.svelte
Normal file
102
ui/src/routes/keys.svelte
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<script>
|
||||
import { getKeys, getKey, Key } from '../lib/key';
|
||||
import { user } from '../stores/user';
|
||||
import { ToastsStore } from '../stores/toasts';
|
||||
|
||||
let keysP = getKeys();
|
||||
|
||||
let mykey = "";
|
||||
let holdSubmit = false;
|
||||
|
||||
async function submitPGPKey() {
|
||||
holdSubmit = true;
|
||||
let key = new Key({ type: 'pgp', key: mykey });
|
||||
key.save().then(() => {
|
||||
keysP = getKeys();
|
||||
holdSubmit = false;
|
||||
mykey = "";
|
||||
ToastsStore.addToast({
|
||||
msg: "Votre nouvelle clef a bien été enregistrée.",
|
||||
color: "success",
|
||||
title: "Clef PGP",
|
||||
});
|
||||
}, (error) => {
|
||||
submitInProgress = false;
|
||||
ToastsStore.addErrorToast({
|
||||
msg: "Une erreur s'est produite durant l'envoi de votre clef : " + error + "\nVeuillez réessayer dans quelques instants.",
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2>Ma clef PGP</h2>
|
||||
|
||||
<p class="lead">
|
||||
Vos rendus doivent être signés avec votre clef PGP.
|
||||
</p>
|
||||
|
||||
{#await keysP}
|
||||
Veuillez patienter
|
||||
{:then keys}
|
||||
{#if keys && keys.length > 0}
|
||||
<p>
|
||||
Vous avez actuellement enregistré {#if keys.length > 1}les clefs publiques suivantes{:else}la clef publique suivante{/if} :
|
||||
</p>
|
||||
{#each keys as keyid}
|
||||
{#await getKey(keyid)}
|
||||
Veuillez patienter
|
||||
{:then key}
|
||||
<div class="alert alert-dark d-flex justify-content-between">
|
||||
<div class="d-flex">
|
||||
<div class="d-flex flex-column justify-content-center me-3">
|
||||
<i class="bi bi-key-fill display-4"></i>
|
||||
<div class="text-center badge bg-light" style="font-variant: small-caps;">
|
||||
{key.type}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
Adresse électronique : <strong class="badge bg-secondary">{key.infos.email}</strong><br>
|
||||
Nom : <strong>{key.infos.identity}</strong> {#if key.infos.comment}<span class="fst-italic">({key.infos.identity})</span>{/if}<br>
|
||||
Key ID : <strong>{key.infos.keyid}</strong><br>
|
||||
Date de la signature : <strong>{key.infos.creation}</strong><br>
|
||||
Clef expirée : <span class="badge" class:bg-danger={key.infos.sigexpired} class:bg-info={!key.infos.sigexpired}>{key.infos.sigexpired?"oui":"non"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-column justify-content-center">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-danger float-end"
|
||||
on:click={() => key.delete().then(() => { keysP = getKeys(); })}
|
||||
>
|
||||
Supprimer la clef
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/await}
|
||||
{/each}
|
||||
{:else}
|
||||
<p>
|
||||
Afin de pouvoir les vérifier, veuillez envoyer votre clef publique dans le formulaire ci-dessous.
|
||||
Utilisez la commande <code>gpg --export --armor {#if $user}{$user.email}{:else}login_x@epita.fr{/if}</code> :
|
||||
</p>
|
||||
|
||||
<form class="container" on:submit|preventDefault={submitPGPKey}>
|
||||
<textarea
|
||||
class="form-control"
|
||||
rows="10"
|
||||
bind:value={mykey}
|
||||
placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
QmllbiBzw7tyIHF1ZSBjJ2VzdCB1bmUgY2hhw65uZSBxdWkgdmV1dCBkaXJlIHF1
|
||||
ZWxxdWUgY2hvc2UK ...
|
||||
-----END PGP PUBLIC KEY BLOCK-----"
|
||||
></textarea>
|
||||
<button
|
||||
type="submit"
|
||||
class="mt-2 btn btn-primary"
|
||||
>
|
||||
Enregistrer cette clef PGP
|
||||
</button>
|
||||
</form>
|
||||
{/if}
|
||||
{/await}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import UserKeys from '../../../components/UserKeys.svelte';
|
||||
import UserSurveys from '../../../components/UserSurveys.svelte';
|
||||
import { user } from '../../../stores/user';
|
||||
import { getSurveys } from '../../../lib/surveys';
|
||||
|
|
@ -102,6 +103,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Clefs
|
||||
</h3>
|
||||
</div>
|
||||
<UserKeys
|
||||
{student}
|
||||
/>
|
||||
<div class="card-header">
|
||||
<button
|
||||
class="btn btn-secondary float-end"
|
||||
|
|
|
|||
Reference in a new issue