Merge pull request #21 from denpiligrim/revert-1-advisory-fix-1

Revert "fix: hardcode credentials"
This commit is contained in:
DenPiligrim
2026-02-06 12:54:50 +03:00
committed by GitHub
3 changed files with 5 additions and 20 deletions
+2 -6
View File
@@ -175,8 +175,6 @@ FINAL_PORT=$(get_random_port)
# --- 4. Генерация паролей ---
DB_PASS=$(openssl rand -base64 12)
JWT_SECRET=$(openssl rand -base64 32)
ADMIN_USER=$(openssl rand -base64 12)
ADMIN_PASS=$(openssl rand -base64 12)
log "Сгенерированы секретные ключи для БД и JWT."
#################################
@@ -188,8 +186,6 @@ DB_PORT=5432
DB_USERNAME=admin
DB_PASSWORD=${DB_PASS}
DB_NAME=3dp_manager
ADMIN_LOGIN=${ADMIN_USER}
ADMIN_PASSWORD=${ADMIN_PASS}
EOF
if [[ "$USE_SSL" == "true" ]]; then
@@ -416,8 +412,8 @@ if [[ "$USE_SSL" == "true" ]]; then
else
echo -e "${GREEN}✔ Установка завершена! Доступно по адресу: http://${UI_HOST}:${FINAL_PORT}${NC}"
fi
echo "${GREEN}Логин: $ADMIN_USER"
echo "${GREEN}Пароль: $ADMIN_PASS"
echo "Логин: admin"
echo "Пароль: admin"
echo ""
echo "Немедленно измените пароль в Настройках утилиты!"
echo "==================================================="
-7
View File
@@ -1,7 +0,0 @@
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=admin
DB_PASSWORD=
DB_NAME=3dp_manager
ADMIN_LOGIN=admin
ADMIN_PASSWORD=
+3 -7
View File
@@ -4,7 +4,6 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import * as bcrypt from 'bcrypt';
import { Setting } from '../settings/entities/setting.entity';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class AuthService {
@@ -14,7 +13,6 @@ export class AuthService {
@InjectRepository(Setting)
private settingsRepo: Repository<Setting>,
private jwtService: JwtService,
private configService: ConfigService,
) {}
async validateUser(login: string, pass: string): Promise<any> {
@@ -87,14 +85,12 @@ export class AuthService {
const login = await this.settingsRepo.findOne({ where: { key: 'admin_login' } });
if (!login) {
this.logger.log('Инициализация администратора...');
const envLogin = this.configService.get<string>('ADMIN_LOGIN') || 'admin';
const envPass = this.configService.get<string>('ADMIN_PASSWORD') || 'admin';
this.logger.log('Инициализация администратора (admin / admin)...');
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: envLogin });
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: 'admin' });
await this.settingsRepo.save(loginSetting);
const hash = await bcrypt.hash(envPass, 10);
const hash = await bcrypt.hash('admin', 10);
const passSetting = this.settingsRepo.create({ key: 'admin_password', value: hash });
await this.settingsRepo.save(passSetting);