-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out registration to its own enrolment package
- Loading branch information
Showing
14 changed files
with
630 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1 @@ | ||
package adminui | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
type security struct { | ||
next http.Handler | ||
} | ||
|
||
func (sh *security) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("X-Frame-Options", "DENY") | ||
w.Header().Set("Strict-Transport-Security", "max-age=31536000") | ||
w.Header().Set("X-Content-Type-Options", "nosniff") | ||
|
||
if r.Method != "GET" { | ||
u, err := url.Parse(r.Header.Get("Origin")) | ||
if err != nil { | ||
http.Error(w, "Bad Request", 400) | ||
return | ||
} | ||
|
||
//If origin != host header | ||
if r.Host != u.Host { | ||
http.Error(w, "Bad Request", 400) | ||
return | ||
} | ||
} | ||
|
||
sh.next.ServeHTTP(w, r) | ||
} | ||
|
||
func setSecurityHeaders(f http.Handler) http.Handler { | ||
return &security{ | ||
next: f, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package resources | ||
|
||
import ( | ||
"embed" | ||
"html/template" | ||
"io" | ||
"path" | ||
|
||
"github.com/NHAS/wag/internal/config" | ||
) | ||
|
||
type Interface struct { | ||
ClientPrivateKey string | ||
ClientAddress string | ||
ClientPresharedKey string | ||
|
||
ServerAddress string | ||
ServerPublicKey string | ||
CapturedAddresses []string | ||
DNS []string | ||
} | ||
|
||
type QrCodeRegistrationDisplay struct { | ||
ImageData template.URL | ||
Username string | ||
} | ||
|
||
//go:embed templates/* | ||
var templates embed.FS | ||
|
||
func Render(page string, out io.Writer, data interface{}) error { | ||
return RenderWithFuncs(page, out, data, nil) | ||
} | ||
|
||
func RenderWithFuncs(page string, out io.Writer, data interface{}, templateFuncs template.FuncMap) error { | ||
var currentTemplate *template.Template | ||
if len(config.Values.MFATemplatesDirectory) != 0 { | ||
currentTemplate = template.Must(template.New(path.Base(page)).Funcs(templateFuncs).ParseFiles(path.Join(config.Values.MFATemplatesDirectory, page))) | ||
} else { | ||
currentTemplate = template.Must(template.New(path.Base(page)).Funcs(templateFuncs).ParseFS(templates, "templates/"+page)) | ||
} | ||
|
||
return currentTemplate.Execute(out, data) | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.