Separate out key directory
This commit is contained in:
parent
b7671b9a97
commit
3dfe5b8558
6 changed files with 85 additions and 60 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue