Skip to content

Commit

Permalink
only initialize pending_users if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Apr 26, 2024
1 parent 0378672 commit c6906af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions initialize_vault_store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import os
from authx.auth import set_service_store_secret, add_provider_to_opa, add_program_to_opa
from authx.auth import get_service_store_secret, set_service_store_secret, add_provider_to_opa, add_program_to_opa
import sys

## Initializes Vault's opa service store with the information for our IDP and the data in site_roles.json, paths.json, programs.json
Expand Down Expand Up @@ -44,9 +44,11 @@
sys.exit(4)

# initialize pending users
response, status_code = set_service_store_secret("opa", key="pending_users", value=json.dumps({"pending_users": {}}))
if status_code != 200:
sys.exit(2)
response, status_code = get_service_store_secret("opa", key="pending_users")
if status_code == 404:
response, status_code = set_service_store_secret("opa", key="pending_users", value=json.dumps({"pending_users": {}}))
if status_code != 200:
sys.exit(2)

# print(json.dumps(results, indent=4))
sys.exit(0)

0 comments on commit c6906af

Please sign in to comment.