Picture of Niko 1071
Registered 12 years 109 days
Niko 1071 Thursday, 4 July 2019, 02:15 PM
External URL as iFrame in myApps ?
Hello,

I would like to integrate an external website into an innovaphone app. Ideally, the app should also tell you which user (innovaphone PBX extensions) has called this page. Is there already sample code for this ?

Many thanks
greetings
Niko
Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 5 July 2019, 01:47 PM
Re: External URL as iFrame in myApps ?
I have played a little bit with myApps and here are the things I found out so far.
  1. innovaphone.ui1.createNode can't create iframes
    it would be nice if this mehtod would return the new created node and
    not this which stands for innovaphone.ui1
  2. the documentation for every entry in the section "JavaScript library for App" is missing
  3. A strange problem which occurs sometimes when I create a new myAPPs project with visual studio it does not copy all the required files. I have
    also seen that they are created but will be left empty.
Now to the part which is kind of strange.

I have created an iframe with this javascript code:

var iframe = document.createElement('iframe');

iframe.setAttribute('url', 'www.google.de');
iframe.setAttribute('width', '100%');
iframe.setAttribute('height', '100%');

document.body.appendChild(iframe);

It shows in the HTML view but it will not load anything. I would say it could be related to the fact that the app in itself is an iframe. If that is the case than is it possible to change the call for the main iframe in which the app is loaded.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Friday, 5 July 2019, 02:22 PM
Re: External URL as iFrame in myApps ?
You can create iframes with new innovaphone.ui1.node("iframe"), which does what you sample code does and a little bit more.

I am not sure if an iframe can be added right to the body of an HTML page, maybe this is the reason why nothing is displayed.

The app itself is an iframe, but iframes inside an App work fine. We are doing this in some Apps.

We know there are gaps in our documentation. It would help us to fill these gaps, if you tell exactly what you are missing.
Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 5 July 2019, 02:34 PM
Re: External URL as iFrame in myApps ?
A start would be the documentation for ui1.lib, so that I'am able to use it.

How does the complete call look like for an iframe with url, width and height
attributes?
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Friday, 5 July 2019, 02:41 PM
Re: External URL as iFrame in myApps ?
There should be a file sdk/web1/ui1.lib/ui1.lib.htm in the SDK.

You should also find it when opening sdk.htm and navigate to Reference
Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 5 July 2019, 02:49 PM
Re: External URL as iFrame in myApps ?
Ah I found it. Thank you.

But the links in sdk/13r1/doc/reference.htm#JS_library are wrong. They point to sdk/13r1/web/ui1.lib/ui1.lib.htm and not to sdk/13r1/web1/ui1.lib/ui1.lib.htm
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 236 days
Daniel Deterding (innovaphone) Friday, 5 July 2019, 03:26 PM
Re: External URL as iFrame in myApps ?
The links are wrong in SR2. They should be fixed with SR3 smile

Greetings,
Daniel
Picture of Sascha
Registered 6 years 31 days
Sascha Monday, 8 July 2019, 09:31 AM in response to Guntram Diehl (innovaphone)
Re: External URL as iFrame in myApps ?
I have changed the creation of the iframe like you suggested but I will not see the data which should be loaded by the iframe.

var iframe = new innovaphone.ui1.Node('iframe');

iframe.container.setAttribute('url', '{any URL you want to use}');
iframe.container.setAttribute('width', '100%');
iframe.container.setAttribute('height', '100%');

var divTest = this.add(new innovaphone.ui1.Div('', iframe));

I have tested it with url's from us which can be called in an iframe.

Is there a setAttribute method which I could use instead of the
iframe.container.setAttribute?

Have you a guidline on how to extend your javascript classes?


Picture of Sascha
Registered 6 years 31 days
Sascha Tuesday, 9 July 2019, 03:22 PM
Re: External URL as iFrame in myApps ?
Nevermind I have found my mistake...
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Friday, 5 July 2019, 02:15 PM in response to Niko 1071
Re: External URL as iFrame in myApps ?
You can load an external website directly by putting the URL in the App Objekt and mark this as "Plain Website".
Be aware that some websites explicitly prohibt loading in an iframe.
You also do not get the user authentication in this case.

You can easily implement the checking the PBX authentication in your external website, so that it can be loaded as "innovaphone App". I am in the process of creating a tutorial in the SDK for that. Should be a matter of a couple of days.
Picture of Peter 627
Registered 14 years 10 days
Peter 627 Tuesday, 9 July 2019, 02:40 PM
Re: External URL as iFrame in myApps ?
Hello Guntram,

"You can easily implement the checking the PBX authentication in your external website".

Is there any documantation about this implementation.
I would like to check the PBX Authentication in some of our Websites, which are written in PHP. Is this possible ?

Best Regards,

Peter
Picture of Sascha
Registered 6 years 31 days
Sascha Tuesday, 9 July 2019, 03:28 PM
Re: External URL as iFrame in myApps ?
I think you mean this tutorial which is new.

External App Service - External web services may be integrated in myApps the same as services running on an App Platform. The minimum requirement is, that these should make use of the PBX authentication. This tutorial explains how to integrate the PBX authentication in such a web service.

You can find it in the SR3 release of the innovaphone SDK.
Picture of Peter 627
Registered 14 years 10 days
Peter 627 Tuesday, 9 July 2019, 04:48 PM
Re: External URL as iFrame in myApps ?
Hi Sascha,

yes a little bit, but i don't understand the Tutorial.
The Topic is as you mention "External App Service....." , or further ...
" External web services may be integrated in myApps the same as services running on an App Platform. The minimum requirement is, that these should make use of the PBX authentication. This tutorial explains how to integrate the PBX authentication in such a web service. For demonstration purposes we implement a simple HTTP GET handler in our NewApp1 project to simulate the external web service. This functionality can then be transfered to the external web service to whatever technology (PHP, Go, Java, ...) is used there"

So the topic is "integration of external App Service which is not running on App Platform" but it shows how to do this by writing an App for App Platform big grin .

It would be easier to understand it, if there would be an completly example in php.

Because now i understand, if i want to do this in php, i have to transfer the code from the mentioned "GET Handler" to php . Right ?

Best Regards,

Peter

Picture of Sascha
Registered 6 years 31 days
Sascha Wednesday, 10 July 2019, 08:20 AM
Re: External URL as iFrame in myApps ?
Yes, I know what you mean.

As far as I have seen and understand it you have to build your php backend in the way it is implemented in the c++ in the tutorial.

It would be easier to understand if we would have both sides descriped in the tutorial so that we could see what the request would look like from the c++ to the other backend which has to validate the request.

I would also like to know where I can read the needed parameters for the reqeust to the backend which has to verify everything.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 09:30 AM
Re: External URL as iFrame in myApps ?
I don't understand which info you are missing. The tutorial is supposed to be self contained, so that you can see all sides.

In the C++ code you can see how the request is verified. This is done, by a shared secret, which is configured in the App Object and in the Backend of the Webservice. For simplicity sake we do not configure this this password in the Backend of the webservice, but use just "secret".

So there is no othe communication needed.

Does this answer the question, or am I missing something?
Picture of Sascha
Registered 6 years 31 days
Sascha Wednesday, 10 July 2019, 10:07 AM
Re: External URL as iFrame in myApps ?
I try to discribe the process of the login as I have understood it.

First you will need a secret phrase which is known on both sides but never disclosed via any request.

  1. The app which want's to do a authentification makes a request to the backend which is written in any language you want to. So the request should be like this: backenurl.de/api?mt=AppChallenge as return you will get the challenge which is generated by the backend which is used by both sides to prevent an attack.
  2. The app sends a request backenurl.de/api?mt=AppLogin&app={}&domain={}&sip={}&guid={}&dn={}&challenge={used from the first request}&digest={}
  3. If everything is okay the backend send back this json {"mt":"AppLoginResult","ok":true}
  4. If the authentification fails you send only a empty json object
I hope this is the logic you want us to use for this authentification process

Now where can I get these parameters from in my application?
app
domain
sip
guid
dn

I would know how to get the dn and guid from your old soap api but not in the new my apps api.

How do I know who is logged in, in the myapps frontend?
Is there an extra api where I can get these informations from?
Where should I store the php session cookie for example?
How can I send the cookie in the header informations on an later request from the app?
Have you tried json web tokens with this as a pseudo session?
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 10:31 AM
1 of 1 users consider this post helpful
Re: External URL as iFrame in myApps ?
This part ist done in phpsession.js to be precise it is the code
 function onpostmessage(e) { var obj = JSON.parse(e.data); if (obj.mt && obj.mt == "Login") { console.log(app + ": AppLogin(" + obj.sip + "@" + obj.domain + ")"); httpGet(url + "?mt=AppLogin&app=" + encodeURIComponent(obj.app) + "&domain=" + encodeURIComponent(obj.domain) + "&sip=" + encodeURIComponent(obj.sip) + "&guid=" + encodeURIComponent(obj.guid) + "&dn=" + encodeURIComponent(obj.dn) + (obj.info ? "&info=" + encodeURIComponent(JSON.stringify(obj.info)) : "") + "&digest=" + encodeURIComponent(obj.digest) + "&challenge=" + encodeURIComponent(challenge), onlogin); } }
You get all the information from the App Client with a browser window message and forward it to the Backend of the Web service.

The hash code covers all the arguments, so in your Backend you can be sure they are not changed, when the digest matches.
Picture of Sascha
Registered 6 years 31 days
Sascha Wednesday, 10 July 2019, 10:47 AM
Re: External URL as iFrame in myApps ?
Thank you.

This covers the part in javascript. Is there a way to get these informations from a event in the c++ side?
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 11:06 AM
Re: External URL as iFrame in myApps ?
On the C++ side, which means the Webserver Backend, you get this information from the URL arguments:

 char * app = UrlArg(resourceName, "&app=", tmp); char * domain = UrlArg(resourceName, "&domain=", tmp); char * sip = UrlArg(resourceName, "&sip=", tmp); char * guid = UrlArg(resourceName, "&guid=", tmp); char * dn = UrlArg(resourceName, "&dn=", tmp); char * info = UrlArg(resourceName, "&info=", tmp); char * challenge = UrlArg(resourceName, "&challenge=", tmp); char * digest = UrlArg(resourceName, "&digest=", tmp); 
Picture of Sascha
Registered 6 years 31 days
Sascha Wednesday, 10 July 2019, 11:08 AM
Re: External URL as iFrame in myApps ?
Yes when you have a frontend which can do the request to your c++ side.

But how would it look like if you would have a "hidden" app which has no
javascript side.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 11:16 AM
Re: External URL as iFrame in myApps ?
But I thought this was the whole point to have something integrated in myApps? Can you give an example so that I understand?
Picture of Sascha
Registered 6 years 31 days
Sascha Wednesday, 10 July 2019, 12:07 PM
Re: External URL as iFrame in myApps ?
I would use it as some kind of monitoring app which runs in the background and would send an info to a webservice. For example when the user hase done a forwarding.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 01:01 PM
1 of 1 users consider this post helpful
Re: External URL as iFrame in myApps ?
We have the concept of hidden Apps, which could do this. These could be loaded in the background.
The only issue at the moment is to trigger that such an App is loaded. We can do this if the App provides an API. In this case it is loaded, when tha API is consumed by another App.

We just discussed how to solve your case. We would need two simple additions to the system:
  • An API which is consumed by the Client isself. This way an App would be started if it provided this API
  • To avoid the need of a Websocket connection from the App Object to your webservice, we would need to allow to configure the APIs provided at the App Object statically
Seems to be fairly simple. We need to discuss this here a little bit more in Detail.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Wednesday, 10 July 2019, 09:38 AM in response to Peter 627
Re: External URL as iFrame in myApps ?
Yes this is the idea smile This way we can do completely self contained samples, which actually work without relying on any other piece of infrastructure.

I tried to write the C++ code in a way, that you should be able to understand, even if you are no C++ expert. If there are questions, just post it here.
Picture of Peter 627
Registered 14 years 10 days
Peter 627 Wednesday, 10 July 2019, 11:22 AM
Re: External URL as iFrame in myApps ?
Ok i got it. For my quick test, i just have done it by using a short quick and dirty code smile.

1. I changed the "login.htm" in the script header to
--> new innovaphone.PhpSession("login.php", name.split("=")[1], "webservice.htm", "");

2. i placed a login.php on my webserver with following code.
---------------------------------------
<?php
if (( $_GET["mt"]) == "AppChallenge"){
$myObj->mt = "AppChallengeResult";
$myObj->challenge = 1234;
$myJSON = json_encode($myObj);
echo $myJSON;
}
if (( $_GET["mt"]) == "AppLogin"){
$myObj->mt = "AppLoginResult";
$myObj->ok = "true";
$myJSON = json_encode($myObj);
echo $myJSON;
}
?>

-----------------------------------------

Now for testing the short example of your tutorial is fully working for me.

Now my task is, to implement the security.

Best Regards,

Peter


Picture of Peter 627
Registered 14 years 10 days
Peter 627 Wednesday, 10 July 2019, 02:21 PM in response to Guntram Diehl (innovaphone)
Re: External URL as iFrame in myApps ?
Hello Guntram,

i have done some tests and it is working now for me.
Could i send you my package out of the forum?
It would be nice to get Feedback about the security implementation and the funtionality.

Another Question is..

Should i see this Authentication Process for the innovaphone Apps too ?
I have compared opening my Webpage with opening Reporting App in Browser Console. And when i open the Reporting App, i don't see the GET Variables which are used for the shared secret.

Best Regards,

Peter




Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 12 July 2019, 11:54 AM in response to Guntram Diehl (innovaphone)
Re: External URL as iFrame in myApps ?
I have used your tutorial to create the app which emulates the webservice part for the login part.

First some imporvements I would recommend for your tutorial.
  1. The info that I have to add the *.cpp file in my *.mak would have been a real help. I know that you want people with more experience to build the c++ of the myApps but I think you will also get many webdeveloper like myself who don't know that they have to add this. Is there a command to do that automatic?
  2. The second part where I hat some problems with was this part:
    "To integrate the code in the HTTP handler, you need to add the following lines to the function WebserverPluginHttpListenResult
 plugin->Accept(new WebserviceLogin(resourceName)); return; 
At the end of the if (requestType == WS_REQUEST_GET) clause."

I think here would a little bit more code be better so that someone who reads the tutorial know exactly what you want.

I ended up with this code:
if (requestType == WS_REQUEST_GET) {
if (plugin->BuildRedirect(resourceName, _BUILD_STRING_, strlen(_BUILD_STRING_))) {
return;
}

plugin->Accept(new WebserviceLogin(resourceName));
return;
}

plugin->Cancel(WSP_CANCEL_NOT_FOUND);
It works with this but I don't know if this is what you wanted me to do.

So but now I don't get a login which works my hashes don't match. Is there something missing that I don't know of? If I understand it correctly I should get a positiv result now or am I wrong?

This is the login Request I send out:
login?mt=AppLogin&app=testapp&domain=byon-int-v13.de&sip=Sascha&guid=50a73dec081f5d01eb560050569337b0&dn=Sascha&info=%7B%22appobj%22%3A%22testapp%22%2C%22appurl%22%3A%22https%3A%2F%2Fapps01.vtk.cloud%2Ftestapp%2Flogin.htm%22%2C%22cn%22%3A%22Sascha%22%2C%22unlicensed%22%3Atrue%2C%22apps%22%3A%5B%7B%22name%22%3A%22users%22%7D%2C%7B%22name%22%3A%22profile%22%7D%2C%7B%22name%22%3A%22users-apis%22%7D%2C%7B%22name%22%3A%22calllist-api%22%7D%2C%7B%22name%22%3A%22calllist%22%7D%2C%7B%22name%22%3A%22contacts%22%7D%2C%7B%22name%22%3A%22contacts-api%22%7D%2C%7B%22name%22%3A%22testapp%22%7D%5D%7D&digest=bbb1e64d1b8f072ff2b8d9d6e17b87d12632171e38b7bb1633df39a8011bfc50&challenge=1234

digest
bbb1e64d1b8f072ff2b8d9d6e17b87d12632171e38b7bb1633df39a8011bfc50

hash which is generated by the c++ part:
5e394bfef192598538786d5bf850172f4dafcd8ed3c4f7e39601d724431ac721

2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Friday, 12 July 2019, 01:11 PM
1 of 1 users consider this post helpful
Re: External URL as iFrame in myApps ?
1. The idea was to add this code to the existing C++ Source File, so that there is no change necessary in the makefile. I will look, if this was not clear.
2. What you did was correct, so there must be another reason, why the Hash does not work. The sample works with the fixed password "secret", did you use this in the config of the App object?
Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 12 July 2019, 01:19 PM
Re: External URL as iFrame in myApps ?
Oh thanks. No I have not used secret there as the password. I think this is the main problem here I will try it again and report back if it has worked.
Picture of Sascha
Registered 6 years 31 days
Sascha Friday, 12 July 2019, 01:52 PM in response to Guntram Diehl (innovaphone)
Re: External URL as iFrame in myApps ?
So I have changed the password to secret in the config for the app object. But the hashes do not match. sad

Request:
login?mt=AppLogin&app=testapp&domain=byon-int-v13.de&sip=Sascha&guid=50a73dec081f5d01eb560050569337b0&dn=Sascha&info=%7B%22appobj%22%3A%22testapp%22%2C%22appurl%22%3A%22https%3A%2F%2Fapps01.vtk.cloud%2Ftestapp%2Flogin.htm%22%2C%22cn%22%3A%22Sascha%22%2C%22unlicensed%22%3Atrue%2C%22apps%22%3A%5B%7B%22name%22%3A%22users%22%7D%2C%7B%22name%22%3A%22profile%22%7D%2C%7B%22name%22%3A%22users-apis%22%7D%2C%7B%22name%22%3A%22calllist-api%22%7D%2C%7B%22name%22%3A%22calllist%22%7D%2C%7B%22name%22%3A%22contacts%22%7D%2C%7B%22name%22%3A%22contacts-api%22%7D%2C%7B%22name%22%3A%22testapp%22%7D%5D%7D&digest=97956e36431e746c2731f64378557b3c5250dbb062f51c0f6428519f84680e35&challenge=1234

digest:
97956e36431e746c2731f64378557b3c5250dbb062f51c0f6428519f84680e35

digest_check:
5e394bfef192598538786d5bf850172f4dafcd8ed3c4f7e39601d724431ac721
Picture of Sascha
Registered 6 years 31 days
Sascha Tuesday, 16 July 2019, 08:14 AM in response to Guntram Diehl (innovaphone)
Re: External URL as iFrame in myApps ?
So I have played a litte more with the webservice tutorial.

login?mt=AppLogin&app=login.htm&domain=byon-int-v13.de&sip=Sascha&guid=50a73dec081f5d01eb560050569337b0&dn=Sascha&info=%7B%22appobj%22%3A%22testapp%22%2C%22appurl%22%3A%22https%3A%2F%2Fapps01.vtk.cloud%2Ftestapp%2Flogin.htm%22%2C%22cn%22%3A%22Sascha%22%2C%22unlicensed%22%3Atrue%2C%22apps%22%3A%5B%7B%22name%22%3A%22users%22%7D%2C%7B%22name%22%3A%22profile%22%7D%2C%7B%22name%22%3A%22users-apis%22%7D%2C%7B%22name%22%3A%22calllist-api%22%7D%2C%7B%22name%22%3A%22calllist%22%7D%2C%7B%22name%22%3A%22contacts%22%7D%2C%7B%22name%22%3A%22contacts-api%22%7D%2C%7B%22name%22%3A%22testapp%22%7D%5D%7D&digest=97956e36431e746c2731f64378557b3c5250dbb062f51c0f6428519f84680e35&challenge=1234

digest 97956e36431e746c2731f64378557b3c5250dbb062f51c0f6428519f84680e35
digest_check 97956e36431e746c2731f64378557b3c5250dbb062f51c0f6428519f84680e35

Now it works as expected. But why is the app parameter in the url set to &app=login.htm and not testapp which is the name of my app object.
2013
Moderator Registered 16 years 129 days
Guntram Diehl (innovaphone) Tuesday, 16 July 2019, 08:42 AM
Re: External URL as iFrame in myApps ?
App is setto the filename configured in the App object, because this is what is defined by the app provider and cannot be changed to anything by the admin of the PBX. This is the same name used in licenses on the PBX and thus can be used on the App service side to check, what was licensed.

In the sample a name login.htm was used to indicate what function is performed with this file. For a real App service, you would rather use the name of your App, esspecially if you want to sell a license for it.
Picture of Sascha
Registered 6 years 31 days
Sascha Tuesday, 16 July 2019, 08:51 AM
Re: External URL as iFrame in myApps ?
Thanks for the clarification on that one.
← You can define your color theme preference here