在明显正确的关联后,Azure 身份验证在 JMeter 中不起作用

问题描述 投票:0回答:1

我正在尝试开发一个 JMeter 脚本,用于使用 Azure (Oauth2) 身份验证对应用程序进行性能测试。现在我被登录过程的自动化困住了。

这些是我在脚本中的相关要求:

  1. 访问登录屏幕:GET https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize 具有以下参数:
  • sso_reload=真
  • scope=openid 配置文件 offline_access https://graph.microsoft.com/user.read
  • response_type=代码
  • redirect_uri=https://${server}/azure-ad-interface-provider/login/getAuthCode
  • state=${state}(在上一步中捕获)
  • nonce=${nonce}(在上一步中捕获)
  • client_id=${client_id}(在上一步中捕获)
  • response_mode=查询

从这个请求中,我捕获了以下参数以供稍后使用:

  • sCx
  • 流币
  • 金丝雀
  • apicanary
  • hpgrequest-id
  • 客户请求ID
  1. 输入用户名:POST https://login.microsoftonline.com/common/GetCredentialType?mkt=en-US 使用以下 JSON 正文: {“用户名”:“${username}”,“isOtherIdpSupported”:true,“checkPhones”:false,“isRemoteNGCSupported”:true,“isCookieBannerShown”:false,“isFidoSupported”:true,“originalRequest”:“${ sCtx}","country":"${country}","forceotclogin":false,"isExternalFederationDisallowed":false,"isRemoteConnectSupported":false,"federationFlags":0,"isSignup":false,"flowToken": "${flowToken}","isAccessPassSupported":true}*

此请求有一个正确的响应,一个包含有关用户和要打开的会话的信息的 JSON。

  1. 输入密码:POST https://login.microsoftonline.com/{tenant_id}/login 使用以下参数:
  • PPSX
  • IsFidoSupported=1
  • ps=2
  • hisScaleUnit=
  • hpgrequestid=${hpgrequestid}
  • i13=0
  • 登录=${用户名}
  • 类型=11
  • 登录选项=3
  • flowToken=${flowToken}
  • psRNGC熵=
  • loginfmt=${用户名}
  • isSignupPost=0
  • 新用户=1
  • 金丝雀=${金丝雀}
  • 他的地区
  • ctx=${sCtx}
  • psRNGCDefaultType=
  • CookieDisclosure=0
  • lrt分区=
  • i21=0
  • lrt=
  • psRNGCSLK=
  • passwd=${密码}
  • FoundMSAs=
  • fspost=0

这个请求应该返回这样的响应:

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html dir="ltr" class="" lang="es">
<head>
    <title>**Sign into the account**</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <link rel="preconnect" href="https://aadcdn.msftauth.net" crossorigin>
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="dns-prefetch" href="//aadcdn.msftauth.net">
<link rel="dns-prefetch" href="//aadcdn.msauth.net">

    <meta name="PageID" content="**ConvergedTFA**" />
...

并且此请求还应返回脚本使用的持久性 cookie,以保持会话打开。

然而,它正在返回:

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html dir="ltr" class="" lang="es">
<head>
    <title>**Redirecting**</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta name="PageID" content="**BssoInterrupt**" />
...

并且没有返回任何 cookie。所以脚本在下一步失败,因为没有有效地执行登录。 我也在使用 Cookie 管理器。实际上,其余的 cookie 正在按预期生成,直到最后一步。

你能告诉我我可能做错了什么吗? 提前致谢。

azure authentication oauth-2.0 jmeter correlation
1个回答
0
投票

如果您绝对确定您的最后一个请求是正确的并且您正确关联了每个动态值,因为最后一个请求是重定向,那么使用 Location 标头中的 URL 重复它可能就足够了。

或者很可能你的最后一个请求格式不正确,将它与真实浏览器发送的请求进行交叉检查,并确保它看起来完全一样(除了需要关联的动态值)。最好使用像 FiddlerWireshark 这样的第 3 方嗅探器工具,这样您就可以并排比较请求。

最可疑的部分是

NewUser=1
,如果您使用现有用户登录,我希望它是
0
.

我也不认为您需要在上次请求时发送

ctx
canary
参数的值(但是您的应用程序可能配置不同)。

您可以查看如何使用 JMeter 文章在 OAuth 安全应用程序上运行性能测试,特别是 atlassian-microsoft-oauth.jmx 示例测试计划。

© www.soinside.com 2019 - 2024. All rights reserved.