mirror of
https://github.com/Luzifer/vault-otp-ui.git
synced 2024-11-09 08:40:05 +00:00
Add basic web application manifest
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
c20c1ec5be
commit
9680058e76
8 changed files with 180 additions and 9 deletions
123
assets.go
123
assets.go
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,8 @@
|
||||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||||
<title>Vault OTP-UI</title>
|
<title>Vault OTP-UI</title>
|
||||||
|
|
||||||
|
<link rel="manifest" href="static/manifest.json">
|
||||||
|
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css"
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css"
|
||||||
integrity="sha256-ZT4HPpdCOt2lvDkXokHuhJfdOKSPFLzeAJik5U/Q+l4=" crossorigin="anonymous" />
|
integrity="sha256-ZT4HPpdCOt2lvDkXokHuhJfdOKSPFLzeAJik5U/Q+l4=" crossorigin="anonymous" />
|
||||||
|
|
35
main.go
35
main.go
|
@ -1,6 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//go:generate go-bindata -pkg $GOPACKAGE -o assets.go index.html application.js
|
//go:generate go-bindata -pkg $GOPACKAGE -o assets.go index.html application.js static
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -9,13 +9,16 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Luzifer/rconfig"
|
"github.com/Luzifer/rconfig"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/alecthomas/template"
|
"github.com/alecthomas/template"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"github.com/tdewolff/minify"
|
"github.com/tdewolff/minify"
|
||||||
|
@ -89,11 +92,13 @@ func main() {
|
||||||
log.Fatalf("Unable to parse CLI parameters: %s", err)
|
log.Fatalf("Unable to parse CLI parameters: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.HandleFunc("/oauth2", handleOAuthCallback)
|
r := mux.NewRouter()
|
||||||
http.HandleFunc("/application.js", handleApplicationJS)
|
r.HandleFunc("/oauth2", handleOAuthCallback)
|
||||||
http.HandleFunc("/codes.json", handleCodesJSON)
|
r.HandleFunc("/application.js", handleApplicationJS)
|
||||||
http.HandleFunc("/", handleIndexPage)
|
r.HandleFunc("/codes.json", handleCodesJSON)
|
||||||
log.Fatalf("HTTP server exitted: %s", http.ListenAndServe(cfg.Listen, nil))
|
r.PathPrefix("/static").HandlerFunc(handleStatics)
|
||||||
|
r.HandleFunc("/", handleIndexPage)
|
||||||
|
log.Fatalf("HTTP server exitted: %s", http.ListenAndServe(cfg.Listen, r))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFileContentFallback(filename string) (io.Reader, error) {
|
func getFileContentFallback(filename string) (io.Reader, error) {
|
||||||
|
@ -207,3 +212,21 @@ func handleCodesJSON(res http.ResponseWriter, r *http.Request) {
|
||||||
res.Header().Set("Cache-Control", "no-cache")
|
res.Header().Set("Cache-Control", "no-cache")
|
||||||
json.NewEncoder(res).Encode(result)
|
json.NewEncoder(res).Encode(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleStatics(res http.ResponseWriter, r *http.Request) {
|
||||||
|
req := strings.TrimLeft(r.URL.Path, "/")
|
||||||
|
ext := req[strings.LastIndex(req, "."):len(req)]
|
||||||
|
t := mime.TypeByExtension(ext)
|
||||||
|
|
||||||
|
b, err := Asset(req)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"file": req,
|
||||||
|
}).Errorf("Static file not found")
|
||||||
|
http.Error(res, "I don't have that.", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Header().Set("Content-Type", t)
|
||||||
|
res.Write(b)
|
||||||
|
}
|
||||||
|
|
29
static/manifest.json
Normal file
29
static/manifest.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"display": "standalone",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"sizes": "128x128",
|
||||||
|
"src": "padlock_128.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sizes": "144x144",
|
||||||
|
"src": "padlock_144.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sizes": "152x152",
|
||||||
|
"src": "padlock_152.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "padlock_192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Vault OTP-UI",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"short_name": "Vault OTP-UI",
|
||||||
|
"start_url": "/"
|
||||||
|
}
|
BIN
static/padlock_128.png
Normal file
BIN
static/padlock_128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
BIN
static/padlock_144.png
Normal file
BIN
static/padlock_144.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
static/padlock_152.png
Normal file
BIN
static/padlock_152.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
static/padlock_192.png
Normal file
BIN
static/padlock_192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in a new issue