Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56953540
credentials.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
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-script.python
Expires
Fri, Nov 13, 14:30 (4 d, 14 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4253890
Default Alt Text
credentials.py (1 KB)
Attached To
Mode
rRPRT Nasqueron internal reports
Attached
Detach File
Event Timeline
Log In to Comment