2 Commits

Author SHA1 Message Date
0101056b5f adding public decorator 2025-11-16 09:23:21 -06:00
ea108de9cd 12 change auth to OIDC (#13)
* switching auth strategy to oidc

* switching auth strategy to oidc
2025-08-26 21:11:16 -05:00
3 changed files with 16 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import { ExecutionContext, Injectable } from '@nestjs/common';
import { AuthGuard as PassportAuthGuard } from '@nestjs/passport';
import { Observable } from 'rxjs';
import { IS_PUBLIC_KEY } from '../decorators/public.decorator';
@Injectable()
export class AuthGuard extends PassportAuthGuard('oidc') {
@@ -9,6 +10,13 @@ export class AuthGuard extends PassportAuthGuard('oidc') {
}
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
const isPublic = this.reflector.get<boolean>(
IS_PUBLIC_KEY,
context.getHandler()
)
if (isPublic) return true;
return super.canActivate(context);
}
}

View File

@@ -0,0 +1,4 @@
import { SetMetadata } from "@nestjs/common";
export const IS_PUBLIC_KEY = "isPublic";
export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);

View File

@@ -8,6 +8,10 @@ export * from './auth/public.decorator';
export * from './util/customError';
// Decorators
export { IS_PUBLIC_KEY, Public } from './decorators/public.decorator'
// User
export * from './user/user.module';