Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
16 lines
460 B
TypeScript
16 lines
460 B
TypeScript
import { Injectable, CanActivate, NotFoundException } from "@nestjs/common";
|
|
|
|
/**
|
|
* Guard that checks if local authentication is enabled via ENABLE_LOCAL_AUTH env var.
|
|
* Returns 404 when disabled so endpoints are invisible to callers.
|
|
*/
|
|
@Injectable()
|
|
export class LocalAuthEnabledGuard implements CanActivate {
|
|
canActivate(): boolean {
|
|
if (process.env.ENABLE_LOCAL_AUTH !== "true") {
|
|
throw new NotFoundException();
|
|
}
|
|
return true;
|
|
}
|
|
}
|