我正在尝试实现一个满足资源服务器 OAuth 角色的服务 (API)。我们有一个实现隐式流程的 Angular 客户端应用程序。我们使用 GLUU 作为我们的 OpenID 提供者。id_token
客户端应用程序能够从授权服务器成功获取(JWT)。但是,当它调用 API(将该令牌作为授权标头中的不记名令牌传递)时,资源服务器无法尝试验证它。我收到一条JwkException
消息:enc (use) is currently not supported.
我正在使用我的 GLUU 服务器提供的端点进行配置security.oauth2.resource.jwk.key-set-uri
(application.yml
https ://[my-gluu-server-host]/oxauth/restv1/jwks)
资源服务器中的故障发生在这种方法中:org.springframework.security.oauth2.provider.token.store.jwk.JwkSetConverter.createRsaJwkDefinition(Map<String, String>)
具体来说,它发生在以下块中,它从/oxauth/restv1/jwks
端点解析文档:
// use
JwkDefinition.PublicKeyUse publicKeyUse = JwkDefinition.PublicKeyUse.fromValue(attributes.get(PUBLIC_KEY_USE));
if (!JwkDefinition.PublicKeyUse.SIG.equals(publicKeyUse)) {
throw new JwkException((publicKeyUse != null ? publicKeyUse.value() : "unknown") + " (" + PUBLIC_KEY_USE + ") is currently not supported.");
}
来自 GLUU 服务器的 jwks 文档除其他键外,还包括以下内容:
{
"kid": "2f2963f5-2e69-448d-8d4b-a0c573a0ae12",
"kty": "RSA",
"use": "sig",
"alg": "RS256",
"exp": 1561073429125,
"n": "1i27yldjaqy1E43560by_mWC9weI9jilYGIHIYc_1nSM0QdVMg3OU-NVBfAcDZhw0ghJ4uZIyjnVVUBp-QqZfvQ9nMVPcYDb3Fycbag3jQ2zYJfU_lAVOoSQquq_Tk8pa4NlJWIbiEFCpkLlNZVZdP8950aZVJX5Z5AzZq6CognrnItuyjNxyA25r244dZyDiShvQ7AC3nX8u04AKTSu-bVBMuZEtJVb7wH3KDxUzgPSj-xZ2ddA9Af9I-GNKpIj5lM7KVun3GMKoVh_NsLVODAbBsJZpG_wKcN0IuHdtoJG3pCD95JmpaSUIlYbvnHH9y19tC45v5dHXUEyv1x8bw",
"e": "AQAB",
"x5c": [
"MIIDBDCCAeygA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JKoZIhvcNAQELBQADggEBABhoycn6/mX07QTWcJ5G9neSjwur7iJxzcI2I3oXvewHQ+Hd5WI5YDh0zIBK5wAmaveUGWVTLHQayh1eOape0u+cHjaK1uoyB9j/PmRXgvVihpxG+oRHR6vWIb2BUzSNZ9zZLlDFhov3ZLeT4qtetj3Zp5WYd4mnTbmqZDHoXOu/ApXvIqCR0wnMZs90fK9ye/gImur2eLi145yyp2t1Q7HP6MqFhyX6lBXETyzJrgIxekJr0gOBrtAx4/DC8gODMsfDJI94QSso/l0EBp5Gmb1auwVT8g8B1yesOJmavcmnDADsqc3GjZTUt4DfDBl5sIulX4lcwEuYAyJV8BhgkNs="
]
}
所以我的问题是,为什么org.springframework.security.oauth2.provider.token.store.jwk.JwkSetConverter
当它看到一个不是用于签名的密钥时会抛出异常?在我看来,集合中是否有加密密钥并不重要。
可能我可以告诉 GLUU 不要包含这些键,但我似乎找不到任何支持这项工作的文档。
任何想法如何解决这个问题?