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

TBCCT-158 Backend base data upload #156

Merged
merged 5 commits into from
Jan 9, 2025
Merged

TBCCT-158 Backend base data upload #156

merged 5 commits into from
Jan 9, 2025

Conversation

alepefe
Copy link
Collaborator

@alepefe alepefe commented Dec 11, 2024

This pull request includes significant changes to the authentication module, backoffice service, and the addition of a new file ingestion feature. The most important changes include adding a new custom passport strategy, refactoring the backoffice service, and implementing a file ingestion page in the backoffice.

Authentication Module Updates:

  • Added passport-custom dependency in api/package.json to support custom authentication strategies.
  • Removed BackofficeService from auth.module.ts and updated its import path in authentication.controller.ts. [1] [2] [3]
  • Introduced BackofficeSessionStrategy and integrated it into the authentication.module.ts. [1] [2] [3] [4]
  • Created JwtCookieAuthGuard to handle JWT and backoffice session authentication.
  • Updated import.controller.ts to use JwtCookieAuthGuard instead of JwtAuthGuard. [1] [2]

Backoffice Service Refactoring:

  • Removed the old backoffice.service.ts and added a new one with enhanced functionality, including cookie generation and session retrieval. [1] [2]
  • Added a new backoffice.module.ts to encapsulate the backoffice service and its dependencies.

File Ingestion Feature:

  • Implemented a new file ingestion page in the backoffice with two tabs for different data uploads.
  • Updated backoffice/index.ts to include the new file ingestion page and ensure it is properly loaded and watched. [1] [2] [3]

Dependency and Configuration Updates:

  • Added styled-components, react, and related type definitions to backoffice/package.json and pnpm-lock.yaml to support the new file ingestion feature. [1] [2] [3] [4] [5] [6]
  • Updated tsconfig.json in the backoffice to include .tsx files.

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tnc-blue-carbon-cost-tool-ghps ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 0:47am

@@ -260,6 +260,8 @@ jobs:
backoffice:
image: $ECR_REGISTRY/$ECR_REPOSITORY_ADMIN:$IMAGE_TAG
restart: always
environment:
NODE_ENV: production
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to pass the env here?

Copy link
Collaborator Author

@alepefe alepefe Jan 8, 2025

Choose a reason for hiding this comment

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

Because if I want to work with a container locally for testing purposes, the variable was passed in directly like this pnpm --filter backoffice run start:prod and the environment property of a docker compose file service was not working, I could not pass NODE_ENV=development.

This is just for comfort but we could fall back to the previous approach.


@Controller()
@UseGuards(JwtAuthGuard, RolesGuard)
@UseGuards(JwtCookieAuthGuard, RolesGuard)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see the point of this, but wouldn't this disable the functionality of uploading the file through a jwt-authenticated POST request? (with no cookies)

Could we have both?

Copy link
Collaborator Author

@alepefe alepefe Jan 8, 2025

Choose a reason for hiding this comment

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

Basically, the frontend does not save to the client the JWT it uses to send requests to the backend.
Andrés told me he saw in the nextjs documentation that you can customize the library's implementation at your own risk.
Therefore, in order to provide a full bidirectionaladminjs -> api integration, the api generates the adminjs session cookie and adminjs can also authenticate an admin with a session cookie.

@@ -214,7 +229,7 @@ const start = async () => {
);

app.use(admin.options.rootPath, adminRouter);

admin.watch()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Leftover?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it does like nodemon but for adminjs.

package.json Show resolved Hide resolved
@alepefe alepefe merged commit edf1817 into dev Jan 9, 2025
2 checks passed
@alepefe alepefe deleted the feat/tbcct-158 branch January 9, 2025 15:42
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.

2 participants