-
Notifications
You must be signed in to change notification settings - Fork 5
PCR Next.js port #715
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
Open
luke-rt
wants to merge
86
commits into
master
Choose a base branch
from
review-nextjs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
PCR Next.js port #715
Changes from 47 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
793fb80
Nextjs initialization
luke-rt 9d1632d
Set up tailwind, cva, shadcn
luke-rt 615d0fa
styling, fonts, began landing page
luke-rt a38b6f6
added about page
rydersitcawich 7e72a72
faq page
rydersitcawich 3bc9478
styling, scorebox, api helpers
luke-rt b0e0430
Nextjs route rewrites
luke-rt 1e1e2ce
updated Next.js version, rewrites
luke-rt b87e529
Small fixes, began JWT auth migration
luke-rt f95225f
JWT tokens working with oidc somewhat working
luke-rt a01fc92
Removed old auth stuff
luke-rt ff0621b
Rollback to tailwind 3 for compatability
luke-rt 06ad776
Progress with next-auth configuration
luke-rt 7ed3316
Made some progress with nextauth and middleware
luke-rt 0c9235a
Trying without nextauth
luke-rt 14e62ef
JWT token logic working, need to cryptographically verify
luke-rt 7e12b07
Create test route and setup JWK
luke-rt 88306fb
Add Fetch Locations Management Command
shiva-menta f208676
Resolved dev environment bugs
luke-rt e00ecfa
Removed duplicate dependencies
luke-rt 42cde55
Got auth middleware working >:)
luke-rt e95e0b8
rename of token
sritanmotati cc35dd7
Began working on design
luke-rt 025af3f
Set up debounced course search
luke-rt 314f801
Searchbar in header
luke-rt 7d3d2cb
Bump dependencies, upgrade tailwind
luke-rt dd3e807
Fix expired token bug and cache JWKs
luke-rt 3d9ae25
Use shadcn for searchbar
luke-rt 1bd9fea
Reconfigure Shadcn, finish searchbar styling
luke-rt 4761cf6
Nits
luke-rt 08c6a53
Finished fuzzy searchbar/autocomplete
luke-rt c299c91
Progress with static rendering review data
luke-rt cb55040
deleted the semester field
el-agua 32d02c7
Revert "deleted the semester field"
el-agua d8f9be4
Removed the semester url redirect
el-agua 3679b7c
Change searchbar style in header
luke-rt 1e19c3d
Lint :(
luke-rt fb22843
Merge branch 'master' into review-nextjs
luke-rt e56c2f3
Rollback postgres version to align w master
luke-rt 2bdb648
Fixed frontend middleware, started oidc backend middleware
luke-rt aedff42
JWK verification finished in middleware
luke-rt 83b0075
Caching JWKs client with thread locking
luke-rt e315367
jk made it a custom auth permission class
luke-rt 0152de8
Broke something
luke-rt fd600c5
Allow AnonymousUser in JWT auth and working fetching on frontend
luke-rt f7354af
Linting
luke-rt e894ef2
Linting
luke-rt 3feff7b
Frontend progress
luke-rt f398f10
Merge branch 'master' into review-nextjs
luke-rt 072534e
Thank you copilot
luke-rt f7116b6
Linting
luke-rt 6e0a6a2
Linting
luke-rt 395dfec
Update docker
luke-rt 0fab482
Rewrite to asyncio
luke-rt 9855b6e
Update workflow hash
luke-rt a00674f
Merge branch 'master' into review-nextjs
luke-rt f4e59cc
Linting
luke-rt e7a5c00
Hide searchbar on redirect and unfocus
luke-rt 9c6e8f7
Merge branch 'master' into review-nextjs
luke-rt 9784e5c
add appDir true for next config
jamesdoh0109 c967627
limit search results to avoid search speed/crashing
jamesdoh0109 cfd6c75
add minor edits + fix tab spacing
jamesdoh0109 2a6ce37
Merge pull request #727 from pennlabs/james/review-nextjs
luke-rt e0592b6
edit middleware config paths to match new route structure
jamesdoh0109 876193f
fix redirect url from / to entered path
jamesdoh0109 1b6de02
Merge pull request #728 from pennlabs/james/fix-redirect-after-log-in
jamesdoh0109 72de08b
fix invalid jwt token due to missing cryptography package
jamesdoh0109 5ed47da
Merge pull request #730 from pennlabs/james/fix-invalid-jwt-token
luke-rt 0b6e305
Merge remote-tracking branch 'origin/master' into review-nextjs
jamesdoh0109 538ffce
Moved async jwt refresh to read() function
luke-rt a6551a0
Heavy refactoring
luke-rt 3b3aada
Indexed db stale-while-revalidate
luke-rt 2118908
Small changes
luke-rt 0e094a3
Add null check for data
luke-rt 9efef5b
Moved JWT to Celery
luke-rt 78ff701
Put review pages in header
luke-rt 0eca275
Remove command autoscroll
luke-rt a65083a
Comment
luke-rt f43ed1d
Merge pull request #729 from pennlabs/luke/review-nextjs-search
luke-rt b400447
Lint
luke-rt 4138661
Oops
luke-rt 49a65f7
install cryptography per uv migration
jamesdoh0109 b17e5cd
remove print statements
jamesdoh0109 4496c46
Merge pull request #732 from pennlabs/james/install-cryptography-foll…
jamesdoh0109 f5573c2
Fix test cases (#733)
luke-rt e9d3ffb
Rename to review-2.0
luke-rt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 pennlabs/django-base:f0f05216db7c23c1dbb5b95c3bc9e8a2603bf2fd | ||
|
|
||
| LABEL maintainer="Penn Labs" | ||
|
|
||
| WORKDIR /backend | ||
|
|
||
| # Copy project dependencies | ||
| COPY Pipfile* ./ | ||
|
|
||
| # Install backend dependencies | ||
| RUN pipenv install --dev | ||
|
|
||
| # Alias runserver command | ||
| RUN echo 'alias runserver="python manage.py runserver 0.0.0.0:8000"' >> ~/.bashrc |
Empty file.
This file contains hidden or 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,64 @@ | ||
| import logging | ||
| import pprint | ||
| import threading | ||
| import time | ||
|
|
||
| import jwt | ||
| from django.conf import settings | ||
| from django.contrib.auth.models import AnonymousUser | ||
| from rest_framework import authentication, exceptions | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| REFRESH_INTERVAL = 3600 # 1 hour | ||
| jwks_client = jwt.PyJWKClient(settings.JWKS_URI) | ||
| jwks_client_lock = threading.Lock() | ||
|
|
||
|
|
||
| def get_jwks_client(): | ||
| with jwks_client_lock: | ||
| return jwks_client | ||
|
|
||
|
|
||
| def start_jwks_refresh(): | ||
| def refresh(): | ||
| global jwks_client | ||
| while True: | ||
| try: | ||
| new_client = jwt.PyJWKClient(settings.JWKS_URI) | ||
| with jwks_client_lock: | ||
| jwks_client = new_client | ||
| logger.info("[JWK] JWKs client updated and cached.") | ||
| except Exception as e: | ||
| logger.info("[JWK] Error updating JWKs client: %s", e) | ||
| time.sleep(REFRESH_INTERVAL) | ||
|
|
||
| thread = threading.Thread(target=refresh, daemon=True) | ||
| thread.start() | ||
|
|
||
|
|
||
| def verify_jwt(token): | ||
| try: | ||
| signing_key = jwks_client.get_signing_key_from_jwt(token).key | ||
| payload = jwt.decode( | ||
| token, signing_key, audience=settings.AUTH_OIDC_CLIENT_ID, algorithms=["RS256"] | ||
| ) | ||
| return payload | ||
| except jwt.PyJWTError: | ||
| raise exceptions.AuthenticationFailed("Invalid JWT Token.") | ||
|
|
||
|
|
||
| class JWTAuthentication(authentication.BaseAuthentication): | ||
| """ | ||
| Authentication based on JWT tokens stored in cookies. | ||
| """ | ||
|
|
||
| def authenticate(self, request): | ||
| id_token = request.COOKIES.get("id_token") | ||
| if id_token: | ||
| payload = verify_jwt(id_token) | ||
| if payload: | ||
| pprint.pprint(payload) | ||
luke-rt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return (payload, None) | ||
| return (AnonymousUser, None) | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ | |
|
|
||
| import boto3 | ||
| import dj_database_url | ||
| import dotenv | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this in prod?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not but rn we only have a test credential anyways |
||
|
|
||
|
|
||
| dotenv.load_dotenv() | ||
|
|
||
|
|
||
| DOMAINS = os.environ.get("DOMAINS", "example.com").split(",") | ||
|
|
@@ -174,6 +178,10 @@ | |
| WEBHOOK_USERNAME = os.environ.get("WEBHOOK_USERNAME", "webhook") | ||
| WEBHOOK_PASSWORD = os.environ.get("WEBHOOK_PASSWORD", "password") | ||
|
|
||
| # Penn Labs Platform JWKs | ||
| JWKS_URI = f"https://platform.pennlabs.org/accounts/.well-known/jwks.json" | ||
| AUTH_OIDC_CLIENT_ID = os.environ.get("AUTH_OIDC_CLIENT_ID", "") | ||
|
|
||
| # Email Configuration | ||
| SMTP_HOST = os.environ.get("SMTP_HOST", "") | ||
| SMTP_PORT = os.environ.get("SMTP_PORT", 587) | ||
|
|
@@ -199,6 +207,7 @@ | |
| "rest_framework.authentication.SessionAuthentication", | ||
| "rest_framework.authentication.BasicAuthentication", | ||
| "accounts.authentication.PlatformAuthentication", | ||
| "PennCourses.authentication.jwt.JWTAuthentication", | ||
| ], | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,6 @@ | ||
| { | ||
| "extends": ["next/core-web-vitals", "next/typescript"], | ||
| "rules": { | ||
| "@typescript-eslint/explicit-function-return-type": "off" | ||
| } | ||
| } |
This file contains hidden or 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,36 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.js | ||
| .yarn/install-state.gz | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # local env files | ||
| .env*.local | ||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts |
This file contains hidden or 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,36 @@ | ||
| This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). | ||
|
|
||
| ## Getting Started | ||
|
|
||
| First, run the development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| # or | ||
| pnpm dev | ||
| # or | ||
| bun dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
|
||
| You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
|
||
| This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. | ||
|
|
||
| ## Learn More | ||
|
|
||
| To learn more about Next.js, take a look at the following resources: | ||
|
|
||
| - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
| - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
|
||
| You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! | ||
|
|
||
| ## Deploy on Vercel | ||
|
|
||
| The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
|
||
| Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
This file contains hidden or 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,113 @@ | ||
| import React from "react"; | ||
| import Link from "next/link"; | ||
| import { cn } from "@/lib/utils"; | ||
| import Image from "next/image"; | ||
|
|
||
| export default function About() { | ||
| return ( | ||
| <div className={cn("mx-[10%]")}> | ||
| <h2>Hey there!</h2> | ||
| <p>Welcome to the new Penn Course Review!</p> | ||
| <p> | ||
| The student-run Penn Course Review has served as a valuable | ||
| guide for course selection since the 1960s. In 2014, Penn Course | ||
| Review was completely redesigned to simplify the search | ||
| experience. In 2018, we updated the site again to continue | ||
| providing you with the best insights on courses. In 2021, we | ||
| migrated the site over to a shared backend with{" "} | ||
| <a | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| href="https://penncoursealert.com/" | ||
| > | ||
| Penn Course Alert | ||
| </a>{" "} | ||
| and{" "} | ||
| <a | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| href="https://penncourseplan.com/" | ||
| > | ||
| Penn Course Plan | ||
| </a> | ||
| , allowing us to serve additional metrics about course | ||
| registration difficulty (based on Penn Course Alert usage data | ||
| and course status updates). We hope to continue updating and | ||
| improving Penn Course Review in the years to come! | ||
| </p> | ||
|
|
||
| <h2>About</h2> | ||
| <p> | ||
| Penn Course Review is a student-run service that provides | ||
| numerical ratings and metrics for undergraduate courses and | ||
| professors at the University of Pennsylvania. PCR has a long | ||
| history of being a valuable and influential guide for course | ||
| selection. | ||
| </p> | ||
| <p> | ||
| PCR is developed and managed by{" "} | ||
| <a | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| href="https://pennlabs.org/" | ||
| > | ||
| Penn Labs | ||
| </a> | ||
| , a student developer organization on Penn's campus. | ||
| </p> | ||
|
|
||
| <p> | ||
| Penn Course Review compiles its information from online course | ||
| evaluations conducted at the end of each semester by the | ||
| Provost's office in conjunction with ISC. | ||
| </p> | ||
| <p> | ||
| Your evaluations and comments feed the Review, so the more | ||
| information you provide about your courses and professors, the | ||
| more comprehensive Penn Course Review will be. | ||
| </p> | ||
|
|
||
| <p> | ||
| If you want to look at courses on the go,{" "} | ||
| <a | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| href="https://pennlabs.org/mobile/" | ||
| > | ||
| PennMobile | ||
| </a>{" "} | ||
| is available for download! In the courses section, you are able | ||
| to view course descriptions and ratings! | ||
| </p> | ||
| <p> | ||
| Interested in building something using the Penn Courses API? | ||
| Check our our{" "} | ||
| <a | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| href="https://penncoursereview.com/api/documentation/" | ||
| > | ||
| API documentation | ||
| </a> | ||
| . | ||
| </p> | ||
| <p>Thanks and happy searching,</p> | ||
| <p> | ||
| <strong>Penn Labs</strong> | ||
| </p> | ||
|
|
||
| <Image | ||
| alt="Penn Labs" | ||
| src="/image/labs.png" | ||
| width={100} | ||
| height={100} | ||
| /> | ||
|
|
||
| <h2>Questions</h2> | ||
| <p> | ||
| If you have any questions, take a look at our{" "} | ||
| <Link href="/faq">FAQs</Link> section. | ||
| </p> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.