Ibm mobilefirst 从应用到适配器再到最终服务的LTPA令牌传播

Ibm mobilefirst 从应用到适配器再到最终服务的LTPA令牌传播,ibm-mobilefirst,ltpa,Ibm Mobilefirst,Ltpa,我试图使用和理解worklight中LTPA安全性的使用以及LTPA cookie的传播 我能够再次对WAS进行身份验证,使用嗅探器,我可以看到worklight会返回LtpaToken2 cookie,但当我调用HTTP适配器时,该适配器会调用与worklight服务器位于同一台机器中的其他WAS中的服务,该适配器不会传播cookie 我想我已经设置了正确的配置。(最后) 是否可以将worklight server配置为自动将LTPA令牌从应用程序传播到适配器,并从适配器传播到最终服务 如果无

我试图使用和理解worklight中LTPA安全性的使用以及LTPA cookie的传播

我能够再次对WAS进行身份验证,使用嗅探器,我可以看到worklight会返回LtpaToken2 cookie,但当我调用HTTP适配器时,该适配器会调用与worklight服务器位于同一台机器中的其他WAS中的服务,该适配器不会传播cookie

我想我已经设置了正确的配置。(最后)

是否可以将worklight server配置为自动将LTPA令牌从应用程序传播到适配器,并从适配器传播到最终服务

如果无法自动执行,如何在适配器代码中检索Ltpa cookie,以便将其添加到WL.Server.invokeHTTP()方法的headers参数中

这是我的安全配置:

<realm loginModule="WASLTPAModule" name="BPMAuthRealm"> 
    <className>com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator</className>
    <parameter name="login-page" value="/login.html"/>
    <parameter name="error-page" value="/login.html"/>
    <parameter name="cookie-name" value="LtpaToken2"/>
</realm>

<loginModule name="WASLTPAModule" canBeResourceLogin="true" isIdentityAssociationKey="false">
    <className>com.worklight.core.auth.ext.WebSphereLoginModule</className>
</loginModule>

<mobileSecurityTest name="BPMApp-strong-mobile-securityTest">
    <testUser realm="BPMAuthRealm"/>
    <testDeviceId provisioningType="none"/>
</mobileSecurityTest>

<customSecurityTest name="BPMAdapter-securityTest">
    <test isInternalUserID="true" realm="BPMAuthRealm" isInternalDeviceID="true"/>
</customSecurityTest>
对于it工作,我必须在worklight studio中生成的自定义war中手动添加login.html

应用程序描述符:

<ipad bundleId="xxxx" securityTest="BPMApp-strong-mobile-securityTest" version="1.0">
<procedure connectAs="endUser" name="getRest" securityTest="BPMAdapter-securityTest"/>

适配器描述符:

<ipad bundleId="xxxx" securityTest="BPMApp-strong-mobile-securityTest" version="1.0">
<procedure connectAs="endUser" name="getRest" securityTest="BPMAdapter-securityTest"/>

安全配置:

<realm loginModule="WASLTPAModule" name="BPMAuthRealm"> 
    <className>com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator</className>
    <parameter name="login-page" value="/login.html"/>
    <parameter name="error-page" value="/login.html"/>
    <parameter name="cookie-name" value="LtpaToken2"/>
</realm>

<loginModule name="WASLTPAModule" canBeResourceLogin="true" isIdentityAssociationKey="false">
    <className>com.worklight.core.auth.ext.WebSphereLoginModule</className>
</loginModule>

<mobileSecurityTest name="BPMApp-strong-mobile-securityTest">
    <testUser realm="BPMAuthRealm"/>
    <testDeviceId provisioningType="none"/>
</mobileSecurityTest>

<customSecurityTest name="BPMAdapter-securityTest">
    <test isInternalUserID="true" realm="BPMAuthRealm" isInternalDeviceID="true"/>
</customSecurityTest>

com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator
com.worklight.core.auth.ext.WebSphereLoginModule

谢谢。

我相信这就是您要找的:

function getCurrentUser() {
path = '/snoop';
var attributes = WL.Server.getActiveUser().attributes;
var token = "LtpaToken=" + attributes.get('LtpaToken');

var input = {
    method : 'get',
    returnedContentType : 'html',
    headers: {"Cookie": token},
    path : path
};

return WL.Server.invokeHttp(input);
}

这段代码来自5.0.3,因此我认为新版本中从attributes对象获取令牌的语法可能已经改变

您可能需要更改:

var token = "LtpaToken=" + attributes.get('LtpaToken');
致:


但这就是我的想法。适配器不会在后续请求时发送cookie,但是通过用户的“attributes”对象,适配器可以使用cookie。只需在每次适配器调用时获取cookie并将其添加到头中即可。

我相信这就是您要寻找的:

function getCurrentUser() {
path = '/snoop';
var attributes = WL.Server.getActiveUser().attributes;
var token = "LtpaToken=" + attributes.get('LtpaToken');

var input = {
    method : 'get',
    returnedContentType : 'html',
    headers: {"Cookie": token},
    path : path
};

return WL.Server.invokeHttp(input);
}

这段代码来自5.0.3,因此我认为新版本中从attributes对象获取令牌的语法可能已经改变

您可能需要更改:

var token = "LtpaToken=" + attributes.get('LtpaToken');
致:


但这就是我的想法。适配器不会在后续请求时发送cookie,但是通过用户的“attributes”对象,适配器可以使用cookie。只需在每次适配器调用时获取cookie并将其添加到头中即可。

谢谢Jeremy,它可以工作,代码是WL.Server.getActiveUser().attributes.LtpaToken。ltpa cookie传播是从应用程序到适配器,而不是从适配器到服务。这里还要注意,应用程序的传播是对任何http请求进行的,不仅仅是对适配器,在我的应用程序中,我必须打开一个iFrame,它用iFrame请求传播令牌。在用户属性中,ltpa令牌始终与密钥LtpaToken一起存储,但在cooke中,它与在authentication-config.xml中设置的cookie name参数一起存储。谢谢Jeremy,它可以工作,代码是WL.Server.getActiveUser().attributes.LtpaToken。ltpa cookie传播是从应用程序到适配器,而不是从适配器到服务。这里还要注意,应用程序的传播是对任何http请求进行的,不仅仅是对适配器,在我的应用程序中,我必须打开一个iFrame,它用iFrame请求传播令牌。在用户属性中,ltpa令牌始终与密钥LtpaToken一起存储,但在cooke中,它与authentication-config.xml中设置的cookie name参数一起存储