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

Nit 1204 ldap data refresh remove passwords #42

Merged
merged 12 commits into from
Apr 29, 2024
6 changes: 3 additions & 3 deletions .github/workflows/format-python.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Format Python
on:
pull_request:
types:
- [ opened, synchronize, reopened, edited, ready_for_review ]
types: [ opened, edited, reopened, synchronize, ready_for_review ]
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Format code with black
run: |
pip install black
Expand Down
18 changes: 18 additions & 0 deletions cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,23 @@ def user_expiry(user_ou, root_dn):
cli.ldap_cmds.user.user_expiry(user_ou=user_ou, root_dn=root_dn)


@click.command()
@click.option(
"-u",
"--user-ou",
help="OU to add users to, defaults to ou=Users",
default="ou=Users",
)
@click.option(
"-r",
"--root-dn",
help="Root DN to add users to, defaults to dc=moj,dc=com",
default="dc=moj,dc=com",
)
def remove_all_user_passwords(user_ou, root_dn):
cli.ldap_cmds.user.remove_all_user_passwords(user_ou=user_ou, root_dn=root_dn)


# from cli.ldap import test

main_group.add_command(add_roles_to_users)
Expand All @@ -217,6 +234,7 @@ def user_expiry(user_ou, root_dn):
main_group.add_command(update_user_roles)
main_group.add_command(deactivate_crc_users)
main_group.add_command(user_expiry)
main_group.add_command(remove_all_user_passwords)

logger.configure_logging()

Expand Down
4 changes: 1 addition & 3 deletions cli/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ def connection():
log.debug("Created database connection successfully")
return conn
except Exception as e:
log.exception(
f"Failed to create database connection. An exception of type {type(e).__name__} occurred: {e}"
)
log.exception(f"Failed to create database connection. An exception of type {type(e).__name__} occurred: {e}")
raise e
16 changes: 4 additions & 12 deletions cli/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
).replace(
"_DICT",
"",
): ast.literal_eval(val)
if "DICT" in key
else val
): (ast.literal_eval(val) if "DICT" in key else val)
for key, val in dotenv_values(".vars").items()
if val is not None
}, # load development variables
Expand All @@ -40,9 +38,7 @@
).replace(
"_DICT",
"",
): ast.literal_eval(val)
if "DICT" in key
else val
): (ast.literal_eval(val) if "DICT" in key else val)
for key, val in os.environ.items()
if key.startswith("VAR_") and val is not None
},
Expand All @@ -61,9 +57,7 @@
.replace(
"SSM_",
"",
): ast.literal_eval(val)
if "_DICT" in key
else val
): (ast.literal_eval(val) if "_DICT" in key else val)
for key, val in dotenv_values(".secrets").items()
if val is not None
},
Expand All @@ -79,9 +73,7 @@
.replace(
"SSM_",
"",
): ast.literal_eval(val)
if "DICT" in key
else val
): (ast.literal_eval(val) if "DICT" in key else val)
for key, val in os.environ.items()
if key.startswith("SECRET_") or key.startswith("SSM_") and val is not None
},
Expand Down
16 changes: 4 additions & 12 deletions cli/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def get_access_token(
headers=headers,
)
except Exception as e:
logging.exception(
f"Failed to get access token. An exception of type {type(e).__name__} occurred: {e}"
)
logging.exception(f"Failed to get access token. An exception of type {type(e).__name__} occurred: {e}")
raise e

# extract the token from the response
Expand Down Expand Up @@ -68,9 +66,7 @@ def get_repo(
multi_options=multi_options,
)
except Exception as e:
logging.exception(
f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}"
)
logging.exception(f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}")
raise e
# if there is a token, assume auth is required and use the token and auth_type
elif token:
Expand All @@ -83,9 +79,7 @@ def get_repo(
multi_options=multi_options,
)
except Exception as e:
logging.exception(
f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}"
)
logging.exception(f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}")
raise e
# if there is no token, assume auth is not required and clone without
else:
Expand All @@ -97,7 +91,5 @@ def get_repo(
multi_options=multi_options,
)
except Exception as e:
logging.exception(
f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}"
)
logging.exception(f"Failed to clone repo. An exception of type {type(e).__name__} occurred: {e}")
raise e
2 changes: 1 addition & 1 deletion cli/ldap_cmds/rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def user_ldifs(
for file in user_files:
records = ldif.LDIFRecordList(open(file, "rb"))
records.parse()

# pprint(records.all_records)
# loop through the records
for entry in records.all_records:
Expand Down
Loading
Loading