应该使用哪个OAuth 2.0提供程序的JWK来验证OpenID Connect`id_token`?

时间:2016-02-12 23:57:40

标签: oauth-2.0 openid-connect jwk

如果身份验证服务器提供多个JSON Web密钥(例如https://www.googleapis.com/oauth2/v3/certs),这些密钥应该用于验证OpenID Connect id_token是OPenID Connect Implicit Flow的一部分吗?

是否应使用第一个JSON Web密钥,所有JSON Web密钥验证id_token,或者如果可以使用这些提供的任何JSON Web密钥验证id_token,则<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com</groupId> <artifactId>distributed.analyzer</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>analyzer</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-core</artifactId> <version>4.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-jms</artifactId> <version>4.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.projectreactor</groupId> <artifactId>reactor-core</artifactId> <version>1.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.5</version> </dependency> </dependencies> <build> <plugins> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.distributed.analyzer.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.7</version> </dependency> </dependencies> </dependencyManagement> </project> 是否有效?

谢谢!

1 个答案:

答案 0 :(得分:1)

当OpenID Connect提供商可以使用多个密钥进行签名id_token时,id_token的标头通常会包含一个密钥标识符(在kid元素中)实际使用的密钥。这对应于您描述的(jwks_uri)端点上发布的JWK中的kid元素。因此id_token只有在使用与标题中的kid相关联的密钥进行验证时才有效。