Skip to content

Commit

Permalink
[PLGN-45]- Custom Auth- fixed bug where we cannot pass the API Key fr…
Browse files Browse the repository at this point in the history
…om the input into the Authentication header if it contains a prefix (#2143)

[PLGN-45]- Fix validator issue
  • Loading branch information
jerichardson-r7 authored Nov 27, 2023
1 parent ee0ee11 commit 08bea17
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions plugins/rest/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"spec": "01bf89086f7b69361309c6adf67f9ed3",
"manifest": "6a4dfbf514cf030c250d577eecf8ff21",
"setup": "0dba8c490db609ae9977ade0756dbaa6",
"spec": "824d8daed5906eb3eb6a7941f2b25f62",
"manifest": "605d494d836f7a167cc056175e8c452b",
"setup": "775bc205b08880dafc532003dc63eda8",
"schemas": [
{
"identifier": "delete/schema.py",
Expand Down
2 changes: 1 addition & 1 deletion plugins/rest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rapid7/insightconnect-python-3-38-plugin:5
FROM rapid7/insightconnect-python-3-plugin:5

LABEL organization=rapid7
LABEL sdk=python
Expand Down
2 changes: 1 addition & 1 deletion plugins/rest/bin/komand_rest
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from sys import argv

Name = "HTTP Requests"
Vendor = "rapid7"
Version = "6.0.3"
Version = "6.0.4"
Description = "The HTTP Requests plugin makes it easy to integrate with RESTful services"


Expand Down
1 change: 1 addition & 0 deletions plugins/rest/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Any issues connecting to the remote service should be present in the log of the

# Version History

* 6.0.4 - Custom Auth: Fix bug where we could not pass the API Key from the input into the Authentication header if the header value included a prefix
* 6.0.3 - Added empty `__init__.py` file to `unit_test` folder | Refreshed with new tooling | Updated `requirements.txt`
* 6.0.2 - Fixed a bug that would cause an incorrect error message whenever a 400 error was received and the response object was a list
* 6.0.1 - Improved ability of 'Body Any' input to handle non-standard characters and JSON input
Expand Down
2 changes: 1 addition & 1 deletion plugins/rest/komand_rest/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def check_auth_type_validity(
def create_headers_for_custom_auth(self, headers: dict, secret_key) -> dict:
new_headers = {}
for key, value in headers.items():
if value == self.CUSTOM_SECRET_INPUT:
if self.CUSTOM_SECRET_INPUT in value:
if not secret_key:
raise PluginException(
cause="'CUSTOM_SECRET_INPUT' used in authentication header, but no secret provided.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/rest/plugin.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ products: [insightconnect]
name: rest
title: HTTP Requests
description: The HTTP Requests plugin makes it easy to integrate with RESTful services
version: 6.0.3
version: 6.0.4
vendor: rapid7
support: community
supported_versions: ["2023-10-19"]
Expand Down
2 changes: 1 addition & 1 deletion plugins/rest/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


setup(name="rest-rapid7-plugin",
version="6.0.3",
version="6.0.4",
description="The HTTP Requests plugin makes it easy to integrate with RESTful services",
author="rapid7",
author_email="",
Expand Down
6 changes: 6 additions & 0 deletions plugins/rest/unit_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ def test_custom_auth_success(self):
api.with_credentials("Custom", secret_key="Key")
self.assertEqual(api.default_headers["TEST"], "Key")

def test_custom_auth_with_prefix_success(self):
log = logging.getLogger("Test")
api = RestAPI("www.google.com", log, True, {"TEST": "ApiKey CUSTOM_SECRET_INPUT"})
api.with_credentials("Custom", secret_key="Key")
self.assertEqual(api.default_headers["TEST"], "Key")

def test_custom_auth_not_provided(self):
log = logging.getLogger("Test")
api = RestAPI("www.google.com", log, True, {"TEST": "CUSTOM_SECRET_INPUT"})
Expand Down

0 comments on commit 08bea17

Please sign in to comment.