Skip to content

Commit

Permalink
only add Authorization header if token exists (#6)
Browse files Browse the repository at this point in the history
* only add Authorization header if token exists

This patch makes the database config "token" optional.
Users can either set it to an empty string or omit the token completely.
This is useful for DB-APIs that do not require authentication, and
therefore no token.

* pin dependency werkzeug to version 2.1.2

to workaround python-restx/flask-restx#460

* add git ignore file

build output and caches can be ignored by git

* downgrade werkzeug even further to 2.0.*

as suggested in python-restx/flask-restx#460 (comment)
  • Loading branch information
reimer-atb authored Nov 16, 2022
1 parent e08a9cb commit c5a6a2b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ServiceDiscovery/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
**/*.egg-info/
**/__pycache__/
3 changes: 2 additions & 1 deletion ServiceDiscovery/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
werkzeug==2.0.*
Flask==2.1.2
Flask-Cors==3.0.10
flask-talisman==1.0.0
Expand All @@ -10,4 +11,4 @@ pandas==1.4.2
numpy==1.22.4
lxml==4.9.0
PyGithub==1.55
langdetect==1.0.9
langdetect==1.0.9
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self):
database_config = ConfigReader.read_config(section="database")
self.scheme = database_config["scheme"]
self.host = database_config["host"]
self.header = {"Authorization": f"Bearer {database_config['token']}"}
if database_config.get('token'):
self.header = {"Authorization": f"Bearer {database_config['token']}"}
self.registry_endpoint = database_config["registry_endpoint"]
self.services_endpoint = database_config["services_endpoint"]
self.database_endpoint = f"{self.scheme}://{self.host}"
Expand Down

0 comments on commit c5a6a2b

Please sign in to comment.