如何使用Rally.RestApi.dll进行SSO?
直到现在,我已经读到Rally RestAPI不支持SSO登录。我认为,截至2014年1月,这种情况已不再属实。在支持SSO登录的Rally Excel加载项(这里是的链接)中使用了相同的API。我可以获得Rally Excel加载项的源代码吗?或者至少有人可以提供一个使用Rally RestAPI的SSO示例如何使用Rally.RestApi.dll进行SSO?,rally,Rally,直到现在,我已经读到Rally RestAPI不支持SSO登录。我认为,截至2014年1月,这种情况已不再属实。在支持SSO登录的Rally Excel加载项(这里是的链接)中使用了相同的API。我可以获得Rally Excel加载项的源代码吗?或者至少有人可以提供一个使用Rally RestAPI的SSO示例 我想做与Excel加载项导出功能完全相同的事情,但我想在纯.net应用程序中做同样的事情。我们的工具包目前不支持SSO。我们使用了一些特殊的技巧来让它为Excel插件工作,但是没有一个界
我想做与Excel加载项导出功能完全相同的事情,但我想在纯.net应用程序中做同样的事情。我们的工具包目前不支持SSO。我们使用了一些特殊的技巧来让它为Excel插件工作,但是没有一个界面足够友好,可以与我们的开发者社区共享
我们正在开发一个OAuth解决方案,它将使这样的项目更容易完成。一旦它发货,我们应该发布一个博客,向您展示它的功能。我个人的希望是,我们所有的工具包都能支持简化OAuth的使用。我在C#Rest Api中添加了一个howto,它解释了如何像Rally在Excel插件中那样进行SSO身份验证。我把它贴在这里是为了方便 谢谢,斯科特 一本简短的入门书 Rally Web Services API(WSAPI)本机仅支持基本身份验证。使用基本身份验证,必须使用用户名和密码启动WSAPI会话,该用户名和密码根据直接存储在Rally中的用户名和密码列表进行验证。在客户端开始使用单点登录(SSO)之前,这一切都可以正常工作。SSO允许客户端使用单个企业范围的身份验证机制(如LDAP或Active Directory)来管理用户凭据和密码。到目前为止,在启用SSO的情况下使用WSAPI需要客户端在Rally中为所有希望使用Rally WSAPI的用户维护一个重复的用户列表(“白色”列表)。最近对Rally的更改现在允许WSAPI用户使用其SSO凭据访问Rally,并减少了将这些用户保留在“白名单”中的需要 注意:Rally当前的SSO实现基于SAML规范,该规范要求用户与浏览器交互以完成身份验证。因此,这种技术需要用户与浏览器交互,因此它与无头WSAPI客户端(如与VCS和bug跟踪工具同步的Rally)不兼容 启动SSO连接时,用户提供一个URL,该URL启动与Rally的服务提供商(SP)的SSO握手,随后涉及客户端的身份提供商(IdP),并使用代表有效身份验证会话的Cookie响应Rally。如果已验证的会话cookie包含在任何后续WSAPI调用中,Rally将将这些调用与已验证的用户关联,并且WSAPI调用将被验证。为了便于在成功进行SAML SSO身份验证后访问经过身份验证的会话cookie以进行WSAPI调用,Rally查找添加到初始SSO URL的参数,该参数如果存在,将返回一个特殊网页,其中以明文形式包含会话cookie,作为SSO握手的最终产物。用户可以使用该数据构造一个cookie,以便在后续WSAPI调用中使用 注意:下面的示例URL(可能)特定于Rally的内部SSO实现。由于SSO用于允许客户使用自己的SSO基础设施(至少是IdP部分)提供自己的身份验证,因此SSO URL将是特定于客户的。请联系您的Rally TAM或Rally支持人员以获取有关SSO URL的帮助 原始SSO URL类似于:
https://sso.rallydev.com/sp/startSSO.ping?PartnerIdpId=pingidp.f4tech.com-29577
特殊参数为:
TargetResource=https://us1.rallydev.com/slm/j_sso_security_check?noRedirect=true
注意:此名称/值对使用PingIdentity作为SSO提供程序在Rally的特定SSO实现中设置SSO RelayState。其他SSO提供程序可能使用不同的参数名称来设置RelayState。例如,某些SSO提供程序使用RelayState作为参数名。在任何情况下,值都是相同的(即“”)
因此,完整的URL如下所示:
https://sso.rallydev.com/sp/startSSO.ping?PartnerIdpId=pingidp.f4tech.com-29577&TargetResource=https://us1.rallydev.com/slm/j_sso_security_check?noRedirect=true
如果用户在身份验证后导航到此修改的SSO URL,则会显示一个包含以下内容的网页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>SSO Token</title>
</head>
<body>
<form>
<input type="hidden" name="authCookieName" value="ZSESSIONID"/>
<input type="hidden" name="authCookieValue" value="khkjhkhkhkhkjhh"/>
</form>
</body>
</html>
将IConnectionInfo用于SSO时,调用方必须实现DoSSOAuth()。下面是一个带注释的示例
public class MyConnectionInfo : Rally.RestApi.ConnectionInfo
{
public override void doSSOAuth()
{
// Launch a browser to the this.server URI.
// The browser will close automatically if it successfully reaches the SSO landing page
// Users can cancel the SSO handshake
// Abort if the handshake is successful, but didn't arrive at the SSO landing page
var ssoDialog = new SSOAuthDialog(server);
DialogResult result = ssoDialog.ShowDialog();
if (result == DialogResult.Cancel)
throw new Exception("SSO authorization canceled");
else if (result == DialogResult.Abort)
throw new Exception(ssoDialog.abortReason);
// Parse the SSO landing page into a Cookie and save it
AuthCookie = parseSSOLandingPage(ssoDialog.getBrowser().DocumentText);
// Infer Cookie values from SO Landing Page URL if not set
if (String.IsNullOrWhiteSpace(authCookie.Domain) || authCookie.Domain == "null")
authCookie.Domain = ssoDialog.getBrowser().Url.Host;
AuthCookie.Secure = String.Equals(ssoDialog.getBrowser().Url.Scheme,"https",StringComparison.InvariantCultureIgnoreCase);
// Set a specific port port if the SSO Landing Page URL has one
if (!ssoDialog.getBrowser().Url.IsDefaultPort)
Port = ssoDialog.getBrowser().Url.Port;
}
}
本例使用带有浏览器组件的WinForms对话框向用户演示SSO握手。请记住,您可以使用任何要实现此部分的显示技术。以下是一个带注释的示例:
public partial class SSOAuthDialog : Form
{
public String abortReason;
public SSOAuthDialog(Uri url)
{
InitializeComponent();
webBrowser.Url = url;
}
private void documentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// We have found the SSO Landing Page.
if (webBrowser.DocumentText.Contains("authCookieName") && webBrowser.DocumentText.Contains("authCookieValue"))
{
Trace.TraceInformation("Found SSO authentication token on page: {0}", e.Url.AbsolutePath);
DialogResult = DialogResult.OK;
Close();
}
// We have landed on the Rally ALM page
// This is usually caused by a bad URL
else if (webBrowser.DocumentText.Contains("window.FEATURE_TOGGLES"))
{
abortReason = String.Format("The SSO handshake was successful, but the 'RelayState' was not correctly set. Contact your administrator to obtain the correct URL parameter to set the SSO handshake 'RelayState' to: https://rally1.rallydev.com/slm/j_sso_security_check?noRedirect=true");
Trace.TraceError(abortReason);
DialogResult = DialogResult.Abort;
Close();
}
}
public WebBrowser getBrowser()
{
return webBrowser;
}
}
SSO Example:
var cInfo = new MyConnectionInfo();
cInfo.Server = new Uri("https://host");
cInfo.AuthType = Rally.RestApi.AuthorizationType.SSO;
// This will cause an SSO authentication event
var conn = new RallyRestApi(cInfo);
// This will not b/c it will just use the auth Cookie already in cInfo
var conn2 = new RallyRestApi(cInfo);
将IConnectionInfo用于SSO时,缓存发送来构造RallyRestApi的IConnectionInfo对象非常重要。成功的SSO握手后,生成的auth Cookie存储在IConnectionInfo对象中,并将用于从该RallyRestApi对象进行的所有后续WSAPI调用。如果需要使用以前成功的SSO登录中的相同身份验证Cookie创建另一个RallyRestApi对象,只需使用相同的IConnectionInfo对象构造一个新的RallyRestApi对象,如果存在身份验证Cookie,则将使用它
重试
授权cookie可能会过期。C#ReST Api将检测过期的SSO Cookie,并根据需要启动新的SSO登录会话以获取新的有效Cookie
这就是全部。哇,斯科特,这太棒了。非常感谢!是否可以将.net应用程序连接到SSO,以将SSO令牌聚合并移交给java应用程序,以便java应用程序可以使用令牌调用rest服务?
public partial class SSOAuthDialog : Form
{
public String abortReason;
public SSOAuthDialog(Uri url)
{
InitializeComponent();
webBrowser.Url = url;
}
private void documentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// We have found the SSO Landing Page.
if (webBrowser.DocumentText.Contains("authCookieName") && webBrowser.DocumentText.Contains("authCookieValue"))
{
Trace.TraceInformation("Found SSO authentication token on page: {0}", e.Url.AbsolutePath);
DialogResult = DialogResult.OK;
Close();
}
// We have landed on the Rally ALM page
// This is usually caused by a bad URL
else if (webBrowser.DocumentText.Contains("window.FEATURE_TOGGLES"))
{
abortReason = String.Format("The SSO handshake was successful, but the 'RelayState' was not correctly set. Contact your administrator to obtain the correct URL parameter to set the SSO handshake 'RelayState' to: https://rally1.rallydev.com/slm/j_sso_security_check?noRedirect=true");
Trace.TraceError(abortReason);
DialogResult = DialogResult.Abort;
Close();
}
}
public WebBrowser getBrowser()
{
return webBrowser;
}
}
SSO Example:
var cInfo = new MyConnectionInfo();
cInfo.Server = new Uri("https://host");
cInfo.AuthType = Rally.RestApi.AuthorizationType.SSO;
// This will cause an SSO authentication event
var conn = new RallyRestApi(cInfo);
// This will not b/c it will just use the auth Cookie already in cInfo
var conn2 = new RallyRestApi(cInfo);