From 929a94dc73c82796dec9f70bac4c5d11427430bb Mon Sep 17 00:00:00 2001 From: Vigneshan Date: Wed, 16 Dec 2020 11:55:37 +0530 Subject: [PATCH 1/2] Add jwt bearer grant type for sso service providers --- .../entgra/ui/request/interceptor/SsoLoginHandler.java | 10 ++++++++-- .../ui/request/interceptor/util/HandlerConstants.java | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 1ea7d030e1..620040c0d7 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -228,8 +228,14 @@ public class SsoLoginHandler extends HttpServlet { */ private StringEntity constructAppGrantTypeUpdatePayload() { JSONObject jsonObject = new JSONObject(); - jsonObject.put("supportedGrantTypes", new JSONArray(new Object[]{HandlerConstants.CODE_GRANT_TYPE, - HandlerConstants.REFRESH_TOKEN_GRANT_TYPE, HandlerConstants.PASSWORD_GRANT_TYPE})); + jsonObject.put("supportedGrantTypes", + new JSONArray(new Object[]{ + HandlerConstants.CODE_GRANT_TYPE, + HandlerConstants.REFRESH_TOKEN_GRANT_TYPE, + HandlerConstants.PASSWORD_GRANT_TYPE, + HandlerConstants.JWT_BEARER_GRANT_TYPE + }) + ); jsonObject.put(HandlerConstants.CALLBACK_URL_KEY, iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK); String payload = jsonObject.toString(); return new StringEntity(payload, ContentType.APPLICATION_JSON); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 8c0e79c2a6..1efcb84f95 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -52,6 +52,7 @@ public class HandlerConstants { public static final String CODE_GRANT_TYPE = "authorization_code"; public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; public static final String PASSWORD_GRANT_TYPE = "password"; + public static final String JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String SCHEME_SEPARATOR = "://"; public static final String COLON = ":"; From 931fb8ef54b61975e031e4198e310c4a1fd09bc1 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 16 Dec 2020 21:16:38 +0530 Subject: [PATCH 2/2] Add windows agent token generation parameters to config API --- .../wso2/carbon/device/mgt/core/DeviceManagementConstants.java | 2 +- .../org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index 41b96665e6..df5f030684 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -50,7 +50,7 @@ public final class DeviceManagementConstants { private ConfigurationManagement(){ throw new AssertionError(); } - public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event"; + public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event perm:windows:enroll"; public static final String IOT_GATEWAY_HOST = "iot.gateway.host"; public static final String IOT_GATEWAY_HTTPS_PORT = "iot.gateway.https.port"; public static final String APPLICATION_REGISTRATION_API_ENDPOINT = diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 95d68727e7..7822754208 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -812,6 +812,7 @@ public final class DeviceManagerUtil { applicationRegistration.setApplicationName("MyApp"); applicationRegistration.setAllowedToAllDomains(false); List tags = new ArrayList<>(); + tags.add("windows"); tags.add("device_management"); applicationRegistration.setTags(tags); applicationRegistration.setValidityPeriod(3600);