Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update old dependencies #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ ipython = "*"

[packages]

django = "==1.10.5"
django-cors-middleware = "==1.3.1"
django-extensions = "==1.7.1"
djangorestframework = "==3.9.1"
pyjwt = "==1.4.2"
django = "*"
django-cors-middleware = "*"
django-extensions = "*"
djangorestframework = "*"
pyjwt = "*"
gunicorn = "*"
gevent = "*"
"psycopg2" = "*"
psycopg2-binary = "*"
"boto3" = "*"


Expand Down
487 changes: 315 additions & 172 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/conduit/apps/articles/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
router = DefaultRouter()
router.register(r'articles', ArticleViewSet)

app_name = "articles"
urlpatterns = [
url(r'^articles/feed/?$', ArticlesFeedAPIView.as_view()),

Expand Down
6 changes: 4 additions & 2 deletions backend/conduit/apps/authentication/backends.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import jwt

from django.conf import settings
from django.utils.encoding import force_str

from rest_framework import authentication, exceptions

Expand Down Expand Up @@ -74,9 +75,10 @@ def _authenticate_credentials(self, request, token):
Try to authenticate the given credentials. If authentication is
successful, return the user and token. If not, throw an error.
"""
sec = force_str(settings.SECRET_KEY, encoding="utf-8")
try:
payload = jwt.decode(token, settings.SECRET_KEY)
except:
payload = jwt.decode(token, sec, algorithms=['HS256'])
except jwt.exceptions.DecodeError:
msg = 'Invalid authentication. Could not decode token.'
raise exceptions.AuthenticationFailed(msg)

Expand Down
7 changes: 5 additions & 2 deletions backend/conduit/apps/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils import encoding
import jwt

from datetime import datetime, timedelta
Expand All @@ -7,6 +8,7 @@
AbstractBaseUser, BaseUserManager, PermissionsMixin
)
from django.db import models
from django.utils.encoding import force_str

from conduit.apps.core.models import TimestampedModel

Expand Down Expand Up @@ -131,9 +133,10 @@ def _generate_jwt_token(self):
"""
dt = datetime.now() + timedelta(days=60)

sec = force_str(settings.SECRET_KEY, encoding="utf-8")
token = jwt.encode({
'id': self.pk,
'exp': int(dt.strftime('%s'))
}, settings.SECRET_KEY, algorithm='HS256')
}, sec, algorithm='HS256')

return token.decode('utf-8')
return token
1 change: 1 addition & 0 deletions backend/conduit/apps/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
LoginAPIView, RegistrationAPIView, UserRetrieveUpdateAPIView
)

app_name = "authentication"
urlpatterns = [
url(r'^user/?$', UserRetrieveUpdateAPIView.as_view()),
url(r'^users/?$', RegistrationAPIView.as_view()),
Expand Down
1 change: 1 addition & 0 deletions backend/conduit/apps/profiles/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .views import ProfileRetrieveAPIView, ProfileFollowAPIView

app_name = "profiles"
urlpatterns = [
url(r'^profiles/(?P<username>\w+)/?$', ProfileRetrieveAPIView.as_view()),
url(r'^profiles/(?P<username>\w+)/follow/?$',
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/aws/codedeploy/after_install
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mkdir -p /var/log/django
mkdir -p /var/www/conduit/static/

cd /deploy/backend || exit 2
pipenv install
pipenv sync

AWS_DEFAULT_REGION="$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)"
export AWS_DEFAULT_REGION
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/aws/codedeploy/start_server
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export AWS_DEFAULT_REGION
DJANGO_SETTINGS_MODULE='conduit.settings.ec2'
export DJANGO_SETTINGS_MODULE

pipenv run gunicorn --config ../infrastructure/aws/codedeploy/gunicorn.ec2.conf conduit.wsgi
pipenv run gunicorn --config ../infrastructure/aws/codedeploy/gunicorn.ec2.conf.py conduit.wsgi
8 changes: 4 additions & 4 deletions infrastructure/docker/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ WORKDIR /app
COPY backend/Pipfile /app
COPY backend/Pipfile.lock /app

RUN pipenv install
RUN pipenv sync

COPY infrastructure/docker/api/gunicorn.docker.conf /conf/gunicorn.conf
COPY infrastructure/docker/api/gunicorn.docker.conf.py /conf/gunicorn.conf.py

COPY backend /app

Expand All @@ -26,6 +26,6 @@ CMD [ \
"pipenv", \
"run", \
"gunicorn", \
"--config", "/conf/gunicorn.conf", \
"--config", "/conf/gunicorn.conf.py", \
"conduit.wsgi" \
]
]