Skip to content

Commit

Permalink
Merge pull request #235 from eclecticiq/taxii2-raise-unauth
Browse files Browse the repository at this point in the history
Taxii2 raise unauth
  • Loading branch information
erwin-eiq committed Jul 11, 2022
2 parents 0ff2d9c + 54422a3 commit 7f58505
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
@@ -1,6 +1,10 @@
Changelog
=========

0.9.1 (2022-07-11)
------------------
* Implement `raise_unauthorized` for taxii2, this was missing and lead to 500 errors.

0.9.0 (2022-06-13)
------------------
* Allow custom properties. This can be disabled by config option ``allow_custom_properties``
Expand Down
2 changes: 1 addition & 1 deletion opentaxii/_version.py
Expand Up @@ -3,4 +3,4 @@
This module defines the package version for use in __init__.py and setup.py.
"""

__version__ = '0.9.0'
__version__ = '0.9.1'
6 changes: 6 additions & 0 deletions opentaxii/server.py
Expand Up @@ -417,6 +417,12 @@ def handle_validation_exception(self, error):
}
return make_taxii2_response(response, status=400)

def raise_unauthorized(self):
"""
Handle unauthorized access.
"""
raise Unauthorized()

def get_endpoint(self, relative_path: str) -> Optional[Callable[[], Response]]:
endpoint = None
for regex, handler in self.ENDPOINT_MAPPING:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_auth.py
Expand Up @@ -510,3 +510,9 @@ def prepare_inbox_message(version, blocks=None, dest_collection=None):
else:
raise ValueError('Unknown TAXII message version: %s' % version)
return inbox_message


def test_broken_bearer_token_taxii2(client):
headers = {HTTP_AUTHORIZATION: "Bearer broken"}
response = client.get("/taxii2/", headers=headers)
assert response.status_code == 401

0 comments on commit 7f58505

Please sign in to comment.