File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,6 +239,16 @@ func NewOIDCService(
239239 }
240240 }
241241
242+ rPublicKey , ok := publicKey .(* rsa.PublicKey )
243+
244+ if ! ok {
245+ return nil , fmt .Errorf ("public key is not an rsa public key" )
246+ }
247+
248+ if rPublicKey .N .Cmp (privateKey .N ) != 0 || rPublicKey .E != privateKey .E {
249+ return nil , fmt .Errorf ("public key does not pair with private key" )
250+ }
251+
242252 // We will reorganize the client into a map with the client ID as the key
243253 clients := make (map [string ]model.OIDCClientConfig )
244254
@@ -271,7 +281,7 @@ func NewOIDCService(
271281
272282 clients : clients ,
273283 privateKey : privateKey ,
274- publicKey : publicKey .( * rsa. PublicKey ) ,
284+ publicKey : rPublicKey ,
275285 issuer : issuer ,
276286 }
277287
@@ -822,13 +832,13 @@ func (service *OIDCService) GetJWK() ([]byte, error) {
822832 hasher .Write (der )
823833
824834 jwk := jose.JSONWebKey {
825- Key : service .privateKey ,
835+ Key : service .publicKey ,
826836 Algorithm : string (jose .RS256 ),
827837 Use : "sig" ,
828838 KeyID : base64 .URLEncoding .EncodeToString (hasher .Sum (nil )),
829839 }
830840
831- return jwk .Public (). MarshalJSON ()
841+ return jwk .MarshalJSON ()
832842}
833843
834844func (service * OIDCService ) ValidatePKCE (codeChallenge string , codeVerifier string ) bool {
You can’t perform that action at this time.
0 commit comments