-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/72 authentication frameworkgoogle #104
Conversation
As per request from some people I'm going to explain how to test the PR. I've used the extension ModHeader to introduce the header Authorization. You simply add the header, the name should be Authorization and the value should be "JWT access_token" (without the ". The token is created in /api/auth/jwt/create). To test each endpoint, simply search it. If it's a post action, introduce the parameters it needs if it asks for them and click post. The endpoints may ask for the authorization header. Make sure the Authorization header is only used when needed, it may break other websites. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thoroughly tested every endpoint, both for a google account and for a regular account. All the test cases worked.
This looks like it took a lot of effort to implement. I sincerely congratulate you for your work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did a great job with the authentication framework. Now is working as expected, and you fulfilled all the requirements. Congratulations!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was a huge payload and your work was superb, congratulations.
Refactored authentication system to use Djoser, a authentication library compatible with Rest Framework.
The following working endpoints were introduced:
get /api/auth/users/me/
Needs: header: Authorization=JWT access_token
Action: List the user with the associated access_token
get: /api/auth/users/
Needs: header: Authorization=JWT access_token
Action: List the users if the access_token's user has permission
post: /api/auth/users/
Needs: Add parameters
Action: Create user
post /api/auth/jwt/create
Needs: Add parameters
Action: Create access_token and refresh_token
post /api/auth/jwt/refresh
Needs: add refresh_token
Action: Create new access_token and refresh_token
post /api/auth/blacklist
Needs: Add refresh_token
Action: Blacklist refrest_token, needed for logout.
Research "2–4) Logging out and blacklisting tokens" in for more information in the react implementation of logout
get /api/auth/o/google-oauth2/?redirect_uri=http://127.0.0.1:8000/api/redirect-social/
Action: Returns authorization_url which directs to google login.
get authoriation_url
Action: Loging in redirects to /api/redirect-social which returns a 'code' and a 'state'
post /api/auth/o/google-oauth2/?state=state&code=code
Needs: Returns access, refresh and user
Action: The user created is not enabled because it lacks id_number. To activate it see next post.
post /api/auth/activate/
Needs: header: Authorization=JWT access_token
Action: Activate the user associated to the access_token if it has an id_number
This PR changes the User model to use the default Django user as base.