Separate out key directory

This commit is contained in:
cheddar 2025-02-17 19:55:53 -05:00
parent b7671b9a97
commit 3dfe5b8558
No known key found for this signature in database
6 changed files with 85 additions and 60 deletions

View file

@ -2,32 +2,20 @@ package server
import (
"context"
"crypto"
"fmt"
"net/http"
"github.com/common-fate/httpsig"
"github.com/common-fate/httpsig/inmemory"
"github.com/common-fate/httpsig/verifier"
)
func Start(publicKey crypto.PublicKey, isCaddyAuth bool) error {
keyDir := InMemoryDirectory{
records: map[string]KeyEntry{},
}
keyId := "test-id"
keyDir.records[keyId] = KeyEntry{
alg: "ed25519",
publicKey: publicKey,
userId: "test_user",
}
func Start(isCaddyAuth bool, keyDir verifier.KeyDirectory) error {
mux := http.NewServeMux()
verifier := httpsig.Middleware(httpsig.MiddlewareOpts{
NonceStorage: inmemory.NewNonceStorage(),
KeyDirectory: &keyDir,
KeyDirectory: keyDir,
Tag: "auth",
Scheme: "http",
Authority: "localhost:8080",