kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #830 from moonstream-to/moonstream-admin-id
Fetch moonstream admin user infopull/832/head
commit
74aed08a6d
|
@ -422,10 +422,6 @@ def origins_add_handler(args: argparse.Namespace) -> None:
|
|||
logger.warning(f"Unable to parse origin: {origin_raw} as URL")
|
||||
continue
|
||||
|
||||
if settings.MOONSTREAM_ADMIN_USER is None:
|
||||
logger.error("Unable to fetch Moonstream admin user")
|
||||
return
|
||||
|
||||
default_origins_cnt = 0
|
||||
for origin in origins_set:
|
||||
# Try to add new origins to Bugout resources application config,
|
||||
|
@ -434,8 +430,8 @@ def origins_add_handler(args: argparse.Namespace) -> None:
|
|||
while retry_cnt < 3:
|
||||
resource = middleware.create_application_settings_cors_origin(
|
||||
token=settings.MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
user_id=str(settings.MOONSTREAM_ADMIN_USER.id),
|
||||
username=settings.MOONSTREAM_ADMIN_USER.username,
|
||||
user_id=str(settings.MOONSTREAM_ADMIN_ID),
|
||||
username="unknown-moonstream-admin-user",
|
||||
origin=origin,
|
||||
)
|
||||
if resource is not None:
|
||||
|
|
|
@ -26,8 +26,8 @@ from .settings import (
|
|||
BUGOUT_REQUEST_TIMEOUT_SECONDS,
|
||||
BUGOUT_RESOURCE_TYPE_APPLICATION_CONFIG,
|
||||
MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
MOONSTREAM_ADMIN_USER,
|
||||
MOONSTREAM_APPLICATION_ID,
|
||||
MOONSTREAM_ADMIN_ID,
|
||||
)
|
||||
from .settings import bugout_client as bc
|
||||
|
||||
|
@ -269,7 +269,7 @@ def create_application_settings_cors_origin(
|
|||
token=token,
|
||||
resource_id=resource.id,
|
||||
holder_permissions={
|
||||
"holder_id": str(MOONSTREAM_ADMIN_USER.id),
|
||||
"holder_id": str(MOONSTREAM_ADMIN_ID),
|
||||
"holder_type": "user",
|
||||
"permissions": ["admin", "create", "read", "update", "delete"],
|
||||
},
|
||||
|
|
|
@ -28,7 +28,6 @@ from ..settings import (
|
|||
BUGOUT_RESOURCE_TYPE_APPLICATION_CONFIG,
|
||||
DOCS_TARGET_PATH,
|
||||
MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
MOONSTREAM_ADMIN_USER,
|
||||
MOONSTREAM_APPLICATION_ID,
|
||||
)
|
||||
from ..settings import bugout_client as bc
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import os
|
||||
import warnings
|
||||
from time import sleep
|
||||
from typing import Optional, Set
|
||||
|
||||
from bugout.app import Bugout
|
||||
|
@ -194,11 +195,6 @@ MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN",
|
|||
if MOONSTREAM_ADMIN_ACCESS_TOKEN == "":
|
||||
raise ValueError("MOONSTREAM_ADMIN_ACCESS_TOKEN environment variable must be set")
|
||||
|
||||
MOONSTREAM_ADMIN_USER: Optional[BugoutUser] = None
|
||||
try:
|
||||
MOONSTREAM_ADMIN_USER = bugout_client.get_user(
|
||||
token=MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
)
|
||||
except Exception as err:
|
||||
logger.error(f"Unable to get Moonstream admin user with token, err: {str(err)}")
|
||||
logger.error("Running application partly functional")
|
||||
MOONSTREAM_ADMIN_ID = os.environ.get("MOONSTREAM_ADMIN_ID", "")
|
||||
if MOONSTREAM_ADMIN_ID == "":
|
||||
raise ValueError("MOONSTREAM_ADMIN_ID environment variable must be set")
|
||||
|
|
|
@ -8,6 +8,7 @@ export SIGNER_PASSWORD="<password for message signer keystore>"
|
|||
export ENGINE_DB_URI="postgresql://<username>:<password>@<db_host>:<db_port>/<db_name>"
|
||||
export ENGINE_DB_URI_READ_ONLY="postgresql://<username>:<password>@<db_host>:<db_port>/<db_name>"
|
||||
export MOONSTREAM_ADMIN_ACCESS_TOKEN="<admin access token>"
|
||||
export MOONSTREAM_ADMIN_ID="<admin_user_id>"
|
||||
export MOONSTREAM_APPLICATION_ID="<moonstream application id>"
|
||||
export ENGINE_REDIS_PASSWORD="<redis_requirepass_password>"
|
||||
export ENGINE_REDIS_URL="localhost:6380"
|
||||
|
|
Ładowanie…
Reference in New Issue