codebuddies / backend

CodeBuddies back-end
https://codebuddies.org
GNU General Public License v3.0
20 stars 25 forks source link

[Documentation] Need to Add/Alter API Endpoint Instructions, etc. to Reflect New Auth Flow #189

Open BethanyG opened 3 years ago

BethanyG commented 3 years ago

Now that we'e decided to implement a Registration and Login flow and re-organize our auth endpoints (PR #187), post-merge we'll need to update our documentation to show the endpoint & functionality changes:

  1. Registration will now require an email
  2. A user will not be able to sign in without a validated email
  3. Email addresses are validated through an email with a special link containing a token. The token needs to be passed in a POST to the api/v1/auth/verify-email/ endpoint, which will flag the email as "valid" in the DB.
  4. Users will also be able to request password reset emails. Password reset emails will contain a UID and TOKEN. A POST to /api/v1/auth/password/reset/confirm/ with:
{
    "new_password1": "",
    "new_password2": "",
    "uid": "",
    "token": ""
}

will reset the user password associated with the UID.


Current Endpoints after PR #187 is merged:

Django Admin Interface and Login:

Obtaining JWT tokens:

The length of time access and refresh tokens remain valid can be configured in config/settings/base.py by adding a SIMPLE_JWT={} dictionary of values. please note: this project does not currently use SLIDING_TOKEN, only ACCESS_TOKEN and REFRESH_TOKEN current defaults from the library are:

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': False,
    'BLACKLIST_AFTER_ROTATION': True,

    'ALGORITHM': 'HS256',
    'SIGNING_KEY': settings.SECRET_KEY,
    'VERIFYING_KEY': None,
    'AUDIENCE': None,
    'ISSUER': None,

    'AUTH_HEADER_TYPES': ('Bearer',),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',

    'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',

    'JTI_CLAIM': 'jti',

    'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp',
    'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5),
    'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1),
}

Registration/Login/Logout/password reset:

User Details & current_user:

Viewing and Creating Resources:

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

BethanyG commented 3 years ago

Still open.