add libravatar/style endpoint
This commit is contained in:
parent
b56f27dcfb
commit
616997fdc6
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -16,3 +16,4 @@
|
||||||
|
|
||||||
sour.is-keyproofs
|
sour.is-keyproofs
|
||||||
.env
|
.env
|
||||||
|
/pub
|
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,
|
||||||
|
|
|
@ -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{}
|
||||||
|
|
|
@ -50,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; }
|
.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; }
|
||||||
.jumbotron .lead { font-size: 1.0rem; }
|
.jumbotron .lead { font-size: 1.0rem; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user