auth defined test required

This commit is contained in:
2025-07-27 15:54:23 +03:00
parent f39dc541e1
commit 6cf7ce1397
17 changed files with 857 additions and 147 deletions

View File

@@ -6,30 +6,13 @@ import {
} from '@nestjs/common';
import { RedisHandlers } from '@/src/utils/auth/redis_handlers';
const getAccessTokenFromHeader = (req: Request): string => {
console.log(req.headers);
const token = req.headers['acs'];
if (!token) {
throw new ForbiddenException('Access token header is missing');
}
return token;
};
const getSelectTokenFromHeader = (req: Request): string => {
const token = req.headers['slc'];
if (!token) {
throw new ForbiddenException('Select token header is missing');
}
return token;
};
@Injectable()
export class AuthControlGuard implements CanActivate {
constructor(private cacheService: RedisHandlers) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const req = context.switchToHttp().getRequest();
const accessToken = getAccessTokenFromHeader(req);
const accessToken = this.cacheService.mergeLoginKey(req);
console.log('AuthControlGuard', accessToken);
// const hasAccess = accessObject.permissions?.some(
// (p: any) => p.method === method && p.url === path,
@@ -49,7 +32,7 @@ export class EndpointControlGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const req = context.switchToHttp().getRequest();
const selectToken = getSelectTokenFromHeader(req);
const selectToken = this.cacheService.mergeSelectKey(req);
const method = req.method;
const path = req.route?.path;
console.log('EndpointControlGuard', selectToken, method, path);