Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frankhefeng/xk6-oauth-pkce
OAuth PKCE extension for K6
https://github.com/frankhefeng/xk6-oauth-pkce
k6 oauth2 pkce pkce-authentication xk6 xk6-extension
Last synced: 4 months ago
JSON representation
OAuth PKCE extension for K6
- Host: GitHub
- URL: https://github.com/frankhefeng/xk6-oauth-pkce
- Owner: frankhefeng
- License: gpl-3.0
- Created: 2022-06-05T14:11:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-10T11:13:44.000Z (8 months ago)
- Last Synced: 2024-07-30T21:05:26.069Z (6 months ago)
- Topics: k6, oauth2, pkce, pkce-authentication, xk6, xk6-extension
- Language: Go
- Homepage:
- Size: 12 MB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xk6-oauth-pkce
`xk6-oauth-pkce` is a [k6](https://go.k6.io/k6) [extension](https://github.com/grafana/xk6) provides the capability to generate [OAuth PKCE](https://datatracker.ietf.org/doc/html/rfc7636) code verifier and code challenge.
## Build
To build a `k6` binary with this extension, first ensure you have the prerequisites:
- [Go toolchain](https://go101.org/article/go-toolchain.html)
- GitThen:
1. Download [xk6](https://github.com/grafana/xk6):
```bash
$ go install go.k6.io/xk6/cmd/xk6@latest
```2. [Build the k6 binary](https://github.com/grafana/xk6#command-usage):
```bash
$ xk6 build --with github.com/frankhefeng/xk6-oauth-pkce@latest
```# Example
```javascript
import pkce from "k6/x/oauth-pkce";export default function () {
const verifier = pkce.create("S256");
console.log(verifier);
console.log(verifier.verifier);
console.log(verifier.challenge);
}
```Result output:
```shell
./k6 run plain.js/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .ioexecution: local
script: plain.js
output: -scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)INFO[0000] d4pvC50QvNMo9kpvxnWJWIBzst3LZlZVhA4bBhd1wGBwc7Qdvl4YErYx8XzOFHOt source=console
INFO[0000] "PLAIN" source=console
INFO[0000] d4pvC50QvNMo9kpvxnWJWIBzst3LZlZVhA4bBhd1wGBwc7Qdvl4YErYx8XzOFHOt source=consoledata_received........: 0 B 0 B/s
data_sent............: 0 B 0 B/s
iteration_duration...: avg=171.26µs min=171.26µs med=171.26µs max=171.26µs p(90)=171.26µs p(95)=171.26µs
iterations...........: 1 3703.703704/srunning (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.0s/10m0s 1/1 iters, 1 per VU
``````shell
./k6 run s256.js/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .ioexecution: local
script: s256.js
output: -scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)INFO[0000] {"verifier":"35UoJSej40X87vZLreSjUck3QfkjpvAw07aKOgwQY3FMjT2OfRG3G9aMdzkZhMtU","challenge_method":"S256","challenge":"HjKS897Yv8kjD5AX-s0mBsug4EzbjgiVSmUubkHNz58"} source=console
INFO[0000] 35UoJSej40X87vZLreSjUck3QfkjpvAw07aKOgwQY3FMjT2OfRG3G9aMdzkZhMtU source=console
INFO[0000] HjKS897Yv8kjD5AX-s0mBsug4EzbjgiVSmUubkHNz58 source=consoledata_received........: 0 B 0 B/s
data_sent............: 0 B 0 B/s
iteration_duration...: avg=250.45µs min=250.45µs med=250.45µs max=250.45µs p(90)=250.45µs p(95)=250.45µs
iterations...........: 1 3003.003003/srunning (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.0s/10m0s 1/1 iters, 1 per VU
```