IBM Worklight 6.0 - Mixed port numbers after enabl

2019-02-21 00:57发布

问题:

Wishing to have a Worklight Console Authentication I followed the infocenter instructions from this link at infocenter.It seems to be working at the first glance as entering the console it prompts the login form.

Going to the console URL at http://192.168.168.154:9080/finance/console/#catalog it brings the login page right away. So far so good.

After entering the right username/password (both defined at worklight.properties) the login page redirects to the Worklight console at port 10080 and fails to load the page

Unable to connect Firefox can't establish a connection to the server at 192.168.168.154:10080.

As you can read it tries to connect to http://192.168.168.154:10080/finance/console. It should not happen I guess, as port 10080 was not configured.

I have no idea why it is redirecting to this port. I searched inside the config files for 10080 and could not find any reference to it. I think somehow WL is getting this 10080 as a default as it is the port used for development.

Here is the files snippets I am using to enable Login Console:

worklight.properties:

#publicWorkLightHostname=localhost
# http or https
#publicWorkLightProtocol=http
# For default port leave empty
#publicWorkLightPort=10080  <-- it is commented out

console.username=finance
console.password=finance

authenticationConfig.xml

 <staticResources>
    <resource id="worklightConsole" securityTest="WorklightConsole">
            <urlPatterns>/console*</urlPatterns>
    </resource> 
    ....
</staticResources>

 <securityTests>

        <customSecurityTest name="WorklightConsole">
            <test realm="WorklightConsole" isInternalUserID="true"/>
        </customSecurityTest>
  ...
</securityTests>

server.xml

   <httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="9080"
                  httpsPort="9443" >
        <tcpOptions soReuseAddr="true"/>
    </httpEndpoint>
    <!-- Declare the JNDI properties for the IBM Worklight Console. -->
    <jndiEntry jndiName="worklight/publicWorkLightProtocol" value='"http"'/>
    <jndiEntry jndiName="worklight/publicWorkLightPort" value='"9080"'/>
    <jndiEntry jndiName="worklight/serverSessionTimeout" value='"10"'/>

Any idea on how to solve this port mismatch issue ? Env is WL 6.0 on Liberty

P.S: Later on we plan to user LDAP instead. For now, having the username/passaword in the properties would suffice.

回答1:

In worklight.properties, uncomment the #publicWorkLightPort=10080 property and change it to 9080.

worklight.properties is part of the Worklight project's .war file that is deployed into the application server; the application server may have its own port number set in server.xml, but the .war (project) has some specific properties of its own.

During my testing I encountered the same issue, but once uncommenting and changing the port value in worklight.properties, the re-direct then worked properly after logging-in.