-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cron urls for user verification (#2160)
* feat: add cron urls for user verification * remove comment * cron user tests * add cron mixin * remove whitespace * fix: filter * add cron test cases * add negative test cases * Remove custom aimmo branch install * Merge branch 'master' into verify_email_reminder * Lockfile * fix patch * Update logic so it doesn't include students * Try adding a trailing slash * fix: deletion test * Update cron view and test after feedback * fix: tests * Merge changes * Simplify logic * Simplify logic again * fix: tests * fix: reuse global variable * feedback Co-Authored-By: faucomte97 <[email protected]>
- Loading branch information
1 parent
22beedd
commit b730dda
Showing
14 changed files
with
603 additions
and
87 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
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,29 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Django Server", | ||
"type": "python", | ||
"request": "launch", | ||
"django": true, | ||
"justMyCode": false, | ||
"program": "${workspaceFolder}/example_project/manage.py", | ||
"args": [ | ||
"runserver", | ||
"localhost:8000" | ||
] | ||
}, | ||
{ | ||
"name": "Pytest", | ||
"type": "python", | ||
"request": "test", | ||
"justMyCode": false, | ||
"presentation": { | ||
"hidden": true | ||
} | ||
} | ||
] | ||
} |
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,4 @@ | ||
{ | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
from .cron_mixin import CronMixin |
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,12 @@ | ||
from rest_framework.request import Request | ||
from rest_framework.response import Response | ||
|
||
from ..permissions import IsCronRequestFromGoogle | ||
|
||
|
||
class CronMixin: | ||
http_method_names = ["get"] | ||
permission_classes = [IsCronRequestFromGoogle] | ||
|
||
def get(self, request: Request) -> Response: | ||
raise NotImplementedError() |
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 @@ | ||
from .is_cron_request_from_google import IsCronRequestFromGoogle |
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,14 @@ | ||
from django.conf import settings | ||
from rest_framework.permissions import BasePermission | ||
from rest_framework.request import Request | ||
from rest_framework.views import View | ||
|
||
|
||
class IsCronRequestFromGoogle(BasePermission): | ||
""" | ||
Validate that requests to your cron URLs are coming from App Engine and not from another source. | ||
https://cloud.google.com/appengine/docs/flexible/scheduling-jobs-with-cron-yaml#securing_urls_for_cron | ||
""" | ||
|
||
def has_permission(self, request: Request, view: View): | ||
return settings.DEBUG or request.META.get("HTTP_X_APPENGINE_CRON") == "true" |
Oops, something went wrong.