Compare commits
8 Commits
8c9cb6f21d
...
2cac589b0f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cac589b0f | ||
|
|
29859664e3 | ||
|
|
0ceb5d7fc3 | ||
|
|
947c831609 | ||
|
|
ce95ec7444 | ||
|
|
95214f7af3 | ||
|
|
0f49c91fde | ||
|
|
0262c573ae |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -109,3 +109,4 @@ Icon
|
|||||||
Network Trash Folder
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
**/temp/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {cd, path} from 'zx'
|
import {cd, path} from 'zx'
|
||||||
import {trim} from "licia";
|
import {trim} from "licia";
|
||||||
import {run_deploy_batch, run_deploy_root, run_package, run_upload_normal} from "./library.js";
|
import {run_deploy_batch, run_deploy_root, run_package, run_upload} from "./library.js";
|
||||||
|
|
||||||
// 切换目录
|
// 切换目录
|
||||||
cd(trim(path.dirname(import.meta.dirname)))
|
cd(trim(path.dirname(import.meta.dirname)))
|
||||||
@@ -9,7 +9,7 @@ try {
|
|||||||
await run_deploy_root()
|
await run_deploy_root()
|
||||||
await run_deploy_batch(['service-cli', 'service-cli/service-cli-core'])
|
await run_deploy_batch(['service-cli', 'service-cli/service-cli-core'])
|
||||||
await run_package('service-cli/service-cli-runner')
|
await run_package('service-cli/service-cli-runner')
|
||||||
await run_upload_normal('service-cli-runner', 'service-cli')
|
await run_upload('**/service-cli-runner-1.0.0-SNAPSHOT.jar')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {cd, path} from 'zx'
|
import {cd, path} from 'zx'
|
||||||
import {trim} from "licia";
|
import {trim} from "licia";
|
||||||
import {run_deploy_batch, run_deploy_root, run_package, run_upload_normal} from "./library.js";
|
import {run_deploy_batch, run_deploy_root, run_package, run_upload} from "./library.js";
|
||||||
|
|
||||||
// 切换目录
|
// 切换目录
|
||||||
cd(trim(path.dirname(import.meta.dirname)))
|
cd(trim(path.dirname(import.meta.dirname)))
|
||||||
@@ -9,7 +9,7 @@ try {
|
|||||||
await run_deploy_root()
|
await run_deploy_root()
|
||||||
await run_deploy_batch(['service-common', 'service-dependencies', 'service-configuration', 'service-forest', 'service-executor', 'service-executor/service-executor-core'])
|
await run_deploy_batch(['service-common', 'service-dependencies', 'service-configuration', 'service-forest', 'service-executor', 'service-executor/service-executor-core'])
|
||||||
await run_package('service-executor/service-executor-manager')
|
await run_package('service-executor/service-executor-manager')
|
||||||
await run_upload_normal('service-executor-manager', 'service-executor')
|
await run_upload('**/service-executor-manager-1.0.0-SNAPSHOT.jar')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {cd, path} from 'zx'
|
import {cd, path} from 'zx'
|
||||||
import {trim} from "licia";
|
import {trim} from "licia";
|
||||||
import {run_deploy_batch, run_deploy_root, run_package, run_upload_normal} from "./library.js";
|
import {run_deploy_batch, run_deploy_root, run_package, run_upload} from "./library.js";
|
||||||
|
|
||||||
// 切换目录
|
// 切换目录
|
||||||
cd(trim(path.dirname(import.meta.dirname)))
|
cd(trim(path.dirname(import.meta.dirname)))
|
||||||
@@ -9,7 +9,7 @@ try {
|
|||||||
await run_deploy_root()
|
await run_deploy_root()
|
||||||
await run_deploy_batch(['service-common', 'service-dependencies', 'service-configuration', 'service-forest', 'service-executor', 'service-executor/service-executor-core'])
|
await run_deploy_batch(['service-common', 'service-dependencies', 'service-configuration', 'service-forest', 'service-executor', 'service-executor/service-executor-core'])
|
||||||
await run_package('service-executor/service-executor-task')
|
await run_package('service-executor/service-executor-task')
|
||||||
await run_upload_normal('service-executor-task', 'service-executor')
|
await run_upload('**/service-executor-task-1.0.0-SNAPSHOT.jar')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {cd, path} from 'zx'
|
import {cd, path} from 'zx'
|
||||||
import {trim} from "licia";
|
import {trim} from "licia";
|
||||||
import {run_deploy_batch, run_deploy_root, run_package, run_upload_normal} from "./library.js";
|
import {run_deploy_batch, run_deploy_root, run_package, run_upload} from "./library.js";
|
||||||
|
|
||||||
// 切换目录
|
// 切换目录
|
||||||
cd(trim(path.dirname(import.meta.dirname)))
|
cd(trim(path.dirname(import.meta.dirname)))
|
||||||
@@ -9,7 +9,7 @@ try {
|
|||||||
await run_deploy_root()
|
await run_deploy_root()
|
||||||
await run_deploy_batch(['service-common'])
|
await run_deploy_batch(['service-common'])
|
||||||
await run_package('utils/patch')
|
await run_package('utils/patch')
|
||||||
await run_upload_normal('**/patch-1.0.0-SNAPSHOT.jar')
|
await run_upload('**/patch-1.0.0-SNAPSHOT.jar')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import {$, fetch, fs, glob, os, path, spinner, syncProcessCwd, usePowerShell} from 'zx'
|
import {$, fetch, fs, glob, os, path, spinner, syncProcessCwd, usePowerShell} from 'zx'
|
||||||
import {isEqual, trim} from "licia";
|
import {isEqual, trim, fileSize} from "licia";
|
||||||
|
import md5file from 'md5-file'
|
||||||
|
|
||||||
syncProcessCwd(true)
|
syncProcessCwd(true)
|
||||||
if (isEqual(os.platform(), 'win32')) {
|
if (isEqual(os.platform(), 'win32')) {
|
||||||
@@ -39,7 +40,7 @@ export const run_deploy = async (project) => {
|
|||||||
`Deploying project ${project}`,
|
`Deploying project ${project}`,
|
||||||
() => $`mvn -pl ${project} clean deploy -D skipTests -s ${maven_setting}`
|
() => $`mvn -pl ${project} clean deploy -D skipTests -s ${maven_setting}`
|
||||||
)
|
)
|
||||||
console.log(`✅ Finish deploy ${project} (${millisecondToString(output['duration'])})`)
|
console.log(`✅ Finished deploy ${project} (${millisecondToString(output['duration'])})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const run_deploy_root = async () => {
|
export const run_deploy_root = async () => {
|
||||||
@@ -47,7 +48,7 @@ export const run_deploy_root = async () => {
|
|||||||
`Deploying root`,
|
`Deploying root`,
|
||||||
() => $`mvn clean deploy -N -D skipTests -s ${maven_setting}`
|
() => $`mvn clean deploy -N -D skipTests -s ${maven_setting}`
|
||||||
)
|
)
|
||||||
console.log(`✅ Finish deploy root (${millisecondToString(output['duration'])})`)
|
console.log(`✅ Finished deploy root (${millisecondToString(output['duration'])})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const run_deploy_batch = async (projects) => {
|
export const run_deploy_batch = async (projects) => {
|
||||||
@@ -61,7 +62,7 @@ export const run_package = async (project, profile = 'b2b12') => {
|
|||||||
`Packaging project ${project}${isEqual(profile, 'b2b12') ? '' : ` ${profile}`}`,
|
`Packaging project ${project}${isEqual(profile, 'b2b12') ? '' : ` ${profile}`}`,
|
||||||
() => $`mvn -pl ${project} clean package -D skipTests -P ${profile} -s ${maven_setting}`
|
() => $`mvn -pl ${project} clean package -D skipTests -P ${profile} -s ${maven_setting}`
|
||||||
)
|
)
|
||||||
console.log(`✅ Finish package ${project}${isEqual(profile, 'b2b12') ? '' : ` ${profile}`} (${millisecondToString(output['duration'])})`)
|
console.log(`✅ Finished package ${project}${isEqual(profile, 'b2b12') ? '' : ` ${profile}`} (${millisecondToString(output['duration'])})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const run_package_batch = async (projects) => {
|
export const run_package_batch = async (projects) => {
|
||||||
@@ -71,6 +72,7 @@ export const run_package_batch = async (projects) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const upload = async (file_path) => {
|
const upload = async (file_path) => {
|
||||||
|
let start = new Date().getTime()
|
||||||
let response = await spinner(
|
let response = await spinner(
|
||||||
`Uploading project ${file_path}`,
|
`Uploading project ${file_path}`,
|
||||||
() => fetch(`${upload_url}/file/upload/${path.basename(file_path)}`, {
|
() => fetch(`${upload_url}/file/upload/${path.basename(file_path)}`, {
|
||||||
@@ -87,7 +89,9 @@ const upload = async (file_path) => {
|
|||||||
if (!isEqual(response.status, 200)) {
|
if (!isEqual(response.status, 200)) {
|
||||||
throw response
|
throw response
|
||||||
}
|
}
|
||||||
console.log(`✅ Finish upload ${file_path}`)
|
console.log(`✅ Finished upload ${file_path} (${millisecondToString((new Date().getTime()) - start)})`)
|
||||||
|
console.log(`📘 Uploaded ${fileSize(fs.statSync(file_path).size)}`)
|
||||||
|
console.log(`📘 MD5 ${md5file.sync(file_path)}`)
|
||||||
fs.rmSync(file_path)
|
fs.rmSync(file_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"fs-extra": "^11.3.0",
|
"fs-extra": "^11.3.0",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
"licia": "^1.48.0",
|
"licia": "^1.48.0",
|
||||||
|
"md5-file": "^5.0.0",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"node-fetch-native": "^1.6.6",
|
"node-fetch-native": "^1.6.6",
|
||||||
"which": "^5.0.0",
|
"which": "^5.0.0",
|
||||||
|
|||||||
10
bin/pnpm-lock.yaml
generated
10
bin/pnpm-lock.yaml
generated
@@ -26,6 +26,9 @@ importers:
|
|||||||
licia:
|
licia:
|
||||||
specifier: ^1.48.0
|
specifier: ^1.48.0
|
||||||
version: 1.48.0
|
version: 1.48.0
|
||||||
|
md5-file:
|
||||||
|
specifier: ^5.0.0
|
||||||
|
version: 5.0.0
|
||||||
minimist:
|
minimist:
|
||||||
specifier: ^1.2.8
|
specifier: ^1.2.8
|
||||||
version: 1.2.8
|
version: 1.2.8
|
||||||
@@ -129,6 +132,11 @@ packages:
|
|||||||
licia@1.48.0:
|
licia@1.48.0:
|
||||||
resolution: {integrity: sha512-bBWiT5CSdEtwuAHiYTJ74yItCjIFdHi4xiFk6BRDfKa+sdCpkUHp69YKb5udNOJlHDzFjNjcMgNZ/+wQIHrB8A==}
|
resolution: {integrity: sha512-bBWiT5CSdEtwuAHiYTJ74yItCjIFdHi4xiFk6BRDfKa+sdCpkUHp69YKb5udNOJlHDzFjNjcMgNZ/+wQIHrB8A==}
|
||||||
|
|
||||||
|
md5-file@5.0.0:
|
||||||
|
resolution: {integrity: sha512-xbEFXCYVWrSx/gEKS1VPlg84h/4L20znVIulKw6kMfmBUAZNAnF00eczz9ICMl+/hjQGo5KSXRxbL/47X3rmMw==}
|
||||||
|
engines: {node: '>=10.13.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
merge2@1.4.1:
|
merge2@1.4.1:
|
||||||
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
@@ -283,6 +291,8 @@ snapshots:
|
|||||||
|
|
||||||
licia@1.48.0: {}
|
licia@1.48.0: {}
|
||||||
|
|
||||||
|
md5-file@5.0.0: {}
|
||||||
|
|
||||||
merge2@1.4.1: {}
|
merge2@1.4.1: {}
|
||||||
|
|
||||||
micromatch@4.0.8:
|
micromatch@4.0.8:
|
||||||
|
|||||||
6
bin/test.js
Normal file
6
bin/test.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import {fs} from 'zx'
|
||||||
|
|
||||||
|
let stats = fs.statSync('/Users/lanyuanxiaoyao/Project/IdeaProjects/hudi-service/service-api');
|
||||||
|
console.log(stats.ctime)
|
||||||
|
console.log(stats.atime)
|
||||||
|
console.log(stats.mtime)
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"fs-extra": "^11.3.0",
|
"fs-extra": "^11.3.0",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
"licia": "^1.48.0",
|
"licia": "^1.48.0",
|
||||||
|
"md5-file": "^5.0.0",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"node-fetch-native": "^1.6.6",
|
"node-fetch-native": "^1.6.6",
|
||||||
"which": "^5.0.0",
|
"which": "^5.0.0",
|
||||||
|
|||||||
10
service-ai/bin/pnpm-lock.yaml
generated
10
service-ai/bin/pnpm-lock.yaml
generated
@@ -26,6 +26,9 @@ importers:
|
|||||||
licia:
|
licia:
|
||||||
specifier: ^1.48.0
|
specifier: ^1.48.0
|
||||||
version: 1.48.0
|
version: 1.48.0
|
||||||
|
md5-file:
|
||||||
|
specifier: ^5.0.0
|
||||||
|
version: 5.0.0
|
||||||
minimist:
|
minimist:
|
||||||
specifier: ^1.2.8
|
specifier: ^1.2.8
|
||||||
version: 1.2.8
|
version: 1.2.8
|
||||||
@@ -129,6 +132,11 @@ packages:
|
|||||||
licia@1.48.0:
|
licia@1.48.0:
|
||||||
resolution: {integrity: sha512-bBWiT5CSdEtwuAHiYTJ74yItCjIFdHi4xiFk6BRDfKa+sdCpkUHp69YKb5udNOJlHDzFjNjcMgNZ/+wQIHrB8A==}
|
resolution: {integrity: sha512-bBWiT5CSdEtwuAHiYTJ74yItCjIFdHi4xiFk6BRDfKa+sdCpkUHp69YKb5udNOJlHDzFjNjcMgNZ/+wQIHrB8A==}
|
||||||
|
|
||||||
|
md5-file@5.0.0:
|
||||||
|
resolution: {integrity: sha512-xbEFXCYVWrSx/gEKS1VPlg84h/4L20znVIulKw6kMfmBUAZNAnF00eczz9ICMl+/hjQGo5KSXRxbL/47X3rmMw==}
|
||||||
|
engines: {node: '>=10.13.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
merge2@1.4.1:
|
merge2@1.4.1:
|
||||||
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
@@ -283,6 +291,8 @@ snapshots:
|
|||||||
|
|
||||||
licia@1.48.0: {}
|
licia@1.48.0: {}
|
||||||
|
|
||||||
|
md5-file@5.0.0: {}
|
||||||
|
|
||||||
merge2@1.4.1: {}
|
merge2@1.4.1: {}
|
||||||
|
|
||||||
micromatch@4.0.8:
|
micromatch@4.0.8:
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.lanyuanxiaoyao.service.ai.core.configuration;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* web 配置
|
|
||||||
*
|
|
||||||
* @author lanyuanxiaoyao
|
|
||||||
* @date 2023-04-21
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebConfiguration implements WebMvcConfigurer {
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
// 避免跨域影响调试
|
|
||||||
registry.addMapping("/**")
|
|
||||||
.allowedOriginPatterns("*")
|
|
||||||
.allowCredentials(true)
|
|
||||||
.allowedMethods("*")
|
|
||||||
.maxAge(3600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,9 +12,6 @@ import org.springframework.security.core.userdetails.User;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
@@ -29,23 +26,12 @@ public class SecurityConfig {
|
|||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
return http.authorizeHttpRequests(registry -> registry.anyRequest().authenticated())
|
return http.authorizeHttpRequests(registry -> registry.anyRequest().authenticated())
|
||||||
.httpBasic(Customizer.withDefaults())
|
.httpBasic(Customizer.withDefaults())
|
||||||
|
.cors(AbstractHttpConfigurer::disable)
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.cors(configurer -> configurer.configurationSource(corsConfigurationSource()))
|
|
||||||
.formLogin(AbstractHttpConfigurer::disable)
|
.formLogin(AbstractHttpConfigurer::disable)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CorsConfigurationSource corsConfigurationSource() {
|
|
||||||
CorsConfiguration configuration = new CorsConfiguration();
|
|
||||||
configuration.setAllowCredentials(true);
|
|
||||||
configuration.addAllowedHeader("*");
|
|
||||||
configuration.addAllowedMethod("*");
|
|
||||||
configuration.addAllowedOriginPattern("*");
|
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
||||||
source.registerCorsConfiguration("/**", configuration);
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public InMemoryUserDetailsManager userDetailsService(SecurityProperties securityProperties) {
|
public InMemoryUserDetailsManager userDetailsService(SecurityProperties securityProperties) {
|
||||||
UserDetails user = User.builder()
|
UserDetails user = User.builder()
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
private final SecurityProperties securityProperties;
|
private final SecurityProperties securityProperties;
|
||||||
|
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
|
||||||
public SecurityConfig(SecurityProperties securityProperties) {
|
public SecurityConfig(SecurityProperties securityProperties) {
|
||||||
this.securityProperties = securityProperties;
|
this.securityProperties = securityProperties;
|
||||||
}
|
}
|
||||||
@@ -36,6 +35,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.and()
|
.and()
|
||||||
.csrf()
|
.csrf()
|
||||||
.disable()
|
.disable()
|
||||||
|
.cors()
|
||||||
|
.disable()
|
||||||
.formLogin()
|
.formLogin()
|
||||||
.disable();
|
.disable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.lanyuanxiaoyao</groupId>
|
<groupId>com.lanyuanxiaoyao</groupId>
|
||||||
<artifactId>service-dependencies</artifactId>
|
<artifactId>service-configuration</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -22,10 +22,6 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.lanyuanxiaoyao</groupId>
|
|
||||||
<artifactId>service-configuration</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import org.springframework.security.core.userdetails.MapReactiveUserDetailsServi
|
|||||||
import org.springframework.security.core.userdetails.User;
|
import org.springframework.security.core.userdetails.User;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.reactive.CorsConfigurationSource;
|
||||||
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web security
|
* web security
|
||||||
@@ -28,12 +31,26 @@ public class SecurityConfiguration {
|
|||||||
.permitAll()
|
.permitAll()
|
||||||
.and()
|
.and()
|
||||||
.httpBasic()
|
.httpBasic()
|
||||||
|
.disable()
|
||||||
|
.cors()
|
||||||
|
.configurationSource(corsConfigurationSource())
|
||||||
.and()
|
.and()
|
||||||
.csrf()
|
.csrf()
|
||||||
.disable()
|
.disable()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CorsConfigurationSource corsConfigurationSource() {
|
||||||
|
CorsConfiguration configuration = new CorsConfiguration();
|
||||||
|
configuration.setAllowCredentials(true);
|
||||||
|
configuration.addAllowedHeader("*");
|
||||||
|
configuration.addAllowedMethod("*");
|
||||||
|
configuration.addAllowedOriginPattern("*");
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", configuration);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MapReactiveUserDetailsService userDetailsService(SecurityProperties securityProperties) {
|
public MapReactiveUserDetailsService userDetailsService(SecurityProperties securityProperties) {
|
||||||
UserDetails user = User.builder()
|
UserDetails user = User.builder()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.lanyuanxiaoyao.service.gateway.configuration;
|
package com.lanyuanxiaoyao.service.gateway.configuration;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.web.reactive.config.CorsRegistry;
|
import org.springframework.web.reactive.config.CorsRegistry;
|
||||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||||
@@ -10,6 +11,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurer;
|
|||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @date 2024-01-15
|
* @date 2024-01-15
|
||||||
*/
|
*/
|
||||||
|
@Configuration
|
||||||
public class WebConfiguration implements WebFluxConfigurer {
|
public class WebConfiguration implements WebFluxConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {ProLayout} from '@ant-design/pro-components'
|
import {ProLayout} from '@ant-design/pro-components'
|
||||||
import React, {useEffect} from 'react'
|
import React from 'react'
|
||||||
import {Outlet, useLocation, useNavigate} from 'react-router'
|
import {Outlet, useLocation, useNavigate} from 'react-router'
|
||||||
import {menus} from '../route.tsx'
|
import {menus} from '../route.tsx'
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.lanyuanxiaoyao.service.web.configuration;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* web 配置
|
|
||||||
*
|
|
||||||
* @author lanyuanxiaoyao
|
|
||||||
* @date 2023-04-21
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebConfiguration implements WebMvcConfigurer {
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
// 避免跨域影响调试
|
|
||||||
registry.addMapping("/**")
|
|
||||||
.allowedOriginPatterns("*")
|
|
||||||
.allowCredentials(true)
|
|
||||||
.allowedMethods("*")
|
|
||||||
.maxAge(3600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user