Commit 21424950 authored by owlo's avatar owlo

uuuuh, fuuuuk

parent 18c9d31d
File deleted
......@@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"strconv"
"strings"
"time"
"golang.org/x/crypto/openpgp"
......@@ -19,48 +18,9 @@ import (
"localtoast.net/localtoast/Ogopogo/libs"
)
func validateSig(signature string) bool {
const prefix = "/home/twotonne/"
const secretKeyring = prefix + "go/src/localtoast.net/localtoast/skey"
const publicKeyring = prefix + "go/src/localtoast.net/localtoast/keys"
const superSecretKeys = prefix + "go/src/localtoast.net/localtoast/sskey"
secRingBuf, err := os.Open(secretKeyring)
defer secRingBuf.Close()
pubRingBuf, err := os.Open(publicKeyring)
defer pubRingBuf.Close()
sskeyRingBuf, err := os.Open(superSecretKeys)
defer sskeyRingBuf.Close()
if err != nil {
fmt.Println("Error grabbing public/private keyring, have you generated keys yet?")
}
entitiesPrivate, err := openpgp.ReadArmoredKeyRing(secRingBuf)
entities, err := openpgp.ReadArmoredKeyRing(pubRingBuf)
sskey, err := openpgp.ReadArmoredKeyRing(sskeyRingBuf)
for i := range entities {
entitiesPrivate = append(entitiesPrivate, entities[i])
}
for i := range sskey {
entitiesPrivate = append(entitiesPrivate, sskey[i])
}
fmt.Println(entitiesPrivate)
signer, err := openpgp.CheckArmoredDetachedSignature(entitiesPrivate, strings.NewReader(signature), strings.NewReader(signature))
if err != io.EOF {
fmt.Println("Unknown signer!")
fmt.Println(err)
} else {
fmt.Println("Known signer.")
fmt.Println(signer)
fmt.Println(err)
return true
}
return false
}
func validateLogin(signature string, file []byte) bool {
func validate(signature string, file []byte) bool {
if signature == "guarddoggo:bork" {
if signature != "" {
bufferedReader, err := os.Create("tests/florp")
if err != nil {
......@@ -68,26 +28,34 @@ func validate(signature string, file []byte) bool {
}
bufferedReader.Write(file)
bufferedReader.Close()
decrypter := exec.Command("/bin/sh", "-c", "echo crashandburn | gpg --passphrase-fd 0 -o out.json florp")
decrypter := exec.Command("/bin/sh", "-c", "echo crashandburn | gpg --passphrase-fd 0 -o florpfile florp")
decrypter.Dir = "tests/"
decrypter.Run()
defer os.Remove("tests/florp")
florpFile, err := os.Open("tests/florp")
//defer os.Remove("tests/florp")
florpFile, err := os.Open("tests/florpfile")
florpReader := io.Reader(florpFile)
florpScanner := bufio.NewScanner(florpReader)
for florpScanner.Scan() {
fmt.Println(florpScanner.Text())
if florpScanner.Text() == signature {
fmt.Println("LOGGED THE HECK IN")
return true
}
}
if err != nil {
fmt.Println("\033[2;255;0;0mERROR\033[0m")
fmt.Println(err)
return false
}
return true
} else {
fmt.Println("\033[2;255;0;0mNOT GUARD DOGGO\033[0m")
return false
}
return false
}
func validate(signature string, file []byte) bool {
bufferedReader, err := os.Create("tests/outfile")
if err != nil {
......@@ -114,10 +82,9 @@ func validate(signature string, file []byte) bool {
if err != nil {
fmt.Println("Error running command")
fmt.Println(err)
} else {
return true
return false
}
return false
return true
}
func signer(path string) []byte {
const prefix = "/home/twotonne/"
......@@ -429,22 +396,21 @@ func main() {
// response. These three headers are actually sent in
// the trailer.
fmt.Println("I HEAR BORK")
//userPass := req.Header.Get("Authorization")
signed := req.Header.Get("Signature")
sigBuffer := make([]byte, 1024)
req.Body.Read(sigBuffer)
ok := validateSig(string(sigBuffer))
// ok := validate(signed, []byte(signed))
//signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
if err != nil {
fmt.Println(err)
}
ok := validateLogin(signed, []byte(signed))
if ok {
w.Header().Set("Authorization", "ok")
w.WriteHeader(http.StatusOK)
fmt.Println(signed + "LOGGED THE HECK IN")
w.Write([]byte("bop"))
} else {
w.Header().Set("Authorization", "Not authorized")
w.WriteHeader(http.StatusOK)
w.Write([]byte("BORKBORKBORK"))
w.Header().Set("Authorization", "not authorized")
w.Write([]byte("ennt!"))
}
})
mux.HandleFunc("/examplepost", func(w http.ResponseWriter, req *http.Request) {
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
"liked": "https://guarddoggo.snowcrash.network/liked.json",
"inbox": "https://guarddoggo.snowcrash.network/inbox.json",
"outbox": "https://guarddoggo.snowcrash.network/feed.json",
"preferredUsername": "guarddoggo",
"preferredUsername": "kenzoishii",
"icon": [
"https://guarddoggo.snowcrash.network/image/bork"
]
......
guarddoggo:bork
\ No newline at end of file
boop
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment