Skip to content

81 refactor i uzupełnienie swaggera do metod auth#174

Open
JanekDr wants to merge 20 commits intodevfrom
81-refactor-i-uzupełnienie-swaggera-do-metod-auth

Hidden character warning

The head ref may contain hidden characters: "81-refactor-i-uzupe\u0142nienie-swaggera-do-metod-auth"
Open

81 refactor i uzupełnienie swaggera do metod auth#174
JanekDr wants to merge 20 commits intodevfrom
81-refactor-i-uzupełnienie-swaggera-do-metod-auth

Conversation

@JanekDr
Copy link
Copy Markdown
Member

@JanekDr JanekDr commented Mar 15, 2026

  • Migracja klas: Wszystkie endpointy Solvro/USOS OAuth przeniesione na DRF APIView/AsyncAPIView dla poprawnego generowania schematu. Wszelkie opcje redirect korzystają z parametryzacji docelowych widoków klasowych.
  • Opisy wejść/wyjść: Dodano dekoratory @extend_schema ze szczegółowym wykazem rzucanych kodów błędów (200, 302, 400, 401, 403, 404) dla każdej ścieżki JWT i OTP.
  • Bugfix walidacji na OTP: Dodano authentication_classes = [] do publicznych widoków OTP i LoginLinkView. Eliminacja błędnych response 401 Unauthorized dla starych sesji.
  • Wszystkie endpointy są dostępne w sekcji Authentication w dokumentacji.

@JanekDr JanekDr self-assigned this Mar 15, 2026
@JanekDr JanekDr requested a review from MoonPrincess06 as a code owner March 15, 2026 17:27
@JanekDr JanekDr linked an issue Mar 15, 2026 that may be closed by this pull request
@JanekDr JanekDr requested a review from MoonPrincess06 March 18, 2026 14:28
@JanekDr JanekDr requested a review from MoonPrincess06 March 29, 2026 18:13
@Antoni-Czaplicki
Copy link
Copy Markdown
Member

@JanekDr co myślisz żeby zrobić helper safe_redirect który w sobie sprawdzi czy jest safe i jak coś to nadpisze?

@Antoni-Czaplicki
Copy link
Copy Markdown
Member

i pamiętaj też żeby dać Resolve jak już jest komentarz ogarnięty

@JanekDr
Copy link
Copy Markdown
Member Author

JanekDr commented Mar 31, 2026

@JanekDr co myślisz żeby zrobić helper safe_redirect który w sobie sprawdzi czy jest safe i jak coś to nadpisze?

Myśle ze to dobry pomysł i uszczupli lekko kod w metodach auth dla usosa i solvro

Copy link
Copy Markdown
Contributor

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.

Pull request overview

Refactors the authentication-related OAuth and OTP endpoints in users to improve DRF Spectacular (Swagger/OpenAPI) schema generation, while tightening redirect safety checks and documenting request/response variants.

Changes:

  • Migrates Solvro/USOS OAuth endpoints from function-based views to DRF APIView / adrf async API views.
  • Expands @extend_schema documentation across JWT, OAuth, and OTP endpoints (params, examples, and response codes).
  • Updates redirect safety logic and adds tests for DEBUG-dependent HTTP/HTTPS redirect handling; adds initial OAuth flow tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
users/views.py New class-based OAuth endpoints, enhanced schema docs, updated redirect safety logic, and public OTP views made explicitly unauthenticated.
users/urls.py Routes updated to point to the new class-based OAuth views.
users/tests/test_redirect_url.py Adds DEBUG=True/False coverage for HTTP vs HTTPS redirect acceptance.
users/tests/test_oauth.py Adds tests asserting callback URL composition and a mocked Solvro authorize flow.
Comments suppressed due to low confidence (1)

users/views.py:574

  • Same add_query_params + view-name issue in the banned-user jwt=true branch: if redirect_url is the default view name, redirect(add_query_params(...)) can raise NoReverseMatch and return 500 instead of redirecting with an error.
            if request.GET.get("jwt", "false") == "true":
                auth_params = {"error": "user_banned"}
                if user.ban_reason:
                    auth_params["ban_reason"] = user.ban_reason
                return redirect(add_query_params(redirect_url, auth_params))

Copy link
Copy Markdown
Contributor

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor i uzupełnienie swaggera do metod auth

5 participants