From 65d18fd037493a747a56a8d269cb90d5f85ba986 Mon Sep 17 00:00:00 2001 From: Vigneshan Date: Wed, 23 Nov 2022 09:01:25 +0000 Subject: [PATCH] Fix invalid admin credentials issue in token endpoint --- .../extension/api/KeyManagerService.java | 2 -- .../extension/api/KeyManagerServiceImpl.java | 2 -- .../extension/service/KeyMgtServiceImpl.java | 23 +------------------ 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java index e95bae064d..dfd6af295a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java @@ -40,8 +40,6 @@ public interface KeyManagerService { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/token") Response generateAccessToken(@HeaderParam("Authorization") String basicAuthHeader, - @FormParam("client_id") String clientId, - @FormParam("client_secret") String clientSecret, @FormParam("refresh_token") String refreshToken, @FormParam("scope") String scope, @FormParam("grant_type") String grantType, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 69d36e9b00..961951f865 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -63,8 +63,6 @@ public class KeyManagerServiceImpl implements KeyManagerService { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/token") public Response generateAccessToken(@HeaderParam("Authorization") String basicAuthHeader, - @FormParam("client_id") String clientId, - @FormParam("client_secret") String clientSecret, @FormParam("refresh_token") String refreshToken, @FormParam("scope") String scope, @FormParam("grant_type") String grantType, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 18714867f1..49fc818851 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -160,26 +160,6 @@ public class KeyMgtServiceImpl implements KeyMgtService { String tenantDomain = MultitenantUtils.getTenantDomain(application.getOwner()); -// String username, password; -// if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) { -// kmConfig = getKeyManagerConfig(); -// username = kmConfig.getAdminUsername(); -// password = kmConfig.getAdminPassword(); -// } else { -// try { -// username = getRealmService() -// .getTenantUserRealm(-1234).getRealmConfiguration() -// .getRealmProperty("reserved_tenant_user_username") + "@" + tenantDomain; -// password = getRealmService() -// .getTenantUserRealm(-1234).getRealmConfiguration() -// .getRealmProperty("reserved_tenant_user_password"); -// } catch (UserStoreException e) { -// msg = "Error while loading user realm configuration"; -// log.error(msg); -// throw new KeyMgtException(msg); -// } -// } - RequestBody appTokenPayload; switch (tokenRequest.getGrantType()) { case "client_credentials": @@ -197,8 +177,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { case "refresh_token": appTokenPayload = new FormBody.Builder() .add("grant_type", "refresh_token") - .add("refresh_token", tokenRequest.getRefreshToken()) - .add("scope", tokenRequest.getScope()).build(); + .add("refresh_token", tokenRequest.getRefreshToken()).build(); break; case "urn:ietf:params:oauth:grant-type:jwt-bearer": appTokenPayload = new FormBody.Builder()