@@ -149,18 +149,61 @@ public function testVerifySignedJwtWithCerts()
149149 }
150150
151151 // Checks that the id token fails to verify with the expected message.
152- private function checkIdTokenFailure ($ id_token , $ msg )
152+ private function checkIdTokenFailure ($ id_token , $ msg, $ issuer = null )
153153 {
154154 $ certs = $ this ->getSignonCerts ();
155155 $ oauth2 = new Google_Auth_OAuth2 ($ this ->getClient ());
156156 try {
157- $ oauth2 ->verifySignedJwtWithCerts ($ id_token , $ certs , "client_id " );
157+ $ oauth2 ->verifySignedJwtWithCerts ($ id_token , $ certs , "client_id " , $ issuer );
158158 $ this ->fail ("Should have thrown for $ id_token " );
159159 } catch (Google_Auth_Exception $ e ) {
160160 $ this ->assertContains ($ msg , $ e ->getMessage ());
161161 }
162162 }
163163
164+ public function testVerifySignedJwtWithMultipleIssuers ()
165+ {
166+ $ id_token = $ this ->makeSignedJwt (
167+ array (
168+ "iss " => "system.gserviceaccount.com " ,
169+ "aud " => "client_id " ,
170+ "sub " => self ::USER_ID ,
171+ "iat " => time (),
172+ "exp " => time () + 3600
173+ )
174+ );
175+ $ certs = $ this ->getSignonCerts ();
176+ $ oauth2 = new Google_Auth_OAuth2 ($ this ->getClient ());
177+ $ ticket = $ oauth2 ->verifySignedJwtWithCerts (
178+ $ id_token ,
179+ $ certs ,
180+ "client_id " ,
181+ ['system.gserviceaccount.com ' , 'https://system.gserviceaccount.com ' ]
182+ );
183+ $ this ->assertEquals (self ::USER_ID , $ ticket ->getUserId ());
184+ // Check that payload and envelope got filled in.
185+ $ attributes = $ ticket ->getAttributes ();
186+ $ this ->assertEquals ("JWT " , $ attributes ["envelope " ]["typ " ]);
187+ $ this ->assertEquals ("client_id " , $ attributes ["payload " ]["aud " ]);
188+ }
189+
190+ public function testVerifySignedJwtWithBadIssuer ()
191+ {
192+ $ id_token = $ this ->makeSignedJwt (
193+ array (
194+ "iss " => "fake.gserviceaccount.com " ,
195+ "aud " => "client_id " ,
196+ "sub " => self ::USER_ID ,
197+ "iat " => time (),
198+ "exp " => time () + 3600
199+ )
200+ );
201+
202+ $ issuers = ['system.gserviceaccount.com ' , 'https://system.gserviceaccount.com ' ];
203+ $ this ->checkIdTokenFailure ($ id_token , 'Invalid issuer ' , $ issuers [0 ]);
204+ $ this ->checkIdTokenFailure ($ id_token , 'Invalid issuer ' , $ issuers );
205+ }
206+
164207 public function testVerifySignedJwtWithBadJwt ()
165208 {
166209 $ this ->checkIdTokenFailure ("foo " , "Wrong number of segments " );
0 commit comments