Skip to content

Commit be7e430

Browse files
committed
Initial commit
0 parents  commit be7e430

40 files changed

+16397
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# virtualenv
2+
bin/
3+
lib/
4+
include/
5+
pyvenv.cfg
6+
7+
# python
8+
*/__pycache__/*
9+
*.pyc
10+
11+
# django
12+
db.sqlite3
13+
.env
14+
15+
# OSX
16+
.DS_Store

backend/backend/__init__.py

Whitespace-only changes.

backend/backend/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for backend project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
15+
16+
application = get_asgi_application()

backend/backend/settings.py

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import os
2+
from decouple import config
3+
4+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
5+
6+
SECRET_KEY = config('SECRET_KEY')
7+
8+
DEBUG = True
9+
10+
ALLOWED_HOSTS = []
11+
12+
13+
# Application definition
14+
INSTALLED_APPS = [
15+
'django.contrib.admin',
16+
'django.contrib.auth',
17+
'django.contrib.contenttypes',
18+
'django.contrib.sessions',
19+
'django.contrib.messages',
20+
'django.contrib.staticfiles',
21+
22+
'corsheaders',
23+
'rest_framework',
24+
'oauth2_provider',
25+
'social_django',
26+
'rest_framework_social_oauth2',
27+
28+
'core',
29+
]
30+
31+
MIDDLEWARE = [
32+
'corsheaders.middleware.CorsMiddleware',
33+
'django.middleware.security.SecurityMiddleware',
34+
'django.contrib.sessions.middleware.SessionMiddleware',
35+
'django.middleware.common.CommonMiddleware',
36+
'django.middleware.csrf.CsrfViewMiddleware',
37+
'django.contrib.auth.middleware.AuthenticationMiddleware',
38+
'django.contrib.messages.middleware.MessageMiddleware',
39+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
40+
]
41+
42+
ROOT_URLCONF = 'backend.urls'
43+
44+
TEMPLATES = [
45+
{
46+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
47+
'DIRS': [],
48+
'APP_DIRS': True,
49+
'OPTIONS': {
50+
'context_processors': [
51+
'django.template.context_processors.debug',
52+
'django.template.context_processors.request',
53+
'django.contrib.auth.context_processors.auth',
54+
'django.contrib.messages.context_processors.messages',
55+
56+
'social_django.context_processors.backends',
57+
'social_django.context_processors.login_redirect',
58+
],
59+
},
60+
},
61+
]
62+
63+
WSGI_APPLICATION = 'backend.wsgi.application'
64+
65+
DATABASES = {
66+
'default': {
67+
'ENGINE': 'django.db.backends.sqlite3',
68+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
69+
}
70+
}
71+
72+
AUTH_PASSWORD_VALIDATORS = [
73+
{
74+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
75+
},
76+
{
77+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
78+
},
79+
{
80+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
81+
},
82+
{
83+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
84+
},
85+
]
86+
87+
LANGUAGE_CODE = 'en-us'
88+
89+
TIME_ZONE = 'UTC'
90+
91+
USE_I18N = True
92+
93+
USE_L10N = True
94+
95+
USE_TZ = True
96+
97+
STATIC_URL = '/static/'
98+
99+
CORS_ORIGIN_WHITELIST = [
100+
'http://localhost:3000',
101+
'http://localhost:3001',
102+
]
103+
104+
REST_FRAMEWORK = {
105+
'DEFAULT_AUTHENTICATION_CLASSES': (
106+
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
107+
'rest_framework_social_oauth2.authentication.SocialAuthentication',
108+
),
109+
}
110+
111+
AUTHENTICATION_BACKENDS = (
112+
# Add this backend for Google Authentication
113+
'social_core.backends.google.GoogleOAuth2',
114+
'rest_framework_social_oauth2.backends.DjangoOAuth2',
115+
116+
# This is the default Authentication backend
117+
'django.contrib.auth.backends.ModelBackend',
118+
)
119+
120+
# Google OAuth Credentials
121+
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config('SOCIAL_AUTH_GOOGLE_OAUTH2_KEY')
122+
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = config("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET")
123+
124+
# Rest Framework OAuth2 Credentials
125+
CLIENT_ID = config("CLIENT_ID")
126+
CLIENT_SECRET = config("CLIENT_SECRET")

backend/backend/urls.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""backend URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path, include
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
path('auth/', include('rest_framework_social_oauth2.urls')),
22+
path('secret/', include('core.urls'))
23+
]

backend/backend/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for backend project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
15+
16+
application = get_wsgi_application()

backend/core/__init__.py

Whitespace-only changes.

backend/core/admin.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
3+
from . import models
4+
5+
admin.site.register(models.Secret)

backend/core/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CoreConfig(AppConfig):
5+
name = 'core'
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 3.0.6 on 2020-05-07 12:18
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Secret',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('key', models.TextField()),
19+
('value', models.IntegerField()),
20+
],
21+
),
22+
]

backend/core/migrations/__init__.py

Whitespace-only changes.

backend/core/models.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.db import models
2+
3+
4+
class Secret(models.Model):
5+
key = models.TextField()
6+
value = models.IntegerField()
7+
8+
def __str__(self):
9+
return self.key

backend/core/serializers.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from rest_framework import serializers
2+
3+
from . import models
4+
5+
6+
class SecretSerializer(serializers.ModelSerializer):
7+
class Meta:
8+
model = models.Secret
9+
fields = ('key', 'value')

backend/core/urls.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.urls import path
2+
3+
from . import views
4+
5+
urlpatterns = [
6+
path('', views.SecretListView.as_view(), name='index'),
7+
]

backend/core/views.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from rest_framework import generics, permissions
2+
3+
from . import models, serializers
4+
5+
6+
class SecretListView(generics.ListAPIView):
7+
queryset = models.Secret.objects.all()
8+
serializer_class = serializers.SecretSerializer
9+
permission_classes = [permissions.IsAuthenticated]

backend/manage.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
9+
try:
10+
from django.core.management import execute_from_command_line
11+
except ImportError as exc:
12+
raise ImportError(
13+
"Couldn't import Django. Are you sure it's installed and "
14+
"available on your PYTHONPATH environment variable? Did you "
15+
"forget to activate a virtual environment?"
16+
) from exc
17+
execute_from_command_line(sys.argv)
18+
19+
20+
if __name__ == '__main__':
21+
main()

frontend/.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# sensitive
26+
config.js

0 commit comments

Comments
 (0)