forked from OpenDroneMap/WebODM
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
2,460 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/.git | ||
app/static/app/bundles | ||
**/node_modules | ||
.secret_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,4 +108,5 @@ celerybeat-schedule.db | |
|
||
# Debian builds | ||
dpkg/build | ||
dpkg/deb | ||
dpkg/deb | ||
.secret_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from django.contrib.auth.models import User | ||
from django.contrib.auth import login | ||
from rest_framework.views import APIView | ||
from rest_framework import exceptions, permissions, parsers | ||
from rest_framework.response import Response | ||
from app.auth.backends import get_user_from_external_auth_response | ||
import requests | ||
from webodm import settings | ||
|
||
class ExternalTokenAuth(APIView): | ||
permission_classes = (permissions.AllowAny,) | ||
parser_classes = (parsers.JSONParser, parsers.FormParser,) | ||
|
||
def post(self, request): | ||
# This should never happen | ||
if settings.EXTERNAL_AUTH_ENDPOINT == '': | ||
return Response({'error': 'EXTERNAL_AUTH_ENDPOINT not set'}) | ||
|
||
token = request.COOKIES.get('external_access_token', '') | ||
if token == '': | ||
return Response({'error': 'external_access_token cookie not set'}) | ||
|
||
try: | ||
r = requests.post(settings.EXTERNAL_AUTH_ENDPOINT, headers={ | ||
'Authorization': "Bearer %s" % token | ||
}) | ||
res = r.json() | ||
if res.get('user_id') is not None: | ||
user = get_user_from_external_auth_response(res) | ||
if user is not None: | ||
login(request, user, backend='django.contrib.auth.backends.ModelBackend') | ||
return Response({'redirect': '/'}) | ||
else: | ||
return Response({'error': 'Invalid credentials'}) | ||
else: | ||
return Response({'error': res.get('message', 'Invalid external server response')}) | ||
except Exception as e: | ||
return Response({'error': str(e)}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.