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

Auth for NestJS and Fastify #698

Open
anteqkois opened this issue Mar 9, 2024 · 8 comments
Open

Auth for NestJS and Fastify #698

anteqkois opened this issue Mar 9, 2024 · 8 comments

Comments

@anteqkois
Copy link

Is there any way to add auth layer for this configuration? I have tried middleware and npm packages for basic auth but they don't work. With middlewares, there is probably an issue with resolving paths. So now, I don't find any way to add secure auth layer ://

@felixmosh
Copy link
Owner

felixmosh commented Mar 10, 2024

Did you checked the examples folder?

@jakub-zawislak
Copy link

@anteqkois Did you manage to set up the authentication?

@niraj-khatiwada
Copy link

Hi @felixmosh the example directory seem to have code for ExpressAdapter but not for FastifyAdapter. I'm also trying to implement auth for bullboard. Is there any reference for auth with Nest+Fastify?

Thanks for the awesome library.

@felixmosh
Copy link
Owner

Nope, I don't have secret examples that are not in the examples folder 😅

@ChazUK
Copy link

ChazUK commented Dec 2, 2024

I'm also struggling trying to figure out how to add Authentication via the Nest.js Module approach.

@niraj-khatiwada
Copy link

For now, I'm just disabling the access of bull board UI in Nginx and access it with ssh and port forwarded to my local. It's a bit cumbersome but works.

@clintonb
Copy link

clintonb commented Jan 6, 2025

@felixmosh can you reopen this? There is a real need for an example of using Bull Board with NestJS. At the very least this issue can be a call for someone to provide such an example. I've been struggling with this for the past few hours, and there is a lot to understand between Bull Board, NestJS, Passport (most likely), and the underlying server adapter (e.g., Express or Fastify).

I understand most of these components individually. Putting them together is proving more difficult than I anticipated. An example would go a long way toward saving many others hours of effort.

Edit: Now that I've dug into the code itself, it seems that BullBoardRootModule bypasses NestJS app guards altogether:

if (isExpressAdapter(this.adapter)) {
return consumer
.apply(this.options.middleware, this.adapter.getRouter())
.forRoutes(this.options.route);
}
if (isFastifyAdapter(this.adapter)) {
this.adapterHost.httpAdapter
.getInstance()
.register(this.adapter.registerPlugin(), { prefix });
return consumer
.apply(this.options.middleware)
.forRoutes(this.options.route);
}

We effectively need to treat this as a separate middleware that exists almost entirely outside of the NestJS framework.

@felixmosh felixmosh reopened this Jan 7, 2025
@felixmosh
Copy link
Owner

@clintonb do you have any improvment for the Nest.js adapter?
(I'm not familier with Nest.js at all, therefore, I relay on contribution)

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

No branches or pull requests

6 participants