This commit is contained in:
parent
e3a97170a9
commit
f4e876a4b1
10 changed files with 191 additions and 20 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue