fix: remove secrets from code

This commit is contained in:
2024-03-03 15:36:35 +01:00
parent 32757e1dca
commit 8a3796e694
3 changed files with 12 additions and 5 deletions

View File

@@ -7,4 +7,9 @@ AWS_REGION=123
AWS_SES_SMTP_HOST=123
AWS_SES_SMTP_PORT=123
AWS_SES_SMTP_USER=123
AWS_SES_SMTP_PASS=123
AWS_SES_SMTP_PASS=123
AWS_BUCKET_NAME=123
AWS_S3_ACCESS_KEY=123
AWS_S3_SECRET_ACCESS_KEY=123
ADMIN_LOGIN=123
ADMIN_PASSWORD=123

View File

@@ -5,12 +5,14 @@ import { Observable } from 'rxjs'
export class BaseAuthGuard implements CanActivate {
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
const request = context.switchToHttp().getRequest()
const exceptedAuthInput = 'Basic YWRtaW46cXdlcnR5'
const acceptedAuthInput =
'Basic ' +
Buffer.from(`${process.env.ADMIN_LOGIN}:${process.env.ADMIN_PASSWORD}`).toString('base64')
if (!request.headers || !request.headers.authorization) {
throw new UnauthorizedException([{ message: 'No any auth headers' }])
throw new UnauthorizedException([{ message: 'No auth headers found' }])
} else {
if (request.headers.authorization != exceptedAuthInput) {
if (request.headers.authorization != acceptedAuthInput) {
throw new UnauthorizedException([
{
message: 'login or password invalid',

View File

@@ -42,7 +42,7 @@ export class UsersController {
return users
}
//@UseGuards(BaseAuthGuard)
@UseGuards(BaseAuthGuard)
@Post()
async create(@Body() createUserDto: CreateUserDto) {
return await this.commandBus.execute(