From bd2234cd125e3571912080006bcd3730a362a818 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Thu, 1 Oct 2020 15:32:23 -0400 Subject: [PATCH] Add constructor for static key strategy Co-authored-by: Josh Winters Signed-off-by: Rui Yang --- server/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/server.go b/server/server.go index f4d139d1..481cc58d 100644 --- a/server/server.go +++ b/server/server.go @@ -2,6 +2,7 @@ package server import ( "context" + "crypto/rsa" "encoding/json" "errors" "fmt" @@ -172,6 +173,13 @@ func NewServer(ctx context.Context, c Config) (*Server, error) { )) } +// NewServerWithKey constructs a server from the provided config and a static signing key. +func NewServerWithKey(ctx context.Context, c Config, privateKey *rsa.PrivateKey) (*Server, error) { + return newServer(ctx, c, staticRotationStrategy( + privateKey, + )) +} + func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) (*Server, error) { issuerURL, err := url.Parse(c.Issuer) if err != nil {