* dev: remove default user * dev: initiate licensing * dev: remove migration file 0046 * feat: self hosted licensing initialize * dev: instance licenses * dev: change license response structure * dev: add default properties and issue mention migration * dev: reset migrations * dev: instance configuration * dev: instance configuration migration * dev: update instance configuration model to take null and empty values * dev: instance configuration variables * dev: set default values * dev: update instance configuration load * dev: email configuration settings moved to database * dev: instance configuration on instance bootup * dev: auto instance registration script * dev: instance admin * dev: enable instance configuration and instance admin roles * dev: instance owner fix * dev: instance configuration values * dev: fix instance permissions and serializer * dev: fix email senders * dev: remove deprecated variables * dev: fix current site domain registration * dev: update cors setup and local settings * dev: migrate instance registration and configuration to manage commands * dev: check email validity * dev: update script to use manage command * dev: default bucket creation script * dev: instance admin routes and initial set of screens * dev: admin api to check if the current user is admin * dev: instance admin unique constraints * dev: check magic link login * dev: fix email sending for ssl * dev: create instance activation route if the instance is not activated during startup * dev: removed DJANGO_SETTINGS_MODULE from environment files and deleted auto bucket create script * dev: environment configuration for backend * dev: fix access token variable error * feat: Instance Admin Panel: General Settings (#2792) --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
96 lines
3 KiB
Python
96 lines
3 KiB
Python
# Python imports
|
|
import os
|
|
|
|
# Django imports
|
|
from django.conf import settings
|
|
|
|
# Third party imports
|
|
from rest_framework.permissions import AllowAny
|
|
from rest_framework import status
|
|
from rest_framework.response import Response
|
|
from sentry_sdk import capture_exception
|
|
|
|
# Module imports
|
|
from .base import BaseAPIView
|
|
from plane.license.models import Instance, InstanceConfiguration
|
|
from plane.license.utils.instance_value import get_configuration_value
|
|
|
|
|
|
class ConfigurationEndpoint(BaseAPIView):
|
|
permission_classes = [
|
|
AllowAny,
|
|
]
|
|
|
|
def get(self, request):
|
|
instance_configuration = InstanceConfiguration.objects.values("key", "value")
|
|
|
|
data = {}
|
|
# Authentication
|
|
data["google_client_id"] = get_configuration_value(
|
|
instance_configuration,
|
|
"GOOGLE_CLIENT_ID",
|
|
os.environ.get("GOOGLE_CLIENT_ID", None),
|
|
)
|
|
data["github_client_id"] = get_configuration_value(
|
|
instance_configuration,
|
|
"GITHUB_CLIENT_ID",
|
|
os.environ.get("GITHUB_CLIENT_ID", None),
|
|
)
|
|
data["github_app_name"] = get_configuration_value(
|
|
instance_configuration,
|
|
"GITHUB_APP_NAME",
|
|
os.environ.get("GITHUB_APP_NAME", None),
|
|
)
|
|
data["magic_login"] = (
|
|
bool(
|
|
get_configuration_value(
|
|
instance_configuration,
|
|
"EMAIL_HOST_USER",
|
|
os.environ.get("GITHUB_APP_NAME", None),
|
|
),
|
|
)
|
|
and bool(
|
|
get_configuration_value(
|
|
instance_configuration,
|
|
"EMAIL_HOST_PASSWORD",
|
|
os.environ.get("GITHUB_APP_NAME", None),
|
|
)
|
|
)
|
|
) and get_configuration_value(
|
|
instance_configuration, "ENABLE_MAGIC_LINK_LOGIN", "0"
|
|
) == "1"
|
|
data["email_password_login"] = (
|
|
get_configuration_value(
|
|
instance_configuration, "ENABLE_EMAIL_PASSWORD", "0"
|
|
)
|
|
== "1"
|
|
)
|
|
# Slack client
|
|
data["slack_client_id"] = get_configuration_value(
|
|
instance_configuration,
|
|
"SLACK_CLIENT_ID",
|
|
os.environ.get("SLACK_CLIENT_ID", None),
|
|
)
|
|
|
|
# Posthog
|
|
data["posthog_api_key"] = get_configuration_value(
|
|
instance_configuration,
|
|
"POSTHOG_API_KEY",
|
|
os.environ.get("POSTHOG_API_KEY", None),
|
|
)
|
|
data["posthog_host"] = get_configuration_value(
|
|
instance_configuration,
|
|
"POSTHOG_HOST",
|
|
os.environ.get("POSTHOG_HOST", None),
|
|
)
|
|
|
|
# Unsplash
|
|
data["has_unsplash_configured"] = bool(
|
|
get_configuration_value(
|
|
instance_configuration,
|
|
"UNSPLASH_ACCESS_KEY",
|
|
os.environ.get("UNSPLASH_ACCESS_KEY", None),
|
|
)
|
|
)
|
|
|
|
return Response(data, status=status.HTTP_200_OK)
|