Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/th-15-add-login-api' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TaeHyoungKwon committed Jul 19, 2021
2 parents a6824db + 9752c70 commit 9cec854
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 40 deletions.
149 changes: 148 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ orjson = "^3.5.2"
httpx = "^0.18.1"
django-cors-headers = "^3.7.0"
django-storages = "^1.11.1"
drf-yasg = "^1.20.0"
colorama = "^0.4.4"
boto3 = "^1.18.1"
drf-yasg = "^1.20.0"
drf-jwt = "^1.19.1"

[tool.poetry.dev-dependencies]
pre-commit = "^2.11.1"
Expand All @@ -36,6 +37,7 @@ pytest-django = "^4.1.0"
awscli-local = "^0.14"
ipdb = "^0.13.7"
ipython = "^7.23.1"
django-extensions = "^3.1.3"


[tool.black]
Expand Down
10 changes: 10 additions & 0 deletions v2/src/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"django.contrib.staticfiles",
"drf_yasg",
"rest_framework",
"ctrlf_auth",
"django_extensions",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -105,6 +107,14 @@
},
]

REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_jwt.authentication.JSONWebTokenAuthentication",
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.BasicAuthentication",
),
}

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
Expand Down
49 changes: 11 additions & 38 deletions v2/src/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
"""config URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.contrib import admin
from django.urls import path
from django.urls import include, path
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from rest_framework.decorators import api_view
from rest_framework.response import Response

schema_view = get_schema_view(
openapi.Info(
title="Ctrl-f BE",
title="CTRL-f API Doc",
default_version="v1",
description="Ctrl-f BE API Doc",
terms_of_service="",
contact=openapi.Contact(name="test", email="[email protected]"),
license=openapi.License(name="Ctrl-f BE License"),
description="CTRL-f API Doc",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="[email protected]"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)


@swagger_auto_schema(method="get")
@api_view(["GET"])
def helloworld(request):
return Response({"hello": "world"})


urlpatterns = [path("admin/", admin.site.urls)]

if settings.DEBUG:
urlpatterns += [
path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
path("helloworld", helloworld),
]
urlpatterns = [
path("admin/", admin.site.urls),
path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
path("api/auth/", include("ctrlf_auth.urls")),
]
Empty file added v2/src/ctrlf_auth/__init__.py
Empty file.
Empty file added v2/src/ctrlf_auth/admin.py
Empty file.
6 changes: 6 additions & 0 deletions v2/src/ctrlf_auth/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CtrlfAuthConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "ctrlf_auth"
26 changes: 26 additions & 0 deletions v2/src/ctrlf_auth/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.5 on 2021-07-11 09:54

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="CtrlfUser",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("password", models.CharField(max_length=128, verbose_name="password")),
("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")),
("email", models.EmailField(max_length=255, unique=True, verbose_name="email address")),
("is_active", models.BooleanField(default=True)),
],
options={
"abstract": False,
},
),
]
Empty file.
Loading

0 comments on commit 9cec854

Please sign in to comment.