Skip to content

Commit

Permalink
[mw] Improve reading of data source credentials from environment vars
Browse files Browse the repository at this point in the history
Before, the system would happily use empty credentials induced by CI
when running from foreign repositories, where the GitHub secrets
attached to the repository are not active, but the GHA workflow
configuration still sets the environment variables - to empty values.
  • Loading branch information
amotl committed Mar 29, 2023
1 parent 22a2008 commit 3b5be48
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions patzilla/access/depatech/clientpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def from_settings(datasource_settings):

@staticmethod
def from_environment():
if not os.environ["DEPATECH_API_USERNAME"] or not os.environ["DEPATECH_API_PASSWORD"]:
raise KeyError("DEPATECH_API_USERNAME or DEPATECH_API_PASSWORD is empty")
return {
"api_username": os.environ["DEPATECH_API_USERNAME"],
"api_password": os.environ["DEPATECH_API_PASSWORD"],
Expand Down
2 changes: 2 additions & 0 deletions patzilla/access/epo/ops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def from_settings(datasource_settings):

@staticmethod
def from_environment():
if not os.environ["OPS_API_CONSUMER_KEY"] or not os.environ["OPS_API_CONSUMER_SECRET"]:
raise KeyError("OPS_API_CONSUMER_KEY or OPS_API_CONSUMER_SECRET is empty")
return {
"consumer_key": os.environ["OPS_API_CONSUMER_KEY"],
"consumer_secret": os.environ["OPS_API_CONSUMER_SECRET"],
Expand Down
2 changes: 2 additions & 0 deletions patzilla/access/ificlaims/clientpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def from_settings(datasource_settings):

@staticmethod
def from_environment():
if not os.environ["IFICLAIMS_API_USERNAME"] or not os.environ["IFICLAIMS_API_PASSWORD"]:
raise KeyError("IFICLAIMS_API_USERNAME or IFICLAIMS_API_PASSWORD is empty")
return {
"api_username": os.environ["IFICLAIMS_API_USERNAME"],
"api_password": os.environ["IFICLAIMS_API_PASSWORD"],
Expand Down
2 changes: 2 additions & 0 deletions patzilla/access/sip/clientpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def from_settings(datasource_settings):

@staticmethod
def from_environment():
if not os.environ["SIP_API_USERNAME"] or not os.environ["SIP_API_PASSWORD"]:
raise KeyError("SIP_API_USERNAME or SIP_API_PASSWORD is empty")
return {
"api_username": os.environ["SIP_API_USERNAME"],
"api_password": os.environ["SIP_API_PASSWORD"],
Expand Down

0 comments on commit 3b5be48

Please sign in to comment.