简体   繁体   English

如何使用 Oauth PKCE 流程在 Jmeter 中生成授权码

[英]How to generate Authorization code in Jmeter with Oauth PKCE flow

I'm trying to generate Authorization code in Jmeter with Oauth PKCE flow could'nt extract code any thoughts here would be helpful.我正在尝试使用 Oauth PKCE 流无法提取代码在 Jmeter 中生成授权代码,这里的任何想法都会有所帮助。

Refer your application documentation as the implementations might be different.请参阅您的应用程序文档,因为实现可能会有所不同。

Some parameters cannot be "extracted", ie you need to know your client_id beforehand.有些参数不能被“提取”,即你需要事先知道你的client_id

Some parameters needs to be generated, if no documentation is available you can use ie Call Your API Using the Authorization Code Flow with PKCE which contains comprehensive explanation and example code snippets for creating code_verifier and code_challenge需要生成一些参数,如果没有可用的文档,您可以使用 ie Call Your API Using the Authorization Code Flow with PKCE ,其中包含用于创建code_verifiercode_challenge的全面说明和示例代码片段

Example code for code_verifier generation: code_verifier生成的示例代码:

import java.security.SecureRandom;

SecureRandom sr = new SecureRandom();
byte[] code = new byte[32];
sr.nextBytes(code);
String verifier = Base64.getUrlEncoder().withoutPadding().encodeToString(code);

log.info('code_verifier: ' + verifier)

vars.put('verifier', verifier)

在此处输入图像描述

Example code for code_challenge code_challenge的示例代码

import java.security.MessageDigest
import org.apache.commons.codec.binary.Base64

byte[] bytes = vars.get('verifier').getBytes("US-ASCII");
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(bytes, 0, bytes.length);
byte[] digest = md.digest();
String challenge = Base64.encodeBase64URLSafeString(digest);

log.info('code_challenge: ' + challenge)

在此处输入图像描述

The code can be invoked from theJSR223 Test Elements using Groovy as the language可以使用Groovy作为语言从JSR223 测试元素调用代码

暂无
暂无

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

相关问题 For OAuth PKCE flow in JMeter 无法提取Code值 - For OAuth PKCE flow in JMeter unable to extract Code values Angular 中的 PKCE 授权代码流程与 angular-oauth2-oidc - Authorization Code Flow with PKCE in Angular with angular-oauth2-oidc 如何处理移动应用程序的重定向URL-使用PKCE的OAuth 2.0授权代码流 - How to handle redirect url for mobile application - OAuth 2.0 Authorization Code Flow with PKCE 移动应用究竟是如何通过PKCE实现授权码流的? - How exactly do mobile apps achieve authorization code flow with PKCE? OAuth2.0,员工客户端如何用PKCE实现授权码? - OAuth2.0, How to implement authorization code with PKCE for staff client? 使用 PKCE 的授权代码流如何比没有 client_secret 的授权代码流更安全 - How can Authorization Code Flow with PKCE be more secure than Authorization Code Flow without client_secret 在带有 PKCE 的 OAuth 2.0 授权代码流中,什么阻止在第一次调用身份验证服务器时拦截代码质询? - In the OAuth 2.0 Authorization Code Flow with PKCE what prevents intercepting the code challenge on the first call to the auth server? 我应该在哪里存储 code_verifier(使用 PKCE 的 oauth 2.0 代码授权流程) - Where I should store code_verifier (oauth 2.0 code authorization flow with PKCE) Active Directory 是否不支持 PKCE 的授权代码流? - Is Active Directory not supporting Authorization Code Flow with PKCE? OAuth 使用 PKCE 的授权代码流不会触发 /token API 获取令牌 - OAuth Authorization code flow with PKCE does not trigger /token API to get token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM