token-validator: use cookies instead of localStorage to store auth token

This commit is contained in:
nemunaire 2020-03-01 18:15:19 +01:00
parent 72a4015288
commit a4a7b48a4f
6 changed files with 98 additions and 92 deletions

View file

@ -14,6 +14,7 @@ import (
"syscall"
)
var baseURL string = "/"
var sharedSecret string
type ResponseWriterPrefix struct {
@ -59,7 +60,7 @@ func StripPrefix(prefix string, h http.Handler) http.Handler {
func main() {
var bind = flag.String("bind", ":8081", "Bind port/socket")
var dsn = flag.String("dsn", DSNGenerator(), "DSN to connect to the MySQL server")
var baseURL = flag.String("baseurl", "/", "URL prepended to each URL")
flag.StringVar(&baseURL, "baseurl", baseURL, "URL prepended to each URL")
flag.StringVar(&sharedSecret, "sharedsecret", "adelina", "secret used to communicate with remote validator")
flag.StringVar(&AuthorizedKeysLocation, "authorizedkeyslocation", AuthorizedKeysLocation, "File for allowing user to SSH to the machine")
flag.StringVar(&SshPiperLocation, "sshPiperLocation", SshPiperLocation, "Directory containing directories for sshpiperd")
@ -72,12 +73,10 @@ func main() {
if err = sanitizeStaticOptions(); err != nil {
log.Fatal(err)
}
if *baseURL != "/" {
tmp := path.Clean(*baseURL)
baseURL = &tmp
if baseURL != "/" {
baseURL = path.Clean(baseURL)
} else {
tmp := ""
baseURL = &tmp
baseURL = ""
}
if *dummyauth {
@ -102,7 +101,7 @@ func main() {
srv := &http.Server{
Addr: *bind,
Handler: StripPrefix(*baseURL, Router()),
Handler: StripPrefix(baseURL, Router()),
}
// Serve content