Merge pull request #721 from hasuniea/master

fixing windows application tab issue wso2/product-iots#1060
merge-requests/1/head
Chatura Dilan 7 years ago committed by GitHub
commit dd5807fab8

@ -73,7 +73,6 @@
{{#zone "device-details-tab-injected"}} {{#zone "device-details-tab-injected"}}
<li><a data-toggle="tab" href="#location">Location</a></li> <li><a data-toggle="tab" href="#location">Location</a></li>
<li><a data-toggle="tab" href="#app">Applications</a></li>
<li><a data-toggle="tab" href="#policy">Policy Compliance</a></li> <li><a data-toggle="tab" href="#policy">Policy Compliance</a></li>
{{/zone}} {{/zone}}
@ -82,10 +81,6 @@
<iframe width="100%" height="100%" frameborder="0" style="border:0" <iframe width="100%" height="100%" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJk_gsqyVZ4joR4UxR7brwMnA&key=AIzaSyChgf100i4rBz6neCNRyK1D05g9VLY8jvo" allowfullscreen></iframe> src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJk_gsqyVZ4joR4UxR7brwMnA&key=AIzaSyChgf100i4rBz6neCNRyK1D05g9VLY8jvo" allowfullscreen></iframe>
</div> </div>
<div id="app" class="tab-pane fade">
<div id="applications-list-container" data-public-uri="{{@unit.publicUri}}">
</div>
</div>
<div id="policy" class="tab-pane fade"> <div id="policy" class="tab-pane fade">
<div id="policy-list-container"> <div id="policy-list-container">
</div> </div>
@ -116,11 +111,6 @@
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs" <script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
<!--suppress HtmlUnknownTarget -->
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
<!--suppress HtmlUnknownTarget -->
{{js "js/device-detail.js"}} {{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
{{js "js/load-map.js"}} {{js "js/load-map.js"}}

@ -6,15 +6,11 @@
"adminService":"%https.ip%", "adminService":"%https.ip%",
"oauthProvider": { "oauthProvider": {
"appRegistration": { "appRegistration": {
"appType": "webapp", "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register",
"clientName": "windows-web-agent", "applicationName":"windows-web-agent",
"owner": "admin@carbon.super", "tags":["windows"],
"dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "isAllowedToAllDomains":false,
"apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", "isMappingAnExistingOAuthApp":false
"grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer",
"tokenScope": "admin",
"callbackUrl": "%https.ip%/api/device-mgt/v1.0",
"samlGrantTypeName": "urn:ietf:params:oauth:grant-type:saml2-bearer"
}, },
"tokenServiceURL": "%https.ip%/oauth2/token" "tokenServiceURL": "%https.ip%/oauth2/token"
}, },

@ -41,25 +41,24 @@ var utils = function () {
return String(Base64.decodeBase64(String(payload).getBytes())); return String(Base64.decodeBase64(String(payload).getBytes()));
}; };
publicMethods["getDynamicClientAppCredentials"] = function () { publicMethods["getDynamicClientAppCredentials"] = function (username, password) {
// setting up dynamic client application properties // setting up dynamic client application properties
var dcAppProperties = { var dcAppProperties = {
"applicationType": deviceMgtProps["oauthProvider"]["appRegistration"]["appType"], "applicationName": deviceMgtProps["oauthProvider"]["appRegistration"]["applicationName"],
"clientName": deviceMgtProps["oauthProvider"]["appRegistration"]["clientName"], "tags": deviceMgtProps["oauthProvider"]["appRegistration"]["tags"],
"owner": deviceMgtProps["oauthProvider"]["appRegistration"]["owner"], "isAllowedToAllDomains": deviceMgtProps["oauthProvider"]["appRegistration"]["isAllowedToAllDomains"],
"tokenScope": deviceMgtProps["oauthProvider"]["appRegistration"]["tokenScope"], "isMappingAnExistingOAuthApp": deviceMgtProps["oauthProvider"]["appRegistration"]["isMappingAnExistingOAuthApp"]
"grantType": deviceMgtProps["oauthProvider"]["appRegistration"]["grantType"],
"callbackUrl": deviceMgtProps["oauthProvider"]["appRegistration"]["callbackUrl"],
"saasApp" : true
}; };
// calling dynamic client app registration service endpoint // calling dynamic client app registration service endpoint
var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"]
["dynamicClientAppRegistrationServiceURL"]; ["dynamicClientAppRegistrationServiceURL"];
var requestPayload = dcAppProperties; var requestPayload = dcAppProperties;
var encodedBasicOauth = publicMethods.encode(username + ":" + password);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", requestURL, false); xhr.open("POST", requestURL, false);
xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization","Basic "+ encodedBasicOauth);
xhr.send(stringify(requestPayload)); xhr.send(stringify(requestPayload));
var dynamicClientAppCredentials = {}; var dynamicClientAppCredentials = {};

@ -38,7 +38,7 @@ var handlers = function () {
"password grant type. Either username of logged in user, password or both are missing " + "password grant type. Either username of logged in user, password or both are missing " +
"as input - setupTokenPairByPasswordGrantType(x, y)"); "as input - setupTokenPairByPasswordGrantType(x, y)");
} else { } else {
privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); privateMethods.setUpEncodedTenantBasedClientAppCredentials(username, password);
var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (!encodedClientAppCredentials) { if (!encodedClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " +
@ -130,13 +130,13 @@ var handlers = function () {
} }
}; };
privateMethods["setUpEncodedTenantBasedClientAppCredentials"] = function (username) { privateMethods["setUpEncodedTenantBasedClientAppCredentials"] = function (username, password) {
if (!username) { if (!username) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context. No username of logged in user is found as " + "client credentials to session context. No username of logged in user is found as " +
"input - setUpEncodedTenantBasedClientAppCredentials(x)"); "input - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(username, password);
if (!dynamicClientAppCredentials) { if (!dynamicClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context as the server is unable to obtain " + "client credentials to session context as the server is unable to obtain " +

Loading…
Cancel
Save