Merge commit from fork
fix: hardcode credentials
This commit is contained in:
+6
-2
@@ -175,6 +175,8 @@ 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."
|
||||
|
||||
#################################
|
||||
@@ -186,6 +188,8 @@ 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
|
||||
@@ -412,8 +416,8 @@ if [[ "$USE_SSL" == "true" ]]; then
|
||||
else
|
||||
echo -e "${GREEN}✔ Установка завершена! Доступно по адресу: http://${UI_HOST}:${FINAL_PORT}${NC}"
|
||||
fi
|
||||
echo "Логин: admin"
|
||||
echo "Пароль: admin"
|
||||
echo "${GREEN}Логин: $ADMIN_USER"
|
||||
echo "${GREEN}Пароль: $ADMIN_PASS"
|
||||
echo ""
|
||||
echo "Немедленно измените пароль в Настройках утилиты!"
|
||||
echo "==================================================="
|
||||
@@ -0,0 +1,7 @@
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_USERNAME=admin
|
||||
DB_PASSWORD=
|
||||
DB_NAME=3dp_manager
|
||||
ADMIN_LOGIN=admin
|
||||
ADMIN_PASSWORD=
|
||||
@@ -4,6 +4,7 @@ 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 {
|
||||
@@ -13,6 +14,7 @@ export class AuthService {
|
||||
@InjectRepository(Setting)
|
||||
private settingsRepo: Repository<Setting>,
|
||||
private jwtService: JwtService,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
async validateUser(login: string, pass: string): Promise<any> {
|
||||
@@ -85,12 +87,14 @@ export class AuthService {
|
||||
const login = await this.settingsRepo.findOne({ where: { key: 'admin_login' } });
|
||||
|
||||
if (!login) {
|
||||
this.logger.log('Инициализация администратора (admin / admin)...');
|
||||
this.logger.log('Инициализация администратора...');
|
||||
const envLogin = this.configService.get<string>('ADMIN_LOGIN') || 'admin';
|
||||
const envPass = this.configService.get<string>('ADMIN_PASSWORD') || 'admin';
|
||||
|
||||
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: 'admin' });
|
||||
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: envLogin });
|
||||
await this.settingsRepo.save(loginSetting);
|
||||
|
||||
const hash = await bcrypt.hash('admin', 10);
|
||||
const hash = await bcrypt.hash(envPass, 10);
|
||||
const passSetting = this.settingsRepo.create({ key: 'admin_password', value: hash });
|
||||
await this.settingsRepo.save(passSetting);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user