@@ -394,9 +394,11 @@ private ClientDetailsEntity validateGrantTypes(ClientDetailsEntity newClient) th
394
394
// set default grant types if needed
395
395
if (newClient .getGrantTypes () == null || newClient .getGrantTypes ().isEmpty ()) {
396
396
if (newClient .getScope ().contains ("offline_access" )) { // client asked for offline access
397
- newClient .setGrantTypes (Sets .newHashSet ("authorization_code" , "refresh_token" )); // allow authorization code and refresh token grant types by default
397
+ // allow authorization code, client credentials and refresh token grant types by default
398
+ newClient .setGrantTypes (Sets .newHashSet ("authorization_code" , "client_credentials" , "refresh_token" ));
398
399
} else {
399
- newClient .setGrantTypes (Sets .newHashSet ("authorization_code" )); // allow authorization code grant type by default
400
+ // allow authorization code grant type by default
401
+ newClient .setGrantTypes (Sets .newHashSet ("authorization_code" , "client_credentials" ));
400
402
}
401
403
}
402
404
@@ -418,8 +420,7 @@ private ClientDetailsEntity validateGrantTypes(ClientDetailsEntity newClient) th
418
420
if (newClient .getGrantTypes ().contains ("authorization_code" )) {
419
421
420
422
// check for incompatible grants
421
- if (newClient .getGrantTypes ().contains ("implicit" ) ||
422
- newClient .getGrantTypes ().contains ("client_credentials" )) {
423
+ if (newClient .getGrantTypes ().contains ("implicit" )) {
423
424
// return an error, you can't have these grant types together
424
425
throw new ValidationException ("invalid_client_metadata" , "Incompatible grant types requested: " + newClient .getGrantTypes (), HttpStatus .BAD_REQUEST );
425
426
}
@@ -430,15 +431,12 @@ private ClientDetailsEntity validateGrantTypes(ClientDetailsEntity newClient) th
430
431
}
431
432
432
433
newClient .getResponseTypes ().add ("code" );
433
-
434
-
435
434
}
436
435
437
436
if (newClient .getGrantTypes ().contains ("implicit" )) {
438
437
439
438
// check for incompatible grants
440
- if (newClient .getGrantTypes ().contains ("authorization_code" ) ||
441
- newClient .getGrantTypes ().contains ("client_credentials" )) {
439
+ if (newClient .getGrantTypes ().contains ("authorization_code" )) {
442
440
// return an error, you can't have these grant types together
443
441
throw new ValidationException ("invalid_client_metadata" , "Incompatible grant types requested: " + newClient .getGrantTypes (), HttpStatus .BAD_REQUEST );
444
442
}
@@ -456,14 +454,7 @@ private ClientDetailsEntity validateGrantTypes(ClientDetailsEntity newClient) th
456
454
}
457
455
458
456
if (newClient .getGrantTypes ().contains ("client_credentials" )) {
459
-
460
- // check for incompatible grants
461
- if (newClient .getGrantTypes ().contains ("authorization_code" ) ||
462
- newClient .getGrantTypes ().contains ("implicit" )) {
463
- // return an error, you can't have these grant types together
464
- throw new ValidationException ("invalid_client_metadata" , "Incompatible grant types requested: " + newClient .getGrantTypes (), HttpStatus .BAD_REQUEST );
465
- }
466
-
457
+
467
458
if (!newClient .getResponseTypes ().isEmpty ()) {
468
459
// return an error, you can't have this grant type and response type together
469
460
throw new ValidationException ("invalid_client_metadata" , "Incompatible response types requested: " + newClient .getGrantTypes () + " / " + newClient .getResponseTypes (), HttpStatus .BAD_REQUEST );
0 commit comments