Skip to content

Commit

Permalink
fix: move all configs to one place
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithEmad authored and Faraz32123 committed Nov 24, 2023
1 parent 9b351fb commit 70d0957
Showing 1 changed file with 48 additions and 74 deletions.
122 changes: 48 additions & 74 deletions tutorcredentials/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,85 +19,59 @@
# CONFIGURATION
########################################

config: t.Dict[str, t.Dict[str, t.Any]] = {
"defaults": {
"VERSION": __version__,
"BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL": "http://lms:8000/oauth2",
"BACKEND_SERVICE_EDX_OAUTH2_KEY": "{{ CREDENTIALS_OAUTH2_KEY }}",
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}",
"EXTRA_PIP_REQUIREMENTS": [],
"FAVICON_URL": "https://edx-cdn.org/v3/default/favicon.ico",
"HOST": "credentials.{{ LMS_HOST }}",
"LOGO_TRADEMARK_URL": "https://edx-cdn.org/v3/default/logo-trademark.svg",
"LOGO_TRADEMARK_URL_PNG": "https://edx-cdn.org/v3/default/logo-trademark.png",
"LOGO_TRADEMARK_URL_SVG": "https://edx-cdn.org/v3/default/logo-trademark.svg",
"LOGO_URL": "",
"LOGO_URL_PNG": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_URL_SVG": "",
"LOGO_WHITE_URL": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_WHITE_URL_PNG": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_WHITE_URL_SVG": "",
"MYSQL_DATABASE": "credentials",
"MYSQL_USERNAME": "credentials",
"OAUTH2_KEY": "credentials-key",
"OAUTH2_KEY_DEV": "credentials-key-dev",
"OAUTH2_KEY_SSO": "credentials-key-sso",
"OAUTH2_KEY_SSO_DEV": "credentials-key-sso-dev",
"PLATFORM_NAME": "{{ PLATFORM_NAME }}",
"SITE_NAME": "{{ LMS_HOST }}",
"SOCIAL_AUTH_REDIRECT_IS_HTTPS": False,
"SOCIAL_AUTH_EDX_OAUTH2_ISSUER": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT": "http://lms:8000",
"SOCIAL_AUTH_EDX_OAUTH2_KEY": "credentials-sso-key",
"SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL": "{{ LMS_HOST }}/logout",
"THEME_NAME": "edx-theme",
"TOS_URL": "{{ LMS_HOST }}/tos",
},
"unique": {
"MYSQL_PASSWORD": "{{ 8|random_string }}",
"SOCIAL_AUTH_EDX_OAUTH2_SECRET": "{{ 16|random_string }}",
"BACKEND_SERVICE_EDX_OAUTH2_SECRET": "{{ 16|random_string }}",
"OAUTH2_SECRET": "{{ 16|random_string }}",
"OAUTH2_SECRET_DEV": "{{ 16|random_string }}",
"OAUTH2_SECRET_SSO": "{{ 16|random_string }}",
"OAUTH2_SECRET_SSO_DEV": "{{ 16|random_string }}",
},
}

tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
[
# Add your new settings that have default values here.
# Each new setting is a pair, (setting_name, default_value).
# Prefix your setting names with 'CREDENTIALS_'.
("CREDENTIALS_VERSION", __version__),
(
"CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL",
"http://lms:8000/oauth2",
),
("CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_KEY", "{{ CREDENTIALS_OAUTH2_KEY }}"),
(
"CREDENTIALS_DOCKER_IMAGE",
"{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}",
),
("CREDENTIALS_EXTRA_PIP_REQUIREMENTS", []),
("CREDENTIALS_FAVICON_URL", "https://edx-cdn.org/v3/default/favicon.ico"),
("CREDENTIALS_HOST", "credentials.{{ LMS_HOST }}"),
(
"CREDENTIALS_LOGO_TRADEMARK_URL",
"https://edx-cdn.org/v3/default/logo-trademark.svg",
),
(
"CREDENTIALS_LOGO_TRADEMARK_URL_PNG",
"https://edx-cdn.org/v3/default/logo-trademark.png",
),
(
"CREDENTIALS_LOGO_TRADEMARK_URL_SVG",
"https://edx-cdn.org/v3/default/logo-trademark.svg",
),
("CREDENTIALS_LOGO_URL", ""),
("CREDENTIALS_LOGO_URL_PNG", "{{ CREDENTIALS_LOGO_URL }}"),
("CREDENTIALS_LOGO_URL_SVG", ""),
("CREDENTIALS_LOGO_WHITE_URL", "{{ CREDENTIALS_LOGO_URL }}"),
("CREDENTIALS_LOGO_WHITE_URL_PNG", "{{ CREDENTIALS_LOGO_URL }}"),
("CREDENTIALS_LOGO_WHITE_URL_SVG", ""),
("CREDENTIALS_MYSQL_DATABASE", "credentials"),
("CREDENTIALS_MYSQL_USERNAME", "credentials"),
("CREDENTIALS_OAUTH2_KEY", "credentials-key"),
("CREDENTIALS_OAUTH2_KEY_DEV", "credentials-key-dev"),
("CREDENTIALS_OAUTH2_KEY_SSO", "credentials-key-sso"),
("CREDENTIALS_OAUTH2_KEY_SSO_DEV", "credentials-key-sso-dev"),
("CREDENTIALS_PLATFORM_NAME", "{{ PLATFORM_NAME }}"),
("CREDENTIALS_SITE_NAME", "{{ LMS_HOST }}"),
("CREDENTIALS_SOCIAL_AUTH_REDIRECT_IS_HTTPS", False),
("CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_ISSUER", "https://{{ LMS_HOST }}"),
("CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT", "http://lms:8000"),
("CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_KEY", "credentials-sso-key"),
("CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL", "{{ LMS_HOST }}/logout"),
("CREDENTIALS_THEME_NAME", "edx-theme"),
("CREDENTIALS_REPOSITORY", "https://github.com/openedx/credentials.git"),
("CREDENTIALS_REPOSITORY_VERSION", "{{ OPENEDX_COMMON_VERSION }}"),
]
[(f"CREDENTIALS_{key}", value) for key, value in config.get("defaults", {}).items()]
)

tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
[
# Add settings that don't have a reasonable default for all users here.
# For instance, passwords, secret keys, etc.
# Each new setting is a pair, (setting_name, unique_generated_value).
# Prefix your setting names with 'CREDENTIALS_'.
# For example:
("CREDENTIALS_MYSQL_PASSWORD", "{{ 8|random_string }}"),
("CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_SECRET", "{{ 16|random_string }}"),
("CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_SECRET", "{{ 16|random_string }}"),
("CREDENTIALS_OAUTH2_SECRET", "{{ 16|random_string }}"),
("CREDENTIALS_OAUTH2_SECRET_DEV", "{{ 16|random_string }}"),
("CREDENTIALS_OAUTH2_SECRET_SSO", "{{ 16|random_string }}"),
("CREDENTIALS_OAUTH2_SECRET_SSO_DEV", "{{ 16|random_string }}"),
]
[(f"CREDENTIALS_{key}", value) for key, value in config.get("unique", {}).items()]
)

tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(
[
# Danger zone!
# Add values to override settings from Tutor core or other plugins here.
# Each override is a pair, (setting_name, new_value). For example:
# ("PLATFORM_NAME", "My platform"),
]
list(config.get("overrides", {}).items())
)


Expand Down

0 comments on commit 70d0957

Please sign in to comment.