alpha
Login
or
Join now
alice.pds.demo.boltless.dev
/
core
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
2
Pulls
1
Pipelines
legit: validate public keys
author
Anirudh Oppiliappan
date
2 years ago
(Jan 27, 2025, 4:13 PM +0200)
commit
b1a88a75
b1a88a75279e1a0d5a6aeb91fe98404f64a374c7
parent
3da50c91
3da50c914acde2b2606385b80640d2ba527eacaf
+10
1 changed file
Expand all
Collapse all
Unified
Split
legit
routes
routes.go
+10
legit/routes/routes.go
View file
Reviewed
···
19
19
"github.com/icyphox/bild/legit/db"
20
20
"github.com/icyphox/bild/legit/git"
21
21
"github.com/russross/blackfriday/v2"
22
22
+
"golang.org/x/crypto/ssh"
22
23
)
23
24
24
25
type Handle struct {
···
435
436
}
436
437
437
438
func (h *Handle) Keys(w http.ResponseWriter, r *http.Request) {
439
439
+
438
440
switch r.Method {
439
441
case http.MethodGet:
440
442
// TODO: fetch keys from db
···
445
447
case http.MethodPut:
446
448
key := r.FormValue("key")
447
449
name := r.FormValue("name")
450
450
+
451
451
+
_, _, _, _, err := ssh.ParseAuthorizedKey([]byte(key))
452
452
+
if err != nil {
453
453
+
h.WriteOOBNotice(w, "keys", "Invalid public key. Check your formatting and try again.")
454
454
+
log.Printf("parsing public key: %s", err)
455
455
+
return
456
456
+
}
457
457
+
448
458
// TODO: add did here
449
459
if err := h.db.AddPublicKey("did:ashtntnashtx", name, key); err != nil {
450
460
h.WriteOOBNotice(w, "keys", "Failed to add key")