Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12241526
credentials.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
credentials.py
View Options
# -------------------------------------------------------------
# Nasqueron Reports :: Credentials :: Vault
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Read credentials from Vault or OpenBao
# License: BSD-2-Clause
# -------------------------------------------------------------
import
os
from
nasqueron_reports.credentials
import
vault
from
nasqueron_reports.errors
import
NasqueronReportConfigError
# -------------------------------------------------------------
# Credentials wiring
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
resolve_credentials
(
config
):
if
config
[
"driver"
]
==
"vault"
:
return
vault
.
fetch_credentials
(
config
[
"secret"
])
if
config
[
"driver"
]
==
"env"
:
variables
=
config
.
get
(
"variables"
,
{})
return
read_environment
(
variables
)
raise
NasqueronReportConfigError
(
"Credentials driver parameter is missing"
)
# -------------------------------------------------------------
# Environment
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
read_environment
(
variables
):
return
{
k
:
os
.
environ
.
get
(
v
,
""
)
for
k
,
v
in
variables
.
items
()}
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sun, Oct 12, 05:23 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3044169
Default Alt Text
credentials.py (1 KB)
Attached To
Mode
rRPRT Nasqueron internal reports
Attached
Detach File
Event Timeline
Log In to Comment