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 simplejwt to authorization setup #4926

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

add simplejwt to authorization setup #4926

wants to merge 3 commits into from

Conversation

crutan
Copy link
Contributor

@crutan crutan commented Jan 15, 2025

What's this PR do?

Add simplejwt support to the authorization options, adds an additional block to handle bearer tokens

How to test

This PR enables you to get a set of authorization and refresh tokens by authenticating against SEED:

curl -X POST -H 'Content-Type: application/json' -d '{"username":"[email protected]", "password":"password"}' http://localhost/api/token/

That will return a refresh and access token:

{"refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTczNzA2MDk4MSwiaWF0IjoxNzM2OTc0NTgxLCJqdGkiOiIzNmRmZjhmMzYwNTc0NjBhYTk3MTJiNTYzZjgzNjg2MyIsInVzZXJfaWQiOjJ9.PampCBSI2djMnfmx8MZv4oocvEVfd_hrY4k238nX81Q","access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzM2OTc0ODgxLCJpYXQiOjE3MzY5NzQ1ODEsImp0aSI6ImIwYTdkMjYwODc4MDQ3ZmI4YmQ4NGIwMTJjM2JjZGJlIiwidXNlcl9pZCI6Mn0.3Dq7lQ1KVbEDkUn12Qyt2MhZXDpZmPdbjwyhu77PhmI"}

The access token can then be used as a bearer token for authorization:

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzM2OTcxMjEyLCJpYXQiOjE3MzY5NzA5MTIsImp0aSI6ImI2NWZjZDc5OWJlYTQyOGQ4ZGQzYzI1OWQxMzYxODJjIiwidXNlcl9pZCI6Mn0.q0gVvHpujfTPzB0Nye019AzNdPo6M1RPCK8A3uZfBME" -X POST "http://localhost/api/v3/properties/filter/?cycle=2&ids_only=false&include_related=true&organization_id=1&page=1&per_page=100"

These steps are taken from here: https://django-rest-framework-simplejwt.readthedocs.io/en/stable/getting_started.html

@crutan crutan self-assigned this Jan 15, 2025
Copy link

Label error. Requires at least 1 of: Feature, Bug, Enhancement, Maintenance, Documentation, Performance, Do not publish. Found:

@crutan crutan added the Enhancement Add this label if functionality was generally improved but not a full feature or maintentance. label Jan 15, 2025
Copy link
Contributor

@perryr16 perryr16 left a comment

Choose a reason for hiding this comment

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

Retrieved user tokens, and was able to pass them along to hit various endpoints in both postman and curl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Add this label if functionality was generally improved but not a full feature or maintentance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants