Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f48e36da8
|
||
|
|
7e3eee56e0
|
||
|
|
616997fdc6
|
||
|
|
b56f27dcfb
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@
|
|||||||
|
|
||||||
sour.is-keyproofs
|
sour.is-keyproofs
|
||||||
.env
|
.env
|
||||||
|
/pub
|
||||||
3
Makefile
3
Makefile
@@ -1,7 +1,7 @@
|
|||||||
NAME=sour.is-keyproofs
|
NAME=sour.is-keyproofs
|
||||||
BUMP?=current
|
BUMP?=current
|
||||||
DATE:=$(shell date -u +%FT%TZ)
|
DATE:=$(shell date -u +%FT%TZ)
|
||||||
HASH:=$(shell git rev-pars HEAD 2> /dev/null)
|
HASH:=$(shell git rev-parse HEAD 2> /dev/null)
|
||||||
VERSION:=$(shell BUMP=$(BUMP) ./version.sh)
|
VERSION:=$(shell BUMP=$(BUMP) ./version.sh)
|
||||||
|
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ version:
|
|||||||
@echo $(VERSION)
|
@echo $(VERSION)
|
||||||
tag:
|
tag:
|
||||||
git tag -a v$(VERSION) -m "Version: $(VERSION)"
|
git tag -a v$(VERSION) -m "Version: $(VERSION)"
|
||||||
|
git push --tag
|
||||||
release:
|
release:
|
||||||
@make tag BUMP=patch
|
@make tag BUMP=patch
|
||||||
run:
|
run:
|
||||||
|
|||||||
25
example.env
25
example.env
@@ -1,5 +1,7 @@
|
|||||||
# Rename to '.env' or pass required items to environment when running.
|
# Rename to '.env' or pass required items to environment when running.
|
||||||
|
|
||||||
|
# Basic Configuration.
|
||||||
|
|
||||||
# REDDIT_APIKEY [REQUIRED]
|
# REDDIT_APIKEY [REQUIRED]
|
||||||
# REDDIT_SECRET [REQUIRED]
|
# REDDIT_SECRET [REQUIRED]
|
||||||
# To prevent reddits low ratelimits for non-authenticated requests
|
# To prevent reddits low ratelimits for non-authenticated requests
|
||||||
@@ -26,6 +28,12 @@ HTTP_LISTEN=
|
|||||||
|
|
||||||
BASE_URL=
|
BASE_URL=
|
||||||
|
|
||||||
|
# AVATAR_PATH [OPTIONAL]
|
||||||
|
# To set the path for avatar/bg/cover image directories to serve. (default: pub)
|
||||||
|
# Path should allow read/write to application. The folders will be generated automatically.
|
||||||
|
|
||||||
|
# Advanced Options. These are used to customize the application in non-standard deployments
|
||||||
|
|
||||||
# XMPP_URL [OPTIONAL]
|
# XMPP_URL [OPTIONAL]
|
||||||
# To set XMPP http url for VCard verification. (default: BASE_URL)
|
# To set XMPP http url for VCard verification. (default: BASE_URL)
|
||||||
|
|
||||||
@@ -35,3 +43,20 @@ XMPP_URL=
|
|||||||
# To set DNS http url for DNS verification. (default: BASE_URL)
|
# To set DNS http url for DNS verification. (default: BASE_URL)
|
||||||
|
|
||||||
XMPP_URL=
|
XMPP_URL=
|
||||||
|
|
||||||
|
# Avatar app
|
||||||
|
# DISABLE_AVATAR [OPTIONAL]
|
||||||
|
# Disable the Avatar application. Set to any value other than "false"
|
||||||
|
|
||||||
|
# DNS app
|
||||||
|
# DISABLE_DNS [OPTIONAL]
|
||||||
|
# Disable the DNS application. Set to any value other than "false"
|
||||||
|
|
||||||
|
# Keyproofs app
|
||||||
|
# DISABLE_KEYPROOFS [OPTIONAL]
|
||||||
|
# Disable the KeyProofs application. Set to any value other than "false"
|
||||||
|
|
||||||
|
# XMPP VCard app
|
||||||
|
# DISABLE_VCARD [OPTIONAL]
|
||||||
|
# Disable the VCard application. Set to any value other than "false"
|
||||||
|
# If disabled the username/password are no longer required.
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -3,6 +3,7 @@ module github.com/sour-is/keyproofs
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7
|
||||||
github.com/go-chi/chi v4.1.2+incompatible
|
github.com/go-chi/chi v4.1.2+incompatible
|
||||||
github.com/google/go-cmp v0.5.4 // indirect
|
github.com/google/go-cmp v0.5.4 // indirect
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
|
|||||||
1
go.sum
1
go.sum
@@ -138,6 +138,7 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190927073244-c990c680b611/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190927073244-c990c680b611/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
|||||||
52
main.go
52
main.go
@@ -86,38 +86,48 @@ func run(ctx context.Context) error {
|
|||||||
Credential: xmpp.Password(os.Getenv("XMPP_PASSWORD")),
|
Credential: xmpp.Password(os.Getenv("XMPP_PASSWORD")),
|
||||||
})
|
})
|
||||||
|
|
||||||
// configure cors middleware
|
|
||||||
corsMiddleware := cors.New(cors.Options{
|
|
||||||
AllowCredentials: true,
|
|
||||||
AllowedMethods: strings.Fields(env("CORS_METHODS", "GET")),
|
|
||||||
AllowedOrigins: strings.Fields(env("CORS_ORIGIN", "*")),
|
|
||||||
}).Handler
|
|
||||||
|
|
||||||
mux := chi.NewRouter()
|
mux := chi.NewRouter()
|
||||||
mux.Use(
|
mux.Use(
|
||||||
cfg.ApplyHTTP,
|
cfg.ApplyHTTP,
|
||||||
secHeaders,
|
secHeaders,
|
||||||
corsMiddleware,
|
cors.New(cors.Options{
|
||||||
|
AllowCredentials: true,
|
||||||
|
AllowedMethods: strings.Fields(env("CORS_METHODS", "GET")),
|
||||||
|
AllowedOrigins: strings.Fields(env("CORS_ORIGIN", "*")),
|
||||||
|
}).Handler,
|
||||||
middleware.RequestID,
|
middleware.RequestID,
|
||||||
middleware.RealIP,
|
middleware.RealIP,
|
||||||
middleware.RequestLogger(&middleware.DefaultLogFormatter{Logger: accessLog(log.Info)}),
|
middleware.RequestLogger(&middleware.DefaultLogFormatter{Logger: accessLog(log.Info)}),
|
||||||
middleware.Recoverer,
|
middleware.Recoverer,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create cache for promise engine
|
if env("DISABLE_KEYPROOF", "false") == "false" {
|
||||||
arc, _ := lru.NewARC(4096)
|
// Create cache for promise engine
|
||||||
c := cache.New(arc)
|
arc, _ := lru.NewARC(4096)
|
||||||
|
c := cache.New(arc)
|
||||||
keyproofApp := keyproofs.NewKeyProofApp(ctx, c)
|
keyproofs.NewKeyProofApp(ctx, c).Routes(mux)
|
||||||
dnsApp := keyproofs.NewDNSApp(ctx)
|
|
||||||
vcardApp, err := keyproofs.NewVCardApp(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyproofApp.Routes(mux)
|
if env("DISABLE_DNS", "false") == "false" {
|
||||||
dnsApp.Routes(mux)
|
keyproofs.NewDNSApp(ctx).Routes(mux)
|
||||||
vcardApp.Routes(mux)
|
}
|
||||||
|
|
||||||
|
if env("DISABLE_AVATAR", "false") == "false" {
|
||||||
|
avatarApp, err := keyproofs.NewAvatarApp(ctx, env("AVATAR_PATH", "pub"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarApp.Routes(mux)
|
||||||
|
}
|
||||||
|
|
||||||
|
if env("DISABLE_VCARD", "false") == "false" {
|
||||||
|
vcardApp, err := keyproofs.NewVCardApp(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vcardApp.Routes(mux)
|
||||||
|
}
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("app", cfg.GetString("app-name")).
|
Str("app", cfg.GetString("app-name")).
|
||||||
@@ -127,7 +137,7 @@ func run(ctx context.Context) error {
|
|||||||
Str("listen", listen).
|
Str("listen", listen).
|
||||||
Msg("startup")
|
Msg("startup")
|
||||||
|
|
||||||
err = New(&http.Server{
|
err := New(&http.Server{
|
||||||
Addr: listen,
|
Addr: listen,
|
||||||
WriteTimeout: 15 * time.Second,
|
WriteTimeout: 15 * time.Second,
|
||||||
ReadTimeout: 15 * time.Second,
|
ReadTimeout: 15 * time.Second,
|
||||||
|
|||||||
230
pkg/keyproofs/routes-avatar.go
Normal file
230
pkg/keyproofs/routes-avatar.go
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
package keyproofs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/md5"
|
||||||
|
"crypto/sha1"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fsnotify/fsnotify"
|
||||||
|
"github.com/go-chi/chi"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||||
|
)
|
||||||
|
|
||||||
|
type avatarApp struct {
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAvatarApp(ctx context.Context, path string) (*avatarApp, error) {
|
||||||
|
log := log.Ctx(ctx)
|
||||||
|
|
||||||
|
path = filepath.Clean(path)
|
||||||
|
app := &avatarApp{path: path}
|
||||||
|
err := app.CheckFiles(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
watch, err := fsnotify.NewWatcher()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, typ := range []string{"avatar", "bg", "cover"} {
|
||||||
|
err = watch.Add(filepath.Join(path, typ))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug().Msg("startup avatar watcher")
|
||||||
|
wg := graceful.WaitGroup(ctx)
|
||||||
|
wg.Go(func() error {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
log.Debug().Msg("shutdown avatar watcher")
|
||||||
|
return nil
|
||||||
|
case op := <-watch.Events:
|
||||||
|
log.Print(op)
|
||||||
|
switch op.Op {
|
||||||
|
case fsnotify.Create:
|
||||||
|
path = filepath.Dir(op.Name)
|
||||||
|
kind := filepath.Base(path)
|
||||||
|
name := filepath.Base(op.Name)
|
||||||
|
if err := createLinks(app.path, kind, name); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
case fsnotify.Remove, fsnotify.Rename:
|
||||||
|
path = filepath.Dir(op.Name)
|
||||||
|
kind := filepath.Base(path)
|
||||||
|
name := filepath.Base(op.Name)
|
||||||
|
if err := removeLinks(app.path, kind, name); err != nil {
|
||||||
|
log.Error().Err(err).Send()
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
case err := <-watch.Errors:
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return app, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *avatarApp) CheckFiles(ctx context.Context) error {
|
||||||
|
log := log.Ctx(ctx)
|
||||||
|
|
||||||
|
for _, name := range []string{".links", "avatar", "bg", "cover"} {
|
||||||
|
log.Debug().Msgf("mkdir: %s", filepath.Join(app.path, name))
|
||||||
|
err := os.MkdirAll(filepath.Join(app.path, name), 0700)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filepath.Walk(app.path, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
if info.Name() == ".links" {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
path = filepath.Dir(path)
|
||||||
|
kind := filepath.Base(path)
|
||||||
|
name := info.Name()
|
||||||
|
|
||||||
|
log.Debug().Msgf("link: %s %s %s", app.path, kind, name)
|
||||||
|
|
||||||
|
return createLinks(app.path, kind, name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *avatarApp) get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := log.Ctx(r.Context())
|
||||||
|
|
||||||
|
log.Print(r.Host)
|
||||||
|
|
||||||
|
kind := chi.URLParam(r, "kind")
|
||||||
|
hash := chi.URLParam(r, "hash")
|
||||||
|
|
||||||
|
if strings.ContainsRune(hash, '@') {
|
||||||
|
avatarHost, _, err := styleSRV(r.Context(), hash)
|
||||||
|
if err != nil {
|
||||||
|
writeText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hash = hashSHA1(strings.ToLower(hash))
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("https://%s/%s/%s?%s", avatarHost, kind, hash, r.URL.RawQuery), 301)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fname := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
|
log.Debug().Msgf("path: %s", fname)
|
||||||
|
|
||||||
|
f, err := os.Open(fname)
|
||||||
|
if err != nil {
|
||||||
|
writeText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(w, f)
|
||||||
|
if err != nil {
|
||||||
|
writeText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *avatarApp) Routes(r *chi.Mux) {
|
||||||
|
r.MethodFunc("GET", "/{kind:avatar|bg|cover}/{hash}", app.get)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hashMD5(name string) string {
|
||||||
|
h := md5.New()
|
||||||
|
_, _ = h.Write([]byte(name))
|
||||||
|
|
||||||
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
|
}
|
||||||
|
func hashSHA1(name string) string {
|
||||||
|
h := sha1.New()
|
||||||
|
_, _ = h.Write([]byte(name))
|
||||||
|
|
||||||
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
func createLinks(path, kind, name string) error {
|
||||||
|
if !strings.ContainsRune(name, '@') {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
src := filepath.Join("..", kind, name)
|
||||||
|
name = strings.ToLower(name)
|
||||||
|
|
||||||
|
hash := hashMD5(name)
|
||||||
|
link := filepath.Join(path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
|
err := replaceLink(src, link)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
hash = hashSHA1(name)
|
||||||
|
link = filepath.Join(path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
|
err = replaceLink(src, link)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeLinks(path, kind, name string) error {
|
||||||
|
if !strings.ContainsRune(name, '@') {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
name = strings.ToLower(name)
|
||||||
|
|
||||||
|
hash := hashMD5(name)
|
||||||
|
link := filepath.Join(path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
|
err := os.Remove(link)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
hash = hashSHA1(name)
|
||||||
|
link = filepath.Join(path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
|
err = os.Remove(link)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func replaceLink(src, link string) error {
|
||||||
|
if dst, err := os.Readlink(link); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
err = os.Symlink(src, link)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if dst != src {
|
||||||
|
err = os.Remove(link)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Symlink(src, link)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -147,6 +147,7 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
page := page{Style: defaultStyle}
|
page := page{Style: defaultStyle}
|
||||||
page.AppName = fmt.Sprintf("%s v%s", cfg.GetString("app-name"), cfg.GetString("app-version"))
|
page.AppName = fmt.Sprintf("%s v%s", cfg.GetString("app-name"), cfg.GetString("app-version"))
|
||||||
|
page.AppBuild = fmt.Sprintf("%s %s", cfg.GetString("build-date"), cfg.GetString("build-hash"))
|
||||||
|
|
||||||
// Wait for either entity to resolve or timeout
|
// Wait for either entity to resolve or timeout
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ func getStyle(ctx context.Context, email string) (*Style, error) {
|
|||||||
hash := md5.New()
|
hash := md5.New()
|
||||||
email = strings.TrimSpace(strings.ToLower(email))
|
email = strings.TrimSpace(strings.ToLower(email))
|
||||||
_, _ = hash.Write([]byte(email))
|
_, _ = hash.Write([]byte(email))
|
||||||
|
|
||||||
id := hash.Sum(nil)
|
id := hash.Sum(nil)
|
||||||
|
|
||||||
style := &Style{}
|
style := &Style{}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package keyproofs
|
package keyproofs
|
||||||
|
|
||||||
type page struct {
|
type page struct {
|
||||||
AppName string
|
AppName string
|
||||||
Entity *Entity
|
AppBuild string
|
||||||
Style *Style
|
Entity *Entity
|
||||||
Proofs *Proofs
|
Style *Style
|
||||||
|
Proofs *Proofs
|
||||||
|
|
||||||
Markdown string
|
Markdown string
|
||||||
HasProofs bool
|
HasProofs bool
|
||||||
@@ -49,6 +50,7 @@ var pageTPL = `
|
|||||||
}
|
}
|
||||||
.shade { background-color: {{index .Palette 3}}80; border-radius: .25rem;}
|
.shade { background-color: {{index .Palette 3}}80; border-radius: .25rem;}
|
||||||
.lead { padding:0; margin:0; }
|
.lead { padding:0; margin:0; }
|
||||||
|
.scroll { height: 20em; overflow: scroll; }
|
||||||
|
|
||||||
@media only screen and (max-width: 991px) {
|
@media only screen and (max-width: 991px) {
|
||||||
.jumbotron h1 { font-size: 2rem; }
|
.jumbotron h1 { font-size: 2rem; }
|
||||||
@@ -76,21 +78,25 @@ var pageTPL = `
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{{template "content" .}}
|
{{template "content" .}}
|
||||||
|
|
||||||
<div class="card-footer text-muted text-center">
|
<div class="card-footer text-muted text-center">
|
||||||
<a href="/">{{.AppName}}</a> | © 2020 Sour.is | <a href="/id/me@sour.is">About me</a> | <a href="https://github.com/sour-is/keyproofs">GitHub</a> | Inspired by <a href="https://keyoxide.org/">keyoxide</a>
|
<a href="/" alt="{{.AppBuild}}">{{.AppName}}</a>
|
||||||
|
| © 2020 Sour.is
|
||||||
|
| <a href="/id/me@sour.is">About me</a>
|
||||||
|
| <a href="https://github.com/sour-is/keyproofs">GitHub</a>
|
||||||
|
| Inspired by <a href="https://keyoxide.org/">keyoxide</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`
|
`
|
||||||
|
|
||||||
var homeTPL = `
|
var homeTPL = `
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<div class="jumbotron heading">
|
<div class="jumbotron heading">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row shade">
|
<div class="row shade">
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
@@ -99,124 +105,135 @@ var homeTPL = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
</div>
|
||||||
<div class="card">
|
<br/>
|
||||||
<div class="card-body">
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
<form method="GET" action="/">
|
<form method="GET" action="/">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" name="id" class="form-control" placeholder="Email or Fingerprint..." aria-label="Email or Fingerprint" aria-describedby="button-addon">
|
<input type="text"
|
||||||
|
name="id"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Email or Fingerprint..."
|
||||||
|
aria-label="Email or Fingerprint"
|
||||||
|
aria-describedby="button-addon" />
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary" type="submit" id="button-addon">GO</button>
|
<button class="btn btn-outline-secondary" type="submit" id="button-addon">GO</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="container"> {{.Markdown | markDown}} </div>
|
<div class="container"> {{.Markdown | markDown}} </div>
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
||||||
var proofTPL = `
|
var proofTPL = `
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<div class="jumbotron heading">
|
<div class="jumbotron heading">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row shade">
|
<div class="row shade">
|
||||||
|
{{ with .Err }}
|
||||||
|
<div class="col-xs center-md">
|
||||||
|
<i class="fas fa-exclamation-triangle fa-4x fg-color-11"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ with .Err }}
|
<div class="col-md">
|
||||||
|
<h1 class="display-8 fg-color-8">Something went wrong...</h1>
|
||||||
|
<pre class="fg-color-11">{{.}}</pre>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{ with .Style }}
|
||||||
<div class="col-xs center-md">
|
<div class="col-xs center-md">
|
||||||
<i class="fas fa-exclamation-triangle fa-4x fg-color-11"></i>
|
<img src="{{.Avatar}}" class="img-thumbnail" alt="avatar" style="width:88px; height:88px">
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="col-md">
|
{{with .Entity}}
|
||||||
<h1 class="display-8 fg-color-8">Something went wrong...</h1>
|
<div class="col-md center-md">
|
||||||
<pre class="fg-color-11">{{.}}</pre>
|
<h1 class="display-8 fg-color-8">{{.Primary.Name}}</h1>
|
||||||
|
<p class="lead fg-color-11"><i class="fas fa-fingerprint"></i> {{.Fingerprint}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs center-md">
|
||||||
|
<img src="/qr?s=-2&c=OPENPGP4FPR%3A{{.Fingerprint}}" class="img-thumbnail" alt="qrcode" style="width:88px; height:88px">
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{ with .Style }}
|
<div class="col-md">
|
||||||
<div class="col-xs center-md">
|
<h1 class="display-8 fg-color-8">Loading...</h1>
|
||||||
<img src="{{.Avatar}}" class="img-thumbnail" alt="avatar" style="width:88px; height:88px">
|
<p class="lead fg-color-11">Reading key from remote service.</p>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
|
||||||
|
|
||||||
|
|
||||||
{{with .Entity}}
|
|
||||||
<div class="col-md center-md">
|
|
||||||
<h1 class="display-8 fg-color-8">{{.Primary.Name}}</h1>
|
|
||||||
<p class="lead fg-color-11"><i class="fas fa-fingerprint"></i> {{.Fingerprint}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs center-md">
|
|
||||||
<img src="/qr?s=-2&c=OPENPGP4FPR%3A{{.Fingerprint}}" class="img-thumbnail" alt="qrcode" style="width:88px; height:88px">
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
<div class="col-md">
|
|
||||||
<h1 class="display-8 fg-color-8">Loading...</h1>
|
|
||||||
<p class="lead fg-color-11">Reading key from remote service.</p>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{ with .Entity }}
|
<div class="row">
|
||||||
<div class="card">
|
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
|
||||||
<div class="card-header">Contact</div>
|
{{ with .Entity }}
|
||||||
<div class="list-group list-group-flush">
|
<div class="card">
|
||||||
{{with .Primary}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="fas fa-envelope"></i> <b>{{.Name}} <{{.Address}}></b> <span class="badge badge-secondary">Primary</span></a>{{end}}
|
<div class="card-header">Contact</div>
|
||||||
{{range .Emails}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="far fa-envelope"></i> {{.Name}} <{{.Address}}></a>{{end}}
|
<div class="list-group list-group-flush">
|
||||||
|
{{with .Primary}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="fas fa-envelope"></i> <b>{{.Name}} <{{.Address}}></b> <span class="badge badge-secondary">Primary</span></a>{{end}}
|
||||||
|
{{range .Emails}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="far fa-envelope"></i> {{.Name}} <{{.Address}}></a>{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if .HasProofs}}
|
||||||
|
{{with .Proofs}}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Proofs</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
{{range .}}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div>
|
||||||
|
<a title="{{.Link}}" class="font-weight-bold" href="{{.Link}}">
|
||||||
|
<i title="{{.Service}}" class="{{.Icon}}"></i>
|
||||||
|
{{.Name}}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{{if eq .Status 0}}
|
||||||
|
<a class="text-muted" href="{{.Verify}}"> <i class="fas fa-ellipsis-h"> Checking</i></a>
|
||||||
|
{{else if eq .Status 1}}
|
||||||
|
<a class="text-warning" href="{{.Verify}}"> <i class="fas fa-exclamation-triangle"></i> Error</a>
|
||||||
|
{{else if eq .Status 2}}
|
||||||
|
<a class="text-danger" href="{{.Verify}}"> <i class="far fa-times-circle"></i> Invalid</a>
|
||||||
|
{{else if eq .Status 3}}
|
||||||
|
<a class="text-success" href="{{.Verify}}"> <i class="far fa-check-square"></i> Verified</a>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{if eq .Service "xmpp"}}
|
||||||
|
<br/>
|
||||||
|
<img src="/qr?s=-2&c={{.Link}}" alt="qrcode" style="width:88px; height:88px">
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Proofs</div>
|
||||||
|
<div class="card-body">Loading...</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Public Key</div>
|
||||||
|
<div class="card-body scroll">
|
||||||
|
<pre><code>{{.Entity.ArmorText}}</code></pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if .HasProofs}}
|
|
||||||
{{with .Proofs}}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Proofs</div>
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
{{range .}}
|
|
||||||
<li class="list-group-item">
|
|
||||||
<div class="d-flex w-100 justify-content-between">
|
|
||||||
<div>
|
|
||||||
<a title="{{.Link}}" class="font-weight-bold" href="{{.Link}}">
|
|
||||||
<i title="{{.Service}}" class="{{.Icon}}"></i>
|
|
||||||
{{.Name}}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{{if eq .Status 0}}
|
|
||||||
<a class="text-muted" href="{{.Verify}}"> <i class="fas fa-ellipsis-h"> Checking</i></a>
|
|
||||||
{{else if eq .Status 1}}
|
|
||||||
<a class="text-warning" href="{{.Verify}}"> <i class="fas fa-exclamation-triangle"></i> Error</a>
|
|
||||||
{{else if eq .Status 2}}
|
|
||||||
<a class="text-danger" href="{{.Verify}}"> <i class="far fa-times-circle"></i> Invalid</a>
|
|
||||||
{{else if eq .Status 3}}
|
|
||||||
<a class="text-success" href="{{.Verify}}"> <i class="far fa-check-square"></i> Verified</a>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{if eq .Service "xmpp"}}
|
|
||||||
<img src="/qr?s=-2&c={{.Link}}" alt="qrcode" style="width:88px; height:88px">
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{{end}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
{{else}}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Proofs</div>
|
|
||||||
<div class="card-body">Loading...</div>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user