Skip to content
Merged

Dev #53

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9d39c86
feat: [#8641] create organization oauth2
mngocdf Sep 18, 2024
939faea
feat: [#8641] create organization oauth2
mngocdf Sep 23, 2024
eae1969
Merge pull request #2 from Space-DF/feat/8641-create-organization-oauth2
haihuynhDF Oct 1, 2024
99de846
bug: #9945 sensitive mail
mngocdf Oct 2, 2024
9e027d8
Merge pull request #7 from Space-DF/bug/9945-insensitive-mail
haihuynhDF Oct 2, 2024
ec92449
fix: #8849 able to use jwt on another organization
mngocdf Oct 9, 2024
0d2025e
Merge pull request #8 from Space-DF/fix/8849-able-to-use-jwt-on-anoth…
haihuynhDF Oct 9, 2024
90dab1d
feat: credentials api
mngocdf Oct 22, 2024
8bd6940
Merge pull request #9 from Space-DF/feat/credentails-api
haihuynhDF Oct 22, 2024
870444f
feat: credentials api
mngocdf Oct 22, 2024
4f4efd7
Merge pull request #10 from Space-DF/feat/credentails-api
haihuynhDF Oct 22, 2024
7f9476f
chore: move organization role management
mngocdf Oct 29, 2024
963c7bd
Merge branch 'dev' into chore/move-organization-role-management
mngocdf Oct 29, 2024
df5fe07
chore: move organization role management
mngocdf Oct 29, 2024
f8c1a54
Merge pull request #11 from Space-DF/chore/move-organization-role-man…
haihuynhDF Oct 30, 2024
f6e7993
chore: update swagger schema
mngocdf Oct 30, 2024
6aaf86c
Merge pull request #12 from Space-DF/chore/update-swagger-schema
haihuynhDF Oct 30, 2024
6eebdce
chore: update token obtain pair serializer name
pikann Nov 1, 2024
5a177b1
Merge pull request #13 from Space-DF/chore/update-token-obtain-pair-s…
haihuynhDF Nov 1, 2024
436358d
chore: update get devices api
mngocdf Nov 6, 2024
8e24408
Merge pull request #14 from Space-DF/chore/update-get-spaces-api
haihuynhDF Nov 6, 2024
e51a014
feat: add permission to access token
pikann Nov 13, 2024
dc6ed28
Merge pull request #15 from Space-DF/feat/10864-add-permission-to-acc…
haihuynhDF Nov 14, 2024
a8d6c33
feat: #11188 add user's permission to access token
mngocdf Nov 15, 2024
1c07786
Merge pull request #16 from Space-DF/feat/11188-add-user-permission-t…
haihuynhDF Nov 18, 2024
9bc8ab9
chore: #11286 change to uuid primary key
mngocdf Nov 20, 2024
234e4f3
Merge pull request #17 from Space-DF/chore/11286-change-to-uuid-for-p…
haihuynhDF Nov 20, 2024
5eb9374
feat: base for admin and serializiers
tamdanghuynhkim Nov 25, 2024
40f80a3
fix: dont allow none in enum
tamdanghuynhkim Feb 6, 2025
2613f97
Merge pull request #19 from Space-DF/fix/dont-allow-none-in-enum
tamdanghuynhkim Feb 6, 2025
11063db
chore: remove authentication
pikann Mar 7, 2025
8922825
feat: implement add space command
pikann Mar 7, 2025
18b136b
chore: reformat source code
pikann Mar 10, 2025
fea5a12
Merge pull request #20 from Space-DF/chore/remove-authentication
haihuynhDF Mar 11, 2025
674d15d
fix: fix error cannot switch organization
pikann Mar 11, 2025
945d452
feat:send otp email
Mar 11, 2025
475b70b
chore: fix flake8
Mar 11, 2025
5691918
chore: fix bandit error
Mar 11, 2025
e8daf48
chore: fix flake8 again
Mar 11, 2025
b8fac15
Merge pull request #22 from Space-DF/fix/fix-error-cannot-switch-orga…
haihuynhDF Mar 13, 2025
fe8b459
feat: update create organization command
pikann Mar 13, 2025
5f61755
Merge pull request #23 from Space-DF/feat/update-create-organization-…
haihuynhDF Mar 17, 2025
e14fcda
feature: update organization user model
ngovinh2k2 Mar 19, 2025
4fbf1d9
Merge pull request #24 from Space-DF/feature/update-organization-user…
haihuynhDF Mar 21, 2025
288af29
Merge branch 'dev' into feat/send-otp-email
ngovinh2k2 Mar 28, 2025
743d469
fix: handle exception
ngovinh2k2 Mar 30, 2025
b8f4568
fix: update code again
ngovinh2k2 Apr 2, 2025
14bb24d
Merge pull request #21 from Space-DF/feat/send-otp-email
tamdanghuynhkim Apr 3, 2025
c4c8936
Merge pull request #18 from Space-DF/feat/base-for-admin-and-serializers
tamdanghuynhkim Apr 3, 2025
e616cef
fix: issue static url
ngovinh2k2 Apr 3, 2025
4d4369d
Merge pull request #25 from Space-DF/bugfix/issue-static-url
tamdanghuynhkim Apr 3, 2025
cd68e6b
feature: implement login with google
ngovinh2k2 Apr 11, 2025
5d3ff94
Merge pull request #26 from Space-DF/feature/implement-login-with-google
tamdanghuynhkim Apr 11, 2025
e190562
fix: issue with google login
ngovinh2k2 Apr 17, 2025
cce5b3c
Merge pull request #27 from Space-DF/bugfix/issue-with-google-login
tamdanghuynhkim Apr 17, 2025
869001b
fix: optimize login with google
ngovinh2k2 Apr 18, 2025
aabec02
fix: send email time out
ngovinh2k2 Apr 21, 2025
06cbbda
Merge pull request #28 from Space-DF/bugfix/send-email-time-out
tamdanghuynhkim Apr 21, 2025
e4c4226
fix: issue ci
ngovinh2k2 Apr 21, 2025
e099f74
Merge pull request #29 from Space-DF/bugfix/optimize-login-with-google
tamdanghuynhkim Apr 21, 2025
72bfb11
feature: create token with jwt
ngovinh2k2 Apr 22, 2025
f583a6a
Merge pull request #30 from Space-DF/feature/create-token-with-jwt
tamdanghuynhkim Apr 22, 2025
483bb87
feature: add default for space
ngovinh2k2 Apr 22, 2025
5ceca2b
Merge pull request #31 from Space-DF/feature/add-default-for-space
tamdanghuynhkim Apr 28, 2025
584e2d4
feature: delete organization
ngovinh2k2 Jun 19, 2025
da95d53
Merge pull request #35 from Space-DF/feature/delete-organization
tamdanghuynhkim Jun 19, 2025
3fbc87d
fix: login with google fail
ngovinh2k2 Sep 11, 2025
423881b
fix: ci issue
ngovinh2k2 Sep 11, 2025
305bc56
Merge pull request #36 from Space-DF/bugfix/login-with-google-fail
tamdanghuynhkim Sep 11, 2025
cabd266
fix: update org hander
ngovinh2k2 Sep 17, 2025
0e86a3b
Merge pull request #37 from Space-DF/bugfix/update-org-hander
tamdanghuynhkim Sep 18, 2025
ef53802
fix: update exception handler
ngovinh2k2 Sep 24, 2025
79a9e60
fix: remove the delete org handler
ngovinh2k2 Sep 25, 2025
789973f
Merge pull request #38 from Space-DF/bugfix/update-exception-handler
tamdanghuynhkim Sep 26, 2025
38cb162
Merge branch 'dev' into bugfix/remove-the-delete-org-handler
ngovinh2k2 Sep 26, 2025
a9fa2dc
fix: ci issue
ngovinh2k2 Sep 26, 2025
d21ebc0
Merge pull request #39 from Space-DF/bugfix/remove-the-delete-org-han…
tamdanghuynhkim Sep 26, 2025
250f5d6
fix: delete org fail
ngovinh2k2 Sep 30, 2025
0223991
Merge pull request #41 from Space-DF/bugfix/delete-org-fail
tamdanghuynhkim Sep 30, 2025
80ff621
feature: add some fields for space model
ngovinh2k2 Oct 9, 2025
a8dba19
Merge pull request #42 from Space-DF/feature/add-some-fields-for-spac…
Quynh-Nguyen Oct 9, 2025
fdcb355
fix: login error when canceling
ngovinh2k2 Oct 27, 2025
9b6f789
fix: ci issue
ngovinh2k2 Oct 27, 2025
b735f40
Merge pull request #43 from Space-DF/bugfix/login-error-when-canceling
ngovinh2k2 Oct 27, 2025
6605474
feat: switch tenant from request
ngovinh2k2 Nov 7, 2025
de99b76
Merge pull request #45 from Space-DF/feat/switch-tenant-from-request
ngovinh2k2 Nov 13, 2025
562904c
fix: change account aws for ses
ngovinh2k2 Nov 17, 2025
5192cea
Merge pull request #46 from Space-DF/fix/change-account-aws-for-ses
ngovinh2k2 Nov 17, 2025
93affb0
refactor: move emqx business logic to common folder
worty76 Nov 21, 2025
ccc2cf3
Merge pull request #47 from Space-DF/refactor/move-emqx-to-common
lethanhdat762003 Nov 24, 2025
b6c4fe1
chore: lowercase deveui
worty76 Nov 25, 2025
7374392
Merge pull request #48 from Space-DF/chore/lowercase-deveui
lethanhdat762003 Nov 25, 2025
92b499d
feat: implement telemetry client
ngovinh2k2 Dec 13, 2025
71d10d6
Merge pull request #49 from Space-DF/feat/implement-telemetry-client
ngovinh2k2 Dec 13, 2025
be64fe3
feat: get device properties
ngovinh2k2 Dec 13, 2025
c2ab07e
Merge pull request #50 from Space-DF/feat/get-device-properties
ngovinh2k2 Dec 13, 2025
5c2d59a
fix: update api url
ngovinh2k2 Dec 14, 2025
e69614a
Merge pull request #51 from Space-DF/fix/update-api-url
ngovinh2k2 Dec 14, 2025
5cc161d
fix: remove group_by field
ngovinh2k2 Dec 14, 2025
eddd8ab
Merge pull request #52 from Space-DF/fix/remove-group_by-field
ngovinh2k2 Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
12 changes: 12 additions & 0 deletions common/admin/base_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin


class ListDisplayMixin(admin.ModelAdmin):
list_display_exclude = ()

def get_list_display(self, request):
all_fields = [field.name for field in self.model._meta.fields]
list_display = [
field for field in all_fields if field not in self.list_display_exclude
]
return list_display
3 changes: 2 additions & 1 deletion common/apps/jwks/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from common.apps.jwks.views import JWKView
from django.urls import path

from common.apps.jwks.views import JWKView

app_name = "jwks"

urlpatterns = [
Expand Down
4 changes: 4 additions & 0 deletions common/apps/oauth2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
class OauthLoginSerializer(serializers.Serializer):
authorization_code = serializers.CharField()
code_verifier = serializers.CharField()


class CodeLoginSerializer(serializers.Serializer):
authorization_code = serializers.CharField()
29 changes: 27 additions & 2 deletions common/apps/oauth2/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import logging
from operator import itemgetter

from common.apps.oauth2.serializers import OauthLoginSerializer
from common.utils.oauth2 import get_access_token, handle_access_token
from django.shortcuts import redirect
from rest_framework import generics, status
from rest_framework.exceptions import ParseError
from rest_framework.permissions import AllowAny
from rest_framework.response import Response

from common.apps.oauth2.serializers import OauthLoginSerializer
from common.utils.encoder import decode_from_base64
from common.utils.oauth2 import get_access_token, handle_access_token


class GoogleLoginView(generics.CreateAPIView):
serializer_class = OauthLoginSerializer
Expand All @@ -30,3 +33,25 @@ def post(self, request, *args, **kwargs):
logging.exception(e)
raise ParseError(detail="Bad request")
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class GoogleLoginCallbackView(generics.RetrieveAPIView):
def get(self, request):
code = request.GET.get("code")
state = request.GET.get("state")
error = request.GET.get("error")

if not state:
return Response({"error": "Missing code or state"}, status=400)

try:
state_data = decode_from_base64(state)
callback_url = state_data["callback_url"]
except Exception as e:
return Response({"error": str(e)}, status=400)

if error == "access_denied":
return redirect(callback_url)

fe_redirect_url = f"{callback_url}?code={code}&state={state}"
return redirect(fe_redirect_url)
4 changes: 2 additions & 2 deletions common/apps/organization/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class NewOrganizationHandlerBase:
Use by set NEW_ORGANIZATION_HANDLER in Django setting file
"""

def __init__(self, organization, owner_email):
def __init__(self, organization, owner):
self._organization = organization
self._owner_email = owner_email
self._owner = owner

@abstractmethod
def handle(self):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.conf import settings
from django.core.management.base import BaseCommand

from common.apps.organization.models import Domain, Organization


class Command(BaseCommand):
help = "Create a new space"

def add_arguments(self, parser):
parser.add_argument("--name", type=str, help="Organization name")
parser.add_argument("--slug_name", type=str, help="Organization slug name")
parser.add_argument(
"--is_multi_tenant", type=bool, help="True if organization is multi-tenant"
)

def handle(self, *args, **kwargs):
name = kwargs.get("name") or input("Name [test]: ") or "test"
slug_name = kwargs.get("slug_name") or input("Slug name [test]: ") or "test"
is_multi_tenant = (
kwargs.get("is_multi_tenant") or input("Is multi-tenant [False]: ") or False
)

organization = Organization(
schema_name=slug_name,
name=name,
slug_name=slug_name,
is_active=True,
is_multi_tenant=is_multi_tenant,
)
organization.save()
Domain(
domain=f"{slug_name}.{settings.DEFAULT_TENANT_HOST}",
tenant=organization,
is_primary=True,
).save()

self.stdout.write(
self.style.SUCCESS(f"Organization {organization.name} created successfully")
)
39 changes: 21 additions & 18 deletions common/apps/organization/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Generated by Django 5.0.6 on 2024-06-26 11:34
# Generated by Django 5.0.6 on 2024-11-20 07:42

import django.db.models.deletion
import django_tenants.postgresql_backend.base
import uuid
from django.db import migrations, models


Expand All @@ -14,15 +15,6 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name="Organization",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"schema_name",
models.CharField(
Expand All @@ -34,6 +26,16 @@ class Migration(migrations.Migration):
],
),
),
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=100)),
Expand All @@ -49,20 +51,21 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name="Domain",
fields=[
(
"domain",
models.CharField(db_index=True, max_length=253, unique=True),
),
("is_primary", models.BooleanField(db_index=True, default=True)),
(
"id",
models.BigAutoField(
auto_created=True,
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
verbose_name="ID",
unique=True,
),
),
(
"domain",
models.CharField(db_index=True, max_length=253, unique=True),
),
("is_primary", models.BooleanField(db_index=True, default=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
Expand Down
3 changes: 2 additions & 1 deletion common/apps/organization/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from common.models.base_model import BaseModel
from django.db import models
from django_tenants.models import DomainMixin, TenantMixin

from common.models.base_model import BaseModel


class Organization(TenantMixin, BaseModel):
name = models.CharField(max_length=100)
Expand Down
13 changes: 11 additions & 2 deletions common/apps/organization/tasks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging

from common.apps.organization.models import Domain, Organization
from common.celery.tasks import task
from django.conf import settings
from django.db import transaction
from django.utils.module_loading import import_string

from common.apps.organization.models import Domain, Organization
from common.celery.tasks import task

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -43,3 +44,11 @@ def create_organization(id, name, slug_name, is_active, owner, created_at, updat

if NewOrganizationHandler is not None:
NewOrganizationHandler(organization, owner).handle()


@task(name="spacedf.tasks.delete_organization", max_retries=3)
@transaction.atomic
def delete_organization(slug_name):
logger.info(f"delete_organization({slug_name})")
organization = Organization.objects.get(schema_name=slug_name)
organization.delete(force_drop=True)
40 changes: 0 additions & 40 deletions common/apps/organization_role/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions common/apps/organization_role/apps.py

This file was deleted.

19 changes: 0 additions & 19 deletions common/apps/organization_role/constants.py

This file was deleted.

Loading