简体   繁体   English

JMeter 授权配置使用 static API 令牌密钥

[英]JMeter authorization configuration using a static API token key

We are using JMeter v5.3 to run performance tests against our SIT Server instance of JIRA v8.13.22.我们正在使用 JMeter v5.3 对我们的 SIT 服务器实例 JIRA v8.13.22 运行性能测试。 We setup our JMeter tests with basic authentication via the "HTTP Authorization Manager" and the "Basic Digest" mechanism.我们通过“HTTP 授权管理器”和“基本摘要”机制使用基本身份验证设置 JMeter 测试。 We have recently installed the "API Token Authentication for Jira" plugin and turned off basic authentication to JIRA.我们最近安装了“API Token Authentication for Jira”插件并关闭了对 JIRA 的基本身份验证。 See: Plugin Admin docs .请参阅: 插件管理文档 Therefore all REST calls to JIRA via application accounts must now login with an application user that has a registered API key with JIRA.因此,通过应用程序帐户对 JIRA 的所有 REST 调用现在必须使用已注册 API 密钥的应用程序用户登录。

As expected, our JMeter tests now fail with "403 Forbidden" errors due to the Basic Auth setup with the error: "Basic Auth with password is disabled by the API Token Authentication app".正如预期的那样,我们的 JMeter 测试现在因“403 Forbidden”错误而失败,这是由于基本身份验证设置错误:“API 令牌身份验证应用程序禁用了带密码的基本身份验证”。 I found articles similar to JMeter Authorization with access token , but they use "authorization with dynamic access token".我发现类似于JMeter Authorization with access token的文章,但它们使用“动态访问令牌授权”。

How do we configure JMeter to authorize with a registered static API token key?我们如何配置 JMeter 以使用已注册的static API 令牌密钥进行授权?

Have you tried to read the documentation you linked yourself?您是否尝试阅读您自己链接的文档? Because the very first stanza which I see looks like:因为我看到的第一节看起来像:

The Token use itself is very simple - in the place where you would usually use the password, you just use the Token itself Token 本身的使用非常简单——在你通常会使用密码的地方,你只需使用 Token 本身

Previously you were sending Authorization header with the value of Basic followed by your Base64 encoded credentials (this is what HTTP Authorization Manager was doing under the hood).以前,您发送授权header 的值为Basic ,后跟Base64编码凭据(这是HTTP 授权管理器在幕后所做的)。 So all you need to do is to replace the password with the token and that would be it.所以你需要做的就是用令牌替换密码,就是这样。

You can also send the same Authorization header with the value of Bearer followed by your token value.您还可以发送相同的Authorization header,其值是Bearer ,后跟您的令牌值。 It can be done using HTTP Header Manager可以使用HTTP Header 管理器来完成

Here is an example of authenticating via curl:以下是通过 curl 进行身份验证的示例

curl "https://YOUR_JIRA_BASEURL/rest/api/2/myself" \
 -u '<USERNAME>:<YOUR_API_TOKEN>'

And in JMeter you can generate a Test Plan from curl command在 JMeter 中,您可以从 curl 命令生成测试计划

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM