Skip to content

Python module for HMAC Authentication with Kong - Updated for Python 3 and SHA256

License

Notifications You must be signed in to change notification settings

Necr0byte/kong-hmac-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Python module for HMAC Authentication with Kong

This is a python module for generating HTTP request headers for HMAC authentication with Kong. More specifically, Kong's HMAC Authentication Plugin.

This module was written for load testing with Locust and used in conjuction with Locust Docker.

Usage

GET request:

from kong_hmac import generate_request_headers
import requests

key_id = 'my-key-id'
secret = b'my-secret'
url = 'https://example.com/api/resource'
get_request_headers = generate_request_headers(key_id, secret, url)
r = requests.get(url, headers=get_request_headers)
print ('Response code: %d\n' % r.status_code)
print (r.text)

POST request:

from kong_hmac import generate_request_headers
import request

key_id = 'my-key-id'
secret = b'my-secret'
url = 'https://example.com/api/resource'
content_type = 'application/json'
payload = open('payload.json', 'r').read()
post_request_headers = generate_request_headers(key_id, secret, url, payload, content_type)
r = requests.post(url, headers=post_request_headers, data=payload)
print ('Response code: %d\n' % r.status_code)
print (r.text)

payload.json:

{
	"key1": "value1",
	"key2": "value2"
}

Reference

HTTP Signatures Specification

License

MIT License - see the LICENSE file for details

About

Python module for HMAC Authentication with Kong - Updated for Python 3 and SHA256

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%