Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-pycloudlib): incorrect password loaded for couchbase access #8340

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions jans-pycloudlib/jans/pycloudlib/lock/couchbase_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,33 +186,18 @@ def _prepare_bucket(self):
resp.raise_for_status()

def _resolve_auth(self):
# list of possible password files
password_files = [
os.environ.get("CN_OCI_LOCK_PASSWORD_FILE", "/etc/jans/conf/oci_lock_password")
]

# check which user is accessing couchbase
user = os.environ.get("CN_COUCHBASE_SUPERUSER", "")

if user:
password_files.append(
os.environ.get("CN_COUCHBASE_SUPERUSER_PASSWORD_FILE", "/etc/jans/conf/couchbase_superuser_password")
)
else:
user = os.environ.get("CN_COUCHBASE_USER", "admin")
password_files.append(
os.environ.get("CN_COUCHBASE_PASSWORD_FILE", "/etc/jans/conf/couchbase_password")
)

# password of the running user
password = "" # nosec: B105

for password_file in password_files:
if not os.path.isfile(password_file):
continue
superuser_password_file = os.environ.get("CN_COUCHBASE_SUPERUSER_PASSWORD_FILE", "/etc/jans/conf/couchbase_superuser_password")
password_file = os.environ.get("CN_COUCHBASE_PASSWORD_FILE", "/etc/jans/conf/couchbase_password")

if os.path.isfile(superuser_password_file):
user = os.environ.get("CN_COUCHBASE_SUPERUSER", "admin")
password = get_password_from_file(superuser_password_file)
elif os.path.isfile(password_file):
user = os.environ.get("CN_COUCHBASE_USER", "admin")
password = get_password_from_file(password_file)
break
else:
user = ""
password = "" # nosec: B105

# auth credentials
return user, password