From e0fe22e4ba8179e861b79730c1d4420cd02b16de Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Mon, 9 Jun 2014 20:20:36 -0400 Subject: [PATCH] don't regenerate client secrets every single time --- .../connect/web/ClientDynamicRegistrationEndpoint.java | 6 ++++-- .../connect/web/ProtectedResourceRegistrationEndpoint.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java index dcb32e055..8d82d7a05 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java @@ -506,8 +506,10 @@ public class ClientDynamicRegistrationEndpoint { newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_JWT || newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_POST) { - // we need to generate a secret - newClient = clientService.generateClientSecret(newClient); + if (Strings.isNullOrEmpty(newClient.getClientSecret())) { + // no secret yet, we need to generate a secret + newClient = clientService.generateClientSecret(newClient); + } } else if (newClient.getTokenEndpointAuthMethod() == AuthMethod.PRIVATE_KEY) { if (Strings.isNullOrEmpty(newClient.getJwksUri())) { throw new ValidationException("invalid_client_metadata", "JWK Set URI required when using private key authentication", HttpStatus.BAD_REQUEST); diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java index 9ec90a729..0c4ca78de 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java @@ -412,8 +412,10 @@ public class ProtectedResourceRegistrationEndpoint { newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_JWT || newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_POST) { - // we need to generate a secret - newClient = clientService.generateClientSecret(newClient); + if (Strings.isNullOrEmpty(newClient.getClientSecret())) { + // no secret yet, we need to generate a secret + newClient = clientService.generateClientSecret(newClient); + } } else if (newClient.getTokenEndpointAuthMethod() == AuthMethod.PRIVATE_KEY) { if (Strings.isNullOrEmpty(newClient.getJwksUri())) { throw new ValidationException("invalid_client_metadata", "JWK Set URI required when using private key authentication", HttpStatus.BAD_REQUEST);