ref: 256596f5300b17c5c627cf8688f63e7bc6da83e8
parent: ea487fc43c26579181029ae3b7731f823524370f
parent: d4a4ac2fde975f2160f53491f515b2b18efa1eff
author: Mike <Mike@vals-Mac-mini.hitronhub.home>
date: Thu Dec 5 05:33:30 PST 2019
Merge branch 'master' of github.com:olmaxmedical/olmax_go
--- a/router/run.go
+++ b/router/run.go
@@ -1,6 +1,7 @@
package router
import (
+ "crypto/tls"
"fmt"
"net/http"
@@ -31,12 +32,12 @@
mux.HandleFunc("/logout.html", d.logout)
mux.HandleFunc("/profile.html", d.profile)
mux.HandleFunc("/", d.normal)
- /* Pending certificates - from https://github.com/denji/golang-tls (creative commons)
+ //from https://github.com/denji/golang-tls (creative commons)
cfg := &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
PreferServerCipherSuites: true,
- CipherSuites: []int16{
+ CipherSuites: []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
@@ -44,17 +45,16 @@
},
}
srv := &http.Server{
- Addr: ":443",
+ Addr: ":4443",
Handler: mux,
TLSConfig: cfg,
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
}
- return srv.ListenAndServeTLS("tls.crt", "tls.key") */
- return http.ListenAndServe(":8080", mux)
+ return srv.ListenAndServeTLS("cert.pem", "key.pem")
}
func (d *handle) activate(w http.ResponseWriter, r *http.Request) {
- //w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
+ w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
if len(r.URL.Path) != 46 && r.URL.Path[:9] != "/activate" {
http.Error(w, "Bad Request", 400)
return
@@ -106,7 +106,7 @@
}
func (d *handle) normal(w http.ResponseWriter, r *http.Request) {
- //w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
+ w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
if r.URL.Path == "/" {
http.Redirect(w, r, "/index.html", 302)
return
@@ -132,7 +132,7 @@
func (d *handle) logout(w http.ResponseWriter, r *http.Request) {
d.manager.Destroy(w, r)
- //w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
+ w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
http.Redirect(w, r, "/index.html", 302)
}
@@ -200,7 +200,7 @@
// TODO: This will require actual client data from the database to populate the page
func (d *handle) profile(w http.ResponseWriter, r *http.Request) {
- //w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
+ w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
user, status, us, role := getUser(d, w, r)
if status == "false" {
http.Redirect(w, r, "/login.html", 302)