Worklight Apps pointing to different Worklight Servers - ibm-mobilefirst

I want to distribute my Worklight App via the App Store. The problem is, users will have to point to different Worklight Servers depending on what company they belong to, but I don't want my users to have visibility to the Worklight Server URL or have the ability to change it themselves (meaning I want to set worklightSettings in the application-descriptor.xml to false so "Custom Server URL" does not appear in the settings).
So my idea is to initially point all my users to a default Worklight Server (in which they would only connect to the first time the start the app) which would be responsible for identifying which server they should point to based of some credentials. Once the user gives the server their credentials, it will respond with the Worklight Server URL they should connect to and then the application will set it so they will now always connect to the proper server for their company.
I know in the iPhone for example, the URL lives in worklight.plist and before I build it, I can change that value to set my url, but can I change that url after the .ipa is built without having the user manually change the "Custom Server URL" in the settings? Perhaps there's a way to change the "Custom Server URL" value programatically and always have "Use Custom URL" true, but hide it from the user in the settings?

Though not supported (at all) by Worklight, this can be accomplished. See if Anton's answer for the following question is of help:
Re-route/Divert some WL.Client Adapter Invocation traffic to WL Server through different URL (for PCI payment and security requirements)?

Related

How to deploy SSRS through App Proxy or Website

I'm having a very tough time getting this to work. We are using SSRS to view reports on our internal network. However, I would like to deploy SSRS so users from home can use it since we're working from home more frequently. I will supply a screenshot of the current config with the App Proxy settings and maybe you can point something out that I am doing wrong because I'm lost at this point and google has stopped helping.
At this moment, I am trying to deploy SSRS using App Proxy from Azure, however, if you know another way, please let me know.
Again, this is a simple deployment. We simply access SSRS using a http/s address internally and it works fine. I just want users to be able to use it from Home through a website.
App Proxy Settings
App Proxy Cont.
This ended up being a bit of a journey.
Do not install your AD Connect or App Proxy connectors on a Domain Controller. Put them on the same virtual server by themselves.
Set up your SQL Server and Oracle all under a domain service account. If you haven't done this already, get ready to reinstall because it's likely that manually switching the SPN keys isn't going to work.
Leave the default App Proxy settings alone when you Configure App Proxy.
If you have a weblink like reporting.domain.com/reports in Azure you MUST make sure you have reporting.domain.com/reports/ do not forget the extra / at the end.
App Proxy with SSRS will now work.
Use this as your overall guide
https://learn.microsoft.com/en-us/power-bi/report-server/azure-application-proxy

How to change MobileFirst 8 server URL dynamically from client (Mobile Application)?

I am working on ionic 3 with MobileFirst 8.x in it. To connect server I have configured URL in config.xml file.
Is there any way to change server URL dynamically while using application?
URL change occurs only once and after that we will connect the services which are secure under any scopes.
MobileFirst server version :- 8.0.0.00-20170911-123510
MobileFirst Cordova(plugin) version :- 8.0.2017102403
I can see that provision was there in MobileFirst 7.x :-
https://mobilefirstplatform.ibmcloud.com/blog/2015/02/02/changing-server-url-runtime/
Yes. Use the WL.App.setServerURL to achieve this. Usage details here
You have not mentioned why you intend to use the API. This API comes handy in development environments. For example, switching between dev or staging server instances.
Important points to note:
1) As this API points the client application to a new server, client id associated with the earlier server is reset. The application will register fresh to the new server.
2) Authentication contexts created by the earlier server is reset. You will be challenged again by the new server.
You should use this API judiciously and with caution.

IBM Worklight Console: Protected Worklight Console in Liberty Server asked to Authetication twice

I have created a server in liberty and installed IBM Worklight in it.
Everything was working fine till I protect the console.
After protecting the IBM Worklight console the authentication is asked
twice.
First Login Screen with URL localhost:9080
After Login Successful.Again the login is being asked with the hostmachines URL 192.168.10.16:9080
My questions are
Why login appears twice?
Why my hostmachine ip is being revealed?
You are accessing the console with address localhost, whereas in your code you are either using publicWorklightHosname=192.168.10.16 or while building you are using build for remote machine and then putting in IP of the server.
Here is what you need to do:
Make sure a DNS entry of the hostname is present in the server and client machine
Change the publicWorklightHostname property in worklight.properties file to a proper address eg
mymachine.mydomain.com
while building for Remote Server, use the same address as above i.e. mymachine.mydomain.com
redeploy the new war file
Worked perfectly for me.
P.S> I believe you are using local machine, in this case also you can use the machine name in worklight.properties file and make sure that the address you are using is same as the one you used to build. Nonetheless, it doesn;t matter in production or application deployment.

IBM Worklight: Calling Push Notification Adapter from backend

I have implemented a Push Notification adpater and would like backend system to call the procedure in order to submit notification.
With reference to this post, http://server:port/dev/invoke?adapter=adapterName&procedure=procedureName&parameters=1,2,3 can be used but it works in development environment only.
At the end of the post it is mentioned that http://server:port/context/invoke?adapter=adapterName&procedure=procedureName&parameters=1,2,3 can be used to invoke the adapter.
(1) May I know whether it is supported in production environment only? Because it returned HTTP method GET is not supported by this URL in development environment.
(2) Noted that we might need to define securityTest="wl_unprotected" for the adapter and thus the adapter is not protected. What will be the best way to achieve the goal for backend sytem to call the adapter with security control?
In Worklight 5, Worklight Studio uses Jetty within and the usage of a context root is not required. Only once moving your project to an application server such as Tomcat, WebSphere, Liberty, you have to specify it (in worklight.properties and application-descriptor.xml).
So,
in development - no.
in production - yes.
In Worklight 6 where Jetty has been replaced with Liberty, context root is now part of your project whether you are in development or production.
You will have to add the "wl_unprotected" securityTest to your procedure in the adapter XML.
As for protecting the requests, my guess is that your IT department can isolate and protect specific URLs and not allow using them in certain scenarios. You already have the URL structure for them to use.

Detect Worklight Server Hostname/IP Address from Worklight Client code

For a variety of reasons, I need programatic JavaScript access the the hostname or IP address of the Worklight server from the client code.
For example:
- I want to pull scripts and resources from the same host as the Worklight server
- I have an out-of-band service on the Worklight host and I want to connect to it
#IdanAdar has said that the address does not exist. I've search the WL object and cannot find it either. See Can we get the app version and IP address info using worklight api?.
Note that document.location.hostname is null when running as a native app.
My current workaround is to set the IP Address / hostname as a global variable in my top-level html file. This is not ideal because it causes my sourcecode to have to vary by implementation.
Worklight already has this value externalized in the application-descriptor.xml
The server side API has this exposed in WL.Server.configuration["local.IPAddress"]. I think the client should expose an API similar to this as well.
Although not the best option you can develop an adapter that returns the WL.Server.configuration["local.IPAddress"] if available, also could be possible to acces to the IP through the http request.
Is it possible to access to the HTTPRequest in the worklight adapter implementation?
I'm not sure if you can invoke adapters before wlCommonInit, if you can not and you need the ip before the common init then this approach is useless.