Current state
All checks were successful
/ docker (push) Successful in 4m7s

This commit is contained in:
Melody Becker 2025-04-13 20:10:19 +02:00
parent e3a97170a9
commit f4e876a4b1
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
10 changed files with 191 additions and 20 deletions

View file

@ -4,6 +4,8 @@ import (
"crypto/rand"
"database/sql"
"encoding/json"
"encoding/pem"
"fmt"
"net/http"
"strconv"
"time"
@ -173,6 +175,33 @@ func deleteUser(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
func returnKeypair(w http.ResponseWriter, r *http.Request) {
id := r.FormValue("id")
user, err := dbgen.User.Where(dbgen.User.ID.Eq(id)).First()
if err != nil {
return
}
err = shared.SanityCheckX509dRsaKeys(user.PublicKeyRsa, user.PrivateKeyRsa)
if err != nil {
hlog.FromRequest(r).Error().Err(err).Msg("Sanity check failed")
}
privKeyBlock := pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: user.PrivateKeyRsa,
}
if err != nil {
hlog.FromRequest(r).Error().Err(err).Msg("Sanity check failed")
}
privKeyPem := pem.EncodeToMemory(&privKeyBlock)
pubKeyPen := []byte(shared.KeyBytesToPem(user.PublicKeyRsa))
err = shared.SanityCheckPemdRsaKeys(pubKeyPen, privKeyPem)
if err != nil {
hlog.FromRequest(r).Error().Err(err).Msg("Pem Sanity check failed")
}
fmt.Fprintf(w, "%s\n\n%s", privKeyPem, pubKeyPen)
}
func issueUserImport(w http.ResponseWriter, r *http.Request) {
target := r.FormValue("target")
_, err := activitypub.ImportRemoteAccount(target)