Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
Expand All @@ -35,6 +36,7 @@
import com.clougence.clouddm.console.web.global.handler.StaticResourceNoCacheFilter;
import com.clougence.clouddm.console.web.global.i18n.DmI18nUtils;
import com.clougence.clouddm.init.constant.I18nInitFieldKeys;
import com.clougence.clouddm.init.service.InitWebsitePluginLoader;
import com.clougence.utils.ShutdownHook;

import jakarta.annotation.PostConstruct;
Expand Down Expand Up @@ -75,7 +77,8 @@ public static void main(String[] args) {
+ "com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration");
SpringApplication application = new SpringApplication(InitApplication.class);
application.setRegisterShutdownHook(false);
application.run(args);
ConfigurableApplicationContext context = application.run(args);
context.getBean(InitWebsitePluginLoader.class).loadPlugin(InitApplication.class.getClassLoader());

log.info("[DmAloneLauncher] Alone All Context Inited.");
ShutdownHook.joinShutdown();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private static String buildInitAdminRoleSql() {
}

private static String buildInitPrimaryUserSql() {
String adminAccount = InitSeedConstants.escapeSqlLiteral(InitSeedConstants.resolveAdminAccount());
String adminEmail = InitSeedConstants.escapeSqlLiteral(InitSeedConstants.resolveAdminEmail());
String encodedPassword = CryptService.INSTANCE.encryptForOneWay(InitSeedConstants.resolveAdminPassword()).getEncryptPassword();
String encryptedSecretKey = CryptService.INSTANCE.encryptUseDefaultKeyAndSalt(InitSeedConstants.DEFAULT_PRIMARY_SECRET_KEY);
Expand All @@ -51,14 +52,15 @@ private static String buildInitPrimaryUserSql() {
`op_locked`, `account_type`, `user_domain`, `disable`, `parent_id`, `maintainer`, `aliyun_ak`, `aliyun_sk`,
`last_date_update_aliyun_ak`, `bind_type`, `bind_account`, `phone_area_code`,
`user_status`, `src`, `client_id`, `keyword`, `contact_me`, `country`)
VALUES (1,now(), now(), '%s', 'Trial', '%s', '%s', null, '',
VALUES (1,now(), now(), '%s', '%s', '%s', '%s', null, '',
'%s', null, %s,
'%s',
'%s',
now(), 0, 0, now(), 0, 0, 'PRIMARY_ACCOUNT', '%s.cdmgr.com', 0, null,
0, null, null, now(), 'INTERNAL', null, null, 'NORMAL', null, null, null, 0, null)\
""".formatted( //
InitSeedConstants.ADMIN_UID, //
adminAccount, //
adminEmail, //
InitSeedConstants.DEFAULT_PRIMARY_PHONE, //
encodedPassword, ADMIN_ROLE_ID, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class V202606050001__dm_auth_user_account extends AbstractUpgradeJavaMigr

@Override
public List<String> collectScript() {
String adminAccount = InitSeedConstants.escapeSqlLiteral(InitSeedConstants.DEFAULT_PRIMARY_ACCOUNT);
String adminAccount = InitSeedConstants.escapeSqlLiteral(InitSeedConstants.resolveAdminAccount());
return List.of("""
ALTER TABLE dm_auth_user
MODIFY COLUMN username varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum I18nInitFieldKeys {
INIT_FIELD_DB_PASSWORD_DESC,
INIT_FIELD_JWT_SECRET_LABEL,
INIT_FIELD_JWT_SECRET_DESC,
INIT_FIELD_ADMIN_ACCOUNT_LABEL,
INIT_FIELD_ADMIN_ACCOUNT_DESC,
INIT_FIELD_ADMIN_EMAIL_LABEL,
INIT_FIELD_ADMIN_EMAIL_DESC,
INIT_FIELD_ADMIN_PASSWORD_LABEL,
Expand All @@ -41,15 +43,6 @@ public enum I18nInitFieldKeys {
INIT_TEST_DB_SUCCESS,
INIT_TEST_DB_CONNECTION_FAILED,
INIT_TEST_DB_CHARSET_INVALID,
INIT_MYSQL_DRIVER_REQUIRED,
INIT_MYSQL_DRIVER_PREPARING,
INIT_MYSQL_DRIVER_READY,
INIT_MYSQL_DRIVER_UNAVAILABLE,
INIT_MYSQL_DRIVER_PREPARE_FAILED,
INIT_MYSQL_DRIVER_PREPARE_STARTED,
INIT_MYSQL_DRIVER_FILE_DOWNLOAD_COMPLETE,
INIT_MYSQL_DRIVER_FILE_DOWNLOADING,
INIT_MYSQL_DRIVER_FILE_DEFAULT_NAME,
INIT_TEST_DB_REBUILD_PROMPT,
INIT_TEST_DB_USE_EXISTING_WARNING,
INIT_TEST_DB_REBUILD_WARNING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class InitSeedConstants {
public static final String DEFAULT_WORKER_IP = "172.31.239.4";
public static final String DEFAULT_CONSOLE_IP = "172.31.239.3";
public static final String DEFAULT_EXTERNAL_IP = "183.134.161.226";
public static final String RUNTIME_ADMIN_ACCOUNT_KEY = "clougence.init.admin.account";
public static final String RUNTIME_ADMIN_EMAIL_KEY = "clougence.init.admin.email";
public static final String RUNTIME_ADMIN_PASSWORD_KEY = "clougence.init.admin.password";

Expand All @@ -42,6 +43,10 @@ public static String resolveAdminEmail() {
return defaultIfBlank(System.getProperty(RUNTIME_ADMIN_EMAIL_KEY), DEFAULT_PRIMARY_EMAIL);
}

public static String resolveAdminAccount() {
return defaultIfBlank(System.getProperty(RUNTIME_ADMIN_ACCOUNT_KEY), DEFAULT_PRIMARY_ACCOUNT);
}

public static String resolveAdminPassword() {
return defaultIfBlank(System.getProperty(RUNTIME_ADMIN_PASSWORD_KEY), DEFAULT_PRIMARY_PASSWORD);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.clougence.clouddm.console.web.global.jwtsession.RequestAuth;
import com.clougence.clouddm.init.model.InitFieldDef;
import com.clougence.clouddm.init.model.TestDbResult;
import com.clougence.clouddm.init.service.InitMysqlDriverService;
import com.clougence.clouddm.init.service.SysInitDefService;
import com.clougence.clouddm.init.service.SysInitService;

Expand All @@ -48,8 +47,6 @@ public class InitController {
private SysInitService initService;
@Resource
private SysInitDefService defService;
@Resource
private InitMysqlDriverService initMysqlDriverService;

/**
* Returns the default configuration field definitions.
Expand Down Expand Up @@ -77,19 +74,6 @@ public ResWebData<?> testDb(@RequestBody Map<String, String> params) {
return ResWebDataUtils.buildSuccess(result);
}

@RequestAuth(strategy = RequestAuth.AuthStrategy.Ignore)
@RequestMapping(value = "/checkDriverStatus", method = { RequestMethod.POST })
public ResWebData<?> checkDriverStatus() {
return ResWebDataUtils.buildSuccess(this.initMysqlDriverService.driverStatus());
}

@RequestAuth(strategy = RequestAuth.AuthStrategy.Ignore)
@RequestMapping(value = "/downloadDriver", method = { RequestMethod.POST })
public ResWebData<?> downloadDriver() {
this.initMysqlDriverService.downloadDriver();
return ResWebDataUtils.buildSuccess(null);
}

@RequestAuth(strategy = RequestAuth.AuthStrategy.Ignore)
@RequestMapping(value = "/previewScripts", method = { RequestMethod.POST })
public ResWebData<?> previewScripts(@RequestBody Map<String, String> params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2026 杭州开云集致科技有限公司
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.clougence.clouddm.init.controller;

import java.io.IOException;
import java.util.Locale;

import org.springframework.context.annotation.Profile;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.clougence.clouddm.console.web.component.file.PluginResourceManager;
import com.clougence.clouddm.console.web.component.file.mode.PluginResourceData;
import com.clougence.clouddm.console.web.component.file.resource.PluginResourceModel;
import com.clougence.clouddm.console.web.global.jwtsession.RequestAuth;
import com.clougence.clouddm.sdk.resource.ResourceRequest;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Profile("init")
@RestController
public class InitFaviconController {

private static final String FAVICON_RESOURCE = "webside/favicon";
private static final String FAVICON_FORMAT = "ico";

@RequestAuth(strategy = RequestAuth.AuthStrategy.Ignore)
@RequestMapping(value = "/favicon.ico", method = { RequestMethod.GET })
public ResponseEntity<byte[]> favicon(HttpServletRequest httpRequest) {
try {
PluginResourceModel resourceModel = PluginResourceManager.findResource(FAVICON_RESOURCE);
if (resourceModel == null) {
return ResponseEntity.notFound().build();
}

PluginResourceData resourceData = resourceModel.load(buildResourceRequest(httpRequest));
if (resourceData == null || resourceData.inputStream() == null) {
return ResponseEntity.notFound().build();
}

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType(resourceData.contentType()));
headers.setCacheControl(CacheControl.noCache());
try (var inputStream = resourceData.inputStream()) {
return ResponseEntity.ok().headers(headers).body(inputStream.readAllBytes());
}
} catch (IOException e) {
log.warn("Failed to load favicon resource '{}'.", FAVICON_RESOURCE, e);
return ResponseEntity.internalServerError().build();
}
}

private ResourceRequest buildResourceRequest(HttpServletRequest httpRequest) {
ResourceRequest request = new ResourceRequest();
request.setLoggedIn(false);
request.setExpectedFormat(FAVICON_FORMAT);

if (httpRequest != null) {
Locale locale = httpRequest.getLocale();
request.setLanguage(locale == null ? null : locale.toLanguageTag());
}
return request;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class InitHomeController {
private SysInitDefService defService;

@RequestAuth(strategy = RequestAuth.AuthStrategy.Ignore)
@RequestMapping(value = "/dm_global_settings", method = { RequestMethod.POST })
@RequestMapping(value = "/dmGlobalSettings", method = { RequestMethod.POST })
public ResWebData<?> dmGlobalSettings() {
GlobalSettingsVO vo = new GlobalSettingsVO();
vo.setVersion(GlobalConfUtils.getAppVersion());
Expand Down

This file was deleted.

Loading