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

Gap 2587/redirect to404when not allowed on a page #440

Merged
merged 5 commits into from
Apr 16, 2024

Conversation

a-lor-cab
Copy link
Contributor

@a-lor-cab a-lor-cab commented Apr 16, 2024

GAP-2587

Description

if a user was logged in, and tried to access any other subdomain not within his role capabilities, the user service was redirecting the user to its dashboard.
we now implemented logic to redirect the user to a 404/page based on the user role

Summary of the changes and the related issue. List any dependencies that are required for this change:
cabinetoffice/gap-user-service#202

Type of change

Please check the relevant options.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change requires a documentation update.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes:

  • Unit Test

  • Integration Test (if applicable)

  • End to End Test (if applicable)

Screenshots (if appropriate):

Please attach screenshots of the change if it is a UI change:

Checklist:

  • If I have listed dependencies above, I have ensured that they are present in the target branch.
  • I have performed a self-review of my code.
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the documentation where applicable.
  • I have ran cypress tests and they all pass locally.

Copy link
Contributor

@tco-olivergodby tco-olivergodby left a comment

Choose a reason for hiding this comment

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

CAUTION! There is some kind of horrible regression in this repo - speak to Paul Lawlor, check the Automated Checks

Looks good to me - merge when ready

@@ -11,7 +11,17 @@ const authenticateRequest = async (req: NextRequest, res: NextResponse) => {
const authCookie = req.cookies.get('session_id');
const userJwtCookie = req.cookies.get(process.env.JWT_COOKIE_NAME);

if (!authCookie || !userJwtCookie) {
await csrfMiddleware(req, res);
Copy link
Contributor

@jgunnCO jgunnCO Apr 16, 2024

Choose a reason for hiding this comment

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

hmm git has been doing some strange merges today - this line needs to be removed or we'll end up calling this middleware twice (it's also invoked after authenticateRequest in the calling middleware function below), which does not work as I discovered yesterday

@tco-olivergodby tco-olivergodby merged commit 3b2b3ae into develop Apr 16, 2024
14 checks passed
@ConorFayleTCO ConorFayleTCO deleted the GAP-2587/redirectTo404whenNotAllowedOnAPage branch April 16, 2024 12:45
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.

4 participants