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

Enabling Authentication and Authorization from a Single Middleware for Cookie and Bearer Token-Based Flows #1926

Merged
merged 9 commits into from
Mar 5, 2024

Conversation

Pavangbhat
Copy link
Contributor

@Pavangbhat Pavangbhat commented Feb 25, 2024

Date: 26-02-2024

Developer Name: Pavan Bhat


Issue Ticket Number

This ticket does not close the issue but solves a part of this issue

Description

Updated certain middlewares for specific routes, intended for migration to a cron job. This modification facilitates authentication and authorization through a unified middleware, accommodating both cookie-based authentication and authentication via public and private keys for APIs triggered within the cron job context.

Route's Modified:

  • User Status Update:

    • Endpoint: /users/status/update
    • Method: PATCH
  • Idle (No Auth & Auto):

    • Endpoint: /users/status?aggregate=true
    • Method: GET
  • Batch Idle:

    • Endpoint: /users/status/batch
    • Method: PATCH

syncExternalAccountsButton

  • Endpoint: /external-accounts/users?action=discord-users-sync
  • Method: POST

syncUnverifiedUsersButton

  • Endpoint: /users/
  • Method: POST

syncIdleUsersButton

  • Endpoint: /discord-actions/group-idle
  • Method: PUT

syncNickNamesButton

  • Endpoint: /discord-actions/nicknames/sync?dev=true
  • Method: POST

syncIdle7dUsersButton

  • Endpoint: /discord-actions/group-idle-7d
  • Method: PUT

syncOnboarding31dPlusUsersButton

  • Endpoint: /discord-actions/group-onboarding-31d-plus
  • Method: PUT

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1

Test Coverage

Test cases for this new middleware is already present and current changes do not require any new test cases

Screenshot 1

Additional Notes

This approach still provides us capability of triggering these APIs through the dashboard site

routes/external-accounts.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/userStatus.js Fixed Show fixed Hide fixed
routes/userStatus.js Fixed Show fixed Hide fixed
routes/users.js Fixed Show fixed Hide fixed
routes/external-accounts.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/users.js Fixed Show fixed Hide fixed
routes/userStatus.js Fixed Show fixed Hide fixed
routes/userStatus.js Fixed Show fixed Hide fixed
routes/discordactions.js Dismissed Show dismissed Hide dismissed
routes/discordactions.js Dismissed Show dismissed Hide dismissed
routes/external-accounts.js Dismissed Show dismissed Hide dismissed
routes/discordactions.js Fixed Show fixed Hide fixed
routes/discordactions.js Dismissed Show dismissed Hide dismissed
routes/userStatus.js Dismissed Show dismissed Hide dismissed
routes/userStatus.js Dismissed Show dismissed Hide dismissed
routes/users.js Dismissed Show dismissed Hide dismissed
test/integration/authorizeUsersAndService.test.ts Dismissed Show dismissed Hide dismissed
Ajeyakrishna-k
Ajeyakrishna-k previously approved these changes Feb 27, 2024
middlewares/authorizeUsersAndService.ts Show resolved Hide resolved
routes/discordactions.js Outdated Show resolved Hide resolved
routes/discordactions.js Dismissed Show dismissed Hide dismissed
Copy link
Member

@iamitprakash iamitprakash left a comment

Choose a reason for hiding this comment

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

Can you add test case stats, I just want to see current line and brach coverage numbers please

@Pavangbhat
Copy link
Contributor Author

Can you add test case stats, I just want to see current line and brach coverage numbers please


Coverage Percentage Details
Branches 50.96% 1004/1970
Functions 59.28% 667/1125
Lines 65.04% 4117/6329

@iamitprakash iamitprakash merged commit 2afa3bc into develop Mar 5, 2024
3 checks passed
@iamitprakash iamitprakash deleted the feature/auth-enhance branch March 5, 2024 14:57
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.

6 participants