Skip to content

Commit

Permalink
example jwt middleware usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sritanmotati committed Jan 17, 2025
1 parent 6d1393c commit 19c94a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/PennCourses/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from accounts.middleware import LoginRequiredMiddleware

class CustomLoginMiddleware(LoginRequiredMiddleware):
def add_new_exempt_urls(self):
exempt_urls = []

self.EXEMPT_URLS.extend(exempt_urls)
# EXAMPLE USAGE
# self.EXEMPT_URLS.append(r"^accounts/new_exempt_url/$")
# This can be overriden in the subclass
1 change: 1 addition & 0 deletions backend/PennCourses/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"PennCourses.middleware.CustomLoginMiddleware",
]

ROOT_URLCONF = os.environ.get("ROOT_URLCONF", "PennCourses.urls")
Expand Down

0 comments on commit 19c94a2

Please sign in to comment.