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

Add an authorize endpoint that uses JSON instead of a Django template… #1306

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jhnbyrn
Copy link
Contributor

@jhnbyrn jhnbyrn commented Aug 12, 2023

…/HTML form

Fixes #1305

Description of the Change

For single page applications it would be handy to be able to get the data for the authorization page as JSON and then render the authorization page on the client side, and similarly post the results as JSON rather than as a HTML form.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

Merging #1306 (78bd3e8) into master (a4ae1d4) will increase coverage by 0.00%.
The diff coverage is 95.83%.

@@           Coverage Diff           @@
##           master    #1306   +/-   ##
=======================================
  Coverage   97.37%   97.38%           
=======================================
  Files          32       32           
  Lines        2022     2028    +6     
=======================================
+ Hits         1969     1975    +6     
  Misses         53       53           
Files Changed Coverage Δ
oauth2_provider/views/base.py 97.97% <95.83%> (+0.08%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jhnbyrn jhnbyrn marked this pull request as ready for review August 31, 2023 12:11
@jhnbyrn jhnbyrn marked this pull request as draft August 31, 2023 12:36
elif require_approval == "auto":
tokens = (
get_access_token_model()
.objects.filter(
Copy link

@dashdanw dashdanw Sep 13, 2023

Choose a reason for hiding this comment

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

you could potentially avoid iteration by filtering by your desired scopes (assuming the scopes var here is the required scopes of the view)

Suggested change
.objects.filter(
scopes_filter = { 'scopes__icontains': scope for scope in scopes }
.objects.filter(
user=request.user,
application=kwargs["application"],
expires__gt=timezone.now(),
**scopes_filter
).first()

@dopry
Copy link
Contributor

dopry commented Oct 9, 2024

@jhnbyrn can you rebase this.. i'm open to using a mixin here if it enables you use case and doesn't break existing functionality.

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.

JSON endpoint for auth URL
3 participants