MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / setupSignerWithKeys

Method setupSignerWithKeys

rest/oidc_api_test.go:175–189  ·  view source on GitHub ↗

setupSignerWithKeys sets up an RSA signer to sign the token and a set of public keys in JWK format that enable clients to validate a JSON Web Token (JWT) issued by this OpenID Connect Provider. Returns an error if there is any failure in generating RSA key pairs or creating a new RSA signer.

()

Source from the content-addressed store, hash-verified

173// that enable clients to validate a JSON Web Token (JWT) issued by this OpenID Connect Provider.
174// Returns an error if there is any failure in generating RSA key pairs or creating a new RSA signer.
175func (s *mockAuthServer) setupSignerWithKeys() error {
176 rsaPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
177 if err != nil {
178 return err
179 }
180 signingKey := jose.SigningKey{Algorithm: jose.RS256, Key: rsaPrivateKey}
181 var signerOptions = jose.SignerOptions{}
182 signerOptions.WithType("JWT")
183 s.signer, err = jose.NewSigner(signingKey, &signerOptions)
184 if err != nil {
185 return err
186 }
187 s.keys = []jose.JSONWebKey{{Key: &rsaPrivateKey.PublicKey, KeyID: "kid", Use: "sig"}}
188 return nil
189}
190
191// Start registers mock handlers and starts the mock OAuth server.
192// The caller should call Shutdown when finished, to shut it down.

Callers 1

newMockAuthServerFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected