{"id":20442574,"url":"https://github.com/masonm/wiremock-jwt-extension","last_synced_at":"2025-04-12T23:37:48.709Z","repository":{"id":23592396,"uuid":"99407596","full_name":"MasonM/wiremock-jwt-extension","owner":"MasonM","description":"WireMock extension for matching requests with JSON Web Tokens (JWT)","archived":false,"fork":false,"pushed_at":"2023-09-16T19:11:48.000Z","size":253,"stargazers_count":15,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:37:28.361Z","etag":null,"topics":["jwt","wiremock"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MasonM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-05T07:42:56.000Z","updated_at":"2024-05-22T07:22:05.000Z","dependencies_parsed_at":"2024-11-19T02:16:08.416Z","dependency_job_id":null,"html_url":"https://github.com/MasonM/wiremock-jwt-extension","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonM%2Fwiremock-jwt-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonM%2Fwiremock-jwt-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonM%2Fwiremock-jwt-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonM%2Fwiremock-jwt-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MasonM","download_url":"https://codeload.github.com/MasonM/wiremock-jwt-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647256,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","wiremock"],"created_at":"2024-11-15T09:41:34.136Z","updated_at":"2025-04-12T23:37:48.681Z","avatar_url":"https://github.com/MasonM.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\n[![Build Status](https://github.com/MasonM/wiremock-jwt-extension/actions/workflows/gradle.yml/badge.svg)](https://github.com/MasonM/wiremock-jwt-extension/actions/workflows/gradle.yml?query=branch%3Amaster)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.masonm/wiremock-jwt-extension/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.masonm/wiremock-jwt-extension)\n\nwiremock-jwt-extension consists of two extensions for [WireMock](http://wiremock.org): a [request matcher extension](http://wiremock.org/docs/extending-wiremock/#custom-request-matchers) and a [stub mapping transformer extension](http://wiremock.org/docs/record-playback/#transforming-generated-stubs).\n\nThe request matcher extracts JWT tokens from incoming requests and matches against the \"payload\" and/or \"header\" portions. The stub mapping transformer can transform recorded stub mappings to use the request matcher if there exists a JWT token in the \"Authorization\" header.\n\nJWE (JSON Web Encryption) and signature verification are not currently supported. Patches welcome!\n\n# Installation\n\nMaven:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.masonm\u003c/groupId\u003e\n    \u003cartifactId\u003ewiremock-jwt-extension\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle:\n```groovy\nimplementation 'com.github.masonm:wiremock-jwt-extension:1.0.0'\n```\n\n# Running\n\nThere are three ways of running the extension:\n\n1. Standalone, e.g.\n\n    ```sh\n    java -jar build/libs/wiremock-jwt-extension-1.0.0-standalone.jar\n    ```\n    \n2. As an extension of the WireMock standalone JAR, e.g.\n\n    ```sh\n    wget -nc https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/3.0.4/wiremock-standalone-3.0.4.jar\n    java \\\n            -cp wiremock-standalone-3.0.4.jar:build/libs/wiremock-jwt-extension-1.0.0.jar \\\n            wiremock.Run \\\n            --extensions=\"com.github.masonm.JwtMatcherExtension,com.github.masonm.JwtStubMappingTransformer\"\n    ```\n\n3. Programmatically in Java, e.g.\n\n    ```java\n    new WireMockServer(wireMockConfig()\n        .extensions(\"com.github.masonm.JwtMatcherExtension\", \"com.github.masonm.JwtStubMappingTransformer\"))\n    ```\n\n# Request matcher usage\n\nThe extension accepts the following parameters:\n* `header`: Key-value map of header fields to match, e.g. `{ \"alg\": \"HS256\" }`\n* `payload`: Key-value map of payload fields to match, e.g. `{ \"admin\": true }`. If the value is an array (e.g. `{ \"aud\": [\"aud1\", \"aud2\"] }`, it will be matched exactly.\n* `request`: (legacy) Any additional request matchers. Only for Wiremock versions before 2.20 that lacked support for composing standard and custom matchers.\n\nWhen using the API, make sure to set the `\"name\"` field of the customMatcher to `\"jwt-matcher\"`.  Here's an example cURL command that creates a stub mapping with the request matcher:\n```sh\ncurl -d@- http://localhost:8080/__admin/mappings \u003c\u003c-EOD\n{\n    \"request\" : {\n        \"url\" : \"/some_url\",\n        \"method\" : \"GET\",\n        \"customMatcher\" : {\n            \"name\" : \"jwt-matcher\",\n            \"parameters\" : {\n                \"header\" : {\n                    \"alg\" : \"HS256\",\n                    \"typ\": \"JWT\"\n                },\n                \"payload\": {\n                    \"name\" : \"John Doe\",\n                    \"aud\": [\"aud1\", \"aud2\"]\n                }\n            }\n        }\n    },\n    \"response\" : {\n        \"status\" : 200,\n        \"body\": \"success\"\n    }\n}\nEOD\n```\n\nExample request that matches the above stub mapping:\n```sh\ncurl -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJhdWQiOlsiYXVkMSIsImF1ZDIiXX0.h49E7AnYrJpttdEoi4GmoZUCtg6GBSHTSjUcDGnbjRI' http://localhost:8080/some_url\n```\n\n# Stub mapping transformer usage\n\nThe transformer has the name \"jwt-stub-mapping-transformer\" and accepts a list of payload fields to match against via the parameter \"payloadFields\". Example request to `POST /__admin/recordings/snapshot`:\n```json\n{\n    \"transformers\" : [ \"jwt-stub-mapping-transformer\" ],\n    \"transformerParameters\" : {\n        \"payloadFields\" : [ \"name\", \"admin\" ]\n    }\n}\n```\n\n# Building\n\nRun `gradle jar` to build the JAR without WireMock or `gradle standaloneJar` to build a standalone JAR.\nThese will be placed in `build/libs/`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasonm%2Fwiremock-jwt-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasonm%2Fwiremock-jwt-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasonm%2Fwiremock-jwt-extension/lists"}