Skip to content

Commit

Permalink
feat: Instance Registration and Configuration (#2793)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Prateek Shourya <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2023
1 parent 9369ee5 commit 878707f
Show file tree
Hide file tree
Showing 78 changed files with 1,948 additions and 288 deletions.
15 changes: 5 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@ AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880

# GPT settings
OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint
OPENAI_API_KEY="sk-" # add your openai key here
GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access
OPENAI_API_BASE="https://api.openai.com/v1" # deprecated
OPENAI_API_KEY="sk-" # deprecated
GPT_ENGINE="gpt-3.5-turbo" # deprecated

# Settings related to Docker
DOCKERIZED=1
DOCKERIZED=1 # deprecated

# set to 1 If using the pre-configured minio setup
USE_MINIO=1

# Nginx Configuration
NGINX_PORT=80

# Set it to 0, to disable it
ENABLE_WEBHOOK=1

# Set it to 0, to disable it
ENABLE_API=1
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ FROM python:3.11.1-alpine3.17 AS backend
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV DJANGO_SETTINGS_MODULE plane.settings.production
ENV DOCKERIZED 1

WORKDIR /code

Expand Down
24 changes: 10 additions & 14 deletions ENV_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880
# GPT settings
OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint
OPENAI_API_KEY="sk-" # add your openai key here
GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access
OPENAI_API_BASE="https://api.openai.com/v1" # deprecated
OPENAI_API_KEY="sk-" # deprecated
GPT_ENGINE="gpt-3.5-turbo" # deprecated
# Settings related to Docker
DOCKERIZED=1
# set to 1 If using the pre-configured minio setup
USE_MINIO=1
Expand Down Expand Up @@ -78,7 +76,7 @@ NEXT_PUBLIC_ENABLE_OAUTH=0
# Backend
# Debug value for api server use it as 0 for production use
DEBUG=0
DJANGO_SETTINGS_MODULE="plane.settings.selfhosted"
DJANGO_SETTINGS_MODULE="plane.settings.selfhosted" # deprecated
# Error logs
SENTRY_DSN=""
Expand Down Expand Up @@ -115,24 +113,22 @@ AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880
# GPT settings
OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint
OPENAI_API_KEY="sk-" # add your openai key here
GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access
OPENAI_API_BASE="https://api.openai.com/v1" # deprecated
OPENAI_API_KEY="sk-" # deprecated
GPT_ENGINE="gpt-3.5-turbo" # deprecated
# Settings related to Docker
DOCKERIZED=1 # Deprecated
# Github
GITHUB_CLIENT_SECRET="" # For fetching release notes
# Settings related to Docker
DOCKERIZED=1
# set to 1 If using the pre-configured minio setup
USE_MINIO=1
# Nginx Configuration
NGINX_PORT=80
# Default Creds
DEFAULT_EMAIL="[email protected]"
DEFAULT_PASSWORD="password123"
# SignUps
ENABLE_SIGNUP="1"
Expand Down
27 changes: 5 additions & 22 deletions apiserver/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Backend
# Debug value for api server use it as 0 for production use
DEBUG=0
CORS_ALLOWED_ORIGINS="http://localhost"
CORS_ALLOWED_ORIGINS=""
ENVIRONMENT="development"

# Error logs
SENTRY_DSN=""
Expand All @@ -18,15 +19,6 @@ REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://${REDIS_HOST}:6379/"

# Email Settings
EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=587
EMAIL_FROM="Team Plane <[email protected]>"
EMAIL_USE_TLS="1"
EMAIL_USE_SSL="0"

# AWS Settings
AWS_REGION=""
AWS_ACCESS_KEY_ID="access-key"
Expand All @@ -38,9 +30,9 @@ AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880

# GPT settings
OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint
OPENAI_API_KEY="sk-" # add your openai key here
GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access
OPENAI_API_BASE="https://api.openai.com/v1" # deprecated
OPENAI_API_KEY="sk-" # deprecated
GPT_ENGINE="gpt-3.5-turbo" # deprecated

# Github
GITHUB_CLIENT_SECRET="" # For fetching release notes
Expand All @@ -53,9 +45,6 @@ USE_MINIO=1
# Nginx Configuration
NGINX_PORT=80

# Default Creds
DEFAULT_EMAIL="[email protected]"
DEFAULT_PASSWORD="password123"

# SignUps
ENABLE_SIGNUP="1"
Expand All @@ -70,12 +59,6 @@ ENABLE_MAGIC_LINK_LOGIN="0"
# Email redirections and minio domain settings
WEB_URL="http://localhost"

# Set it to 0, to disable it
ENABLE_WEBHOOK=1

# Set it to 0, to disable it
ENABLE_API=1

# Gunicorn Workers
GUNICORN_WORKERS=2

2 changes: 1 addition & 1 deletion apiserver/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ USER captain
COPY manage.py manage.py
COPY plane plane/
COPY templates templates/

COPY package.json package.json
COPY gunicorn.config.py ./
USER root
RUN apk --no-cache add "bash~=5.2"
Expand Down
83 changes: 0 additions & 83 deletions apiserver/bin/bucket_script.py

This file was deleted.

6 changes: 4 additions & 2 deletions apiserver/bin/takeoff
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ set -e
python manage.py wait_for_db
python manage.py migrate

# Create a Default User
python bin/user_script.py
# Register instance
python manage.py register_instance
# Load the configuration variable
python manage.py configure_instance
# Create the default bucket
python bin/bucket_script.py

Expand Down
28 changes: 0 additions & 28 deletions apiserver/bin/user_script.py

This file was deleted.

4 changes: 4 additions & 0 deletions apiserver/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "plane-api",
"version": "0.13.2"
}
5 changes: 4 additions & 1 deletion apiserver/plane/api/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Module import
from .base import BaseSerializer
from plane.db.models import User, Workspace, WorkspaceMemberInvite
from plane.license.models import InstanceAdmin, Instance


class UserSerializer(BaseSerializer):
Expand Down Expand Up @@ -86,7 +87,9 @@ def get_workspace(self, obj):
"last_workspace_id": obj.last_workspace_id,
"last_workspace_slug": workspace.slug if workspace is not None else "",
"fallback_workspace_id": obj.last_workspace_id,
"fallback_workspace_slug": workspace.slug if workspace is not None else "",
"fallback_workspace_slug": workspace.slug
if workspace is not None
else "",
"invites": workspace_invites,
}
else:
Expand Down
8 changes: 2 additions & 6 deletions apiserver/plane/api/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
*user_urls,
*view_urls,
*workspace_urls,
*api_urls,
*webhook_urls,
]

if settings.ENABLE_WEBHOOK:
urlpatterns += webhook_urls

if settings.ENABLE_API:
urlpatterns += api_urls
9 changes: 9 additions & 0 deletions apiserver/plane/api/urls/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
),
name="users",
),
path(
"users/me/instance-admin/",
UserEndpoint.as_view(
{
"get": "retrieve_instance_admin",
}
),
name="users",
),
path(
"users/me/change-password/",
ChangePasswordEndpoint.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/api/views/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ def post(self, request):
except RequestException as e:
capture_exception(e)

access_token, refresh_token = get_tokens_for_user(user)
data = {
"access_token": access_token,
"refresh_token": refresh_token,
}
access_token, refresh_token = get_tokens_for_user(user)
return Response(data, status=status.HTTP_200_OK)


Expand Down
1 change: 0 additions & 1 deletion apiserver/plane/api/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def finalize_response(self, request, response, *args, **kwargs):
self.webhook_event
and self.request.method in ["POST", "PATCH", "DELETE"]
and response.status_code in [200, 201, 204]
and settings.ENABLE_WEBHOOK
):
send_webhook.delay(
event=self.webhook_event,
Expand Down
Loading

0 comments on commit 878707f

Please sign in to comment.