Skip to content

Commit

Permalink
feat: enhance password generation for Keycloak user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ericosta-dev committed Dec 5, 2024
1 parent 0412120 commit 6005b76
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion connect/usecases/users/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@ class CreateKeycloakUserUseCase:
user_dto: KeycloakUserDTO

def generate_password(self) -> str:
return "".join(random.choices(string.ascii_letters + string.digits, k=10))
uppercase = string.ascii_uppercase
lowercase = string.ascii_lowercase
digits = string.digits
special = "!@#$%^&*()_+-=[]{}|;:,.<>?"

password = [
random.choice(uppercase), # 1 uppercase
random.choice(lowercase), # 1 lowercase
random.choice(digits), # 1 digit
random.choice(special), # 1 special
]

all_chars = uppercase + lowercase + digits + special
password.extend(random.choices(all_chars, k=4))

random.shuffle(password)

return "".join(password)

def execute(self) -> dict:
try:
Expand Down

0 comments on commit 6005b76

Please sign in to comment.