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: avoid duplicated client when re-running persistence-loader and configurator #1134

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions docker-jans-configurator/scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,9 +807,35 @@ def generate(self):
if "casa" in opt_scopes:
self.casa_ctx()

self.admin_ui_ctx()
self.jans_cli_ctx()

# populated config
return self.ctx

def admin_ui_ctx(self):
self.set_config("admin_ui_client_id", lambda: f"1901.{uuid4()}")
admin_ui_client_pw = self.set_secret("admin_ui_client_pw", get_random_chars)
self.set_secret(
"admin_ui_client_encoded_pw",
partial(encode_text, admin_ui_client_pw, self.get_secret("encoded_salt")),
)

self.set_config("token_server_admin_ui_client_id", lambda: f"1901.{uuid4()}")
token_server_admin_ui_client_pw = self.set_secret("token_server_admin_ui_client_pw", get_random_chars)
self.set_secret(
"token_server_admin_ui_client_encoded_pw",
partial(encode_text, token_server_admin_ui_client_pw, self.get_secret("encoded_salt")),
)

def jans_cli_ctx(self):
self.set_config("role_based_client_id", lambda: f"2000.{uuid4()}")
role_based_client_pw = self.set_secret("role_based_client_pw", get_random_chars)
self.set_secret(
"role_based_client_encoded_pw",
partial(encode_text, role_based_client_pw, self.get_secret("encoded_salt")),
)


def gen_idp3_key(storepass):
cmd = " ".join([
Expand Down
10 changes: 10 additions & 0 deletions docker-jans-persistence-loader/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def get_base_ctx(manager):
# static kid
ctx["staticKid"] = os.environ.get("CN_OB_STATIC_KID", "")

# WARNING:
# - deprecate configs and secrets for admin_ui and token_server_admin_ui
# - move the configs and secrets creation to configurator
# - remove them on future release

# admin-ui plugins
ctx["admin_ui_client_id"] = manager.config.get("admin_ui_client_id")
if not ctx["admin_ui_client_id"]:
Expand Down Expand Up @@ -337,6 +342,11 @@ def merge_casa_ctx(manager, ctx):


def merge_jans_cli_ctx(manager, ctx):
# WARNING:
# - deprecated configs and secrets for role_based
# - move the configs and secrets creation to configurator
# - remove them on future release

# jans-cli client
ctx["role_based_client_id"] = manager.config.get("role_based_client_id")
if not ctx["role_based_client_id"]:
Expand Down