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

Set up forms app with authentication #1497

Open
wants to merge 1 commit into
base: forms
Choose a base branch
from
Open

Conversation

jchristgit
Copy link
Member

This begins the work of integrating the forms backend into the site.
Changes, until complete, will be merged into the forms tracking
branch.

@jchristgit jchristgit force-pushed the forms-bootstrap branch 2 times, most recently from 0a51298 to 8b6dbeb Compare March 27, 2025 19:08
This begins the work of integrating the forms backend into the site.
Changes, until complete, will be merged into the `forms` tracking
branch.
@jb3 jb3 requested a review from Copilot April 6, 2025 21:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • .coveragerc: Language not supported
Comments suppressed due to low confidence (1)

pydis_site/apps/forms/tests/test_api.py:127

  • [nitpick] Consider revising or removing the informal comment to maintain a professional tone in test files.
# the ultimate power trip...

Comment on lines +88 to 89
FORMS_SECRET_KEY = SECRET_KEY

Copy link
Preview

Copilot AI Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FORMS_SECRET_KEY is assigned multiple times (in DEBUG, CI, and then from the environment). Consider consolidating its configuration to avoid potential inconsistencies during authentication.

Suggested change
FORMS_SECRET_KEY = SECRET_KEY

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

def has_permission(self, request: HttpRequest, view: View) -> bool:
"""Only allow authenticated users with the configured set of scopes to access this resource."""
# XXX: this should check for superset, not strict equality.
return request.user.is_authenticated and request.auth and frozenset(request.auth.scopes) == self.scopes
Copy link
Preview

Copilot AI Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using strict equality for scope comparison may lead to authorization issues. Consider checking if the user’s scopes are a superset of the required scopes instead.

Suggested change
return request.user.is_authenticated and request.auth and frozenset(request.auth.scopes) == self.scopes
return request.user.is_authenticated and request.auth and frozenset(request.auth.scopes).issuperset(self.scopes)

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Comment on lines +108 to +111
oldest = min(role.last_update for role in roles)
if not util.is_stale(oldest, 60 * 60 * 24): # 1 day
return tuple(roles)

Copy link
Preview

Copilot AI Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no roles are present in the database, calling min() could raise an error. Consider adding a check to ensure the queryset is not empty before finding the minimum timestamp.

Suggested change
oldest = min(role.last_update for role in roles)
if not util.is_stale(oldest, 60 * 60 * 24): # 1 day
return tuple(roles)
if roles:
oldest = min(role.last_update for role in roles)
if not util.is_stale(oldest, 60 * 60 * 24): # 1 day
return tuple(roles)

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant