Add TODO: 请在不同的环境使用不同的key(即更换jwks.json中的文件内容); 如何生成不同的key请参考 JwksTest.java 类. / 以及必要注释
parent
61c66304c4
commit
373f738168
|
@ -66,6 +66,7 @@ public class OAuth2ServerConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* keystore file name
|
* keystore file name
|
||||||
|
* TODO: 请在不同的环境使用不同的key(即更换jwks.json中的文件内容); 如何生成不同的key请参考 JwksTest.java 类.
|
||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
|
@ -213,6 +214,7 @@ public class OAuth2ServerConfiguration {
|
||||||
/**
|
/**
|
||||||
* 提供加密/解密的 source
|
* 提供加密/解密的 source
|
||||||
* 可多个 key, 根据不同的需要来选择使用
|
* 可多个 key, 根据不同的需要来选择使用
|
||||||
|
* TODO: 请在不同的环境使用不同的key(即更换jwks.json中的文件内容); 如何生成不同的key请参考 JwksTest.java 类.
|
||||||
*
|
*
|
||||||
* @return JWKSource
|
* @return JWKSource
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class JwksTest {
|
||||||
// Curve point = Curve.P_521;
|
// Curve point = Curve.P_521;
|
||||||
|
|
||||||
ECKeyGenerator ecKeyGenerator = new ECKeyGenerator(point);
|
ECKeyGenerator ecKeyGenerator = new ECKeyGenerator(point);
|
||||||
|
//key 使用范围请根据业务场景设置, 范围越小越好
|
||||||
ecKeyGenerator.keyOperations(Set.of(
|
ecKeyGenerator.keyOperations(Set.of(
|
||||||
SIGN,
|
SIGN,
|
||||||
VERIFY,
|
VERIFY,
|
||||||
|
@ -64,10 +65,12 @@ public class JwksTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void jwkRS() throws Exception {
|
void jwkRS() throws Exception {
|
||||||
|
//size 至少 1024, 推荐 2048
|
||||||
RSAKeyGenerator rsaKeyGenerator = new RSAKeyGenerator(2048);
|
RSAKeyGenerator rsaKeyGenerator = new RSAKeyGenerator(2048);
|
||||||
|
// keyId 必须唯一
|
||||||
rsaKeyGenerator.keyID("sos-rsa-kid2")
|
rsaKeyGenerator.keyID("sos-rsa-kid2")
|
||||||
.algorithm(JWSAlgorithm.RS256)
|
.algorithm(JWSAlgorithm.RS256)
|
||||||
|
//key 使用范围请根据业务场景设置, 范围越小越好
|
||||||
.keyOperations(Set.of(
|
.keyOperations(Set.of(
|
||||||
SIGN,
|
SIGN,
|
||||||
VERIFY,
|
VERIFY,
|
||||||
|
|
Loading…
Reference in New Issue