From 997d8a0ac96178905d897568b92078bb09d8cf5c Mon Sep 17 00:00:00 2001 From: xking Date: Fri, 21 Mar 2025 15:27:15 +0800 Subject: [PATCH] update --- debian 11 安装 编译nginx.md | 17 +----- java/spring-security.md | 97 +++++++++++++++++++++++++++++++++ oracle/oracle.md | 60 +++++++++++++++++++- 3 files changed, 159 insertions(+), 15 deletions(-) create mode 100644 java/spring-security.md diff --git a/debian 11 安装 编译nginx.md b/debian 11 安装 编译nginx.md index 5e9e12d..30fae2d 100644 --- a/debian 11 安装 编译nginx.md +++ b/debian 11 安装 编译nginx.md @@ -351,7 +351,7 @@ apt-get --purge remove nginx ###### nginx.conf -``` +```nginx worker_processes auto; @@ -415,19 +415,8 @@ http { server_tokens off; access_log off; - server { - listen 80; - server_name localhost; - location / { - root html; - index index.html index.htm; - } - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - } -include /etc/nginx/site-enable/*.conf; + + include /etc/nginx/site-enable/*.conf; } ``` diff --git a/java/spring-security.md b/java/spring-security.md new file mode 100644 index 0000000..759fcd9 --- /dev/null +++ b/java/spring-security.md @@ -0,0 +1,97 @@ +在Spring Security中,`SecurityFilterChain`和`WebSecurityCustomizer`分别用于不同的配置场景,以下是它们的核心区别和使用场景: + +### 1. **SecurityFilterChain** + +- **作用**:配置`HttpSecurity`,定义请求级别的安全规则(如URL访问控制、认证机制、CSRF、CORS等)。 + +- **适用场景**: + + - 需要为特定URL路径设置访问权限(如`permitAll()`、`authenticated()`)。 + - 配置登录/注销行为、表单登录、OAuth2、JWT等认证机制。 + - 启用或禁用安全特性(如CSRF保护、Session管理)。 + +- **特点**: + + - 请求会经过完整的Spring Security过滤器链。 + - 即使路径设置为`permitAll()`,请求仍会被安全过滤器处理(如记录日志、CSRF验证等)。 + +- **示例**: + + java + + 复制 + + ``` + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/public/**").permitAll() // 允许匿名访问 + .anyRequest().authenticated() // 其他请求需认证 + .and() + .formLogin() // 启用表单登录 + .loginPage("/login") + .permitAll(); + return http.build(); + } + ``` + +------ + +### 2. **WebSecurityCustomizer** + +- **作用**:配置`WebSecurity`,**全局忽略**某些路径,使其完全绕过Spring Security过滤器链。 + +- **适用场景**: + + - 忽略静态资源(如CSS、JS、图片)或公开API路径。 + - 提升性能,避免不必要的安全处理。 + +- **特点**: + + - 被忽略的路径不会经过任何安全过滤器。 + - 无法在此处配置细粒度的安全规则(如角色权限、认证方式)。 + +- **示例**: + + java + + 复制 + + ``` + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring() + .antMatchers("/static/**", "/resources/**"); // 完全绕过安全过滤器 + } + ``` + +------ + +### **关键区别** + +| 特性 | SecurityFilterChain | WebSecurityCustomizer | +| :--------------- | :------------------------------------ | :----------------------------------- | +| **配置对象** | `HttpSecurity`(请求级安全) | `WebSecurity`(全局Web安全) | +| **请求处理** | 经过安全过滤器链 | 完全绕过安全过滤器链 | +| **适用场景** | 细粒度权限控制、认证机制配置 | 忽略静态资源或无安全需求的路径 | +| **性能影响** | 请求会经过过滤器链(可能有开销) | 无开销,直接跳过安全处理 | +| **配置方法示例** | `.antMatchers("/api/**").permitAll()` | `.ignoring().antMatchers("/css/**")` | + +------ + +### **何时选择?** + +- **使用 `SecurityFilterChain`**: + - 需要对路径应用安全规则(如允许匿名访问但仍需CSRF保护)。 + - 需要配置登录页、OAuth2、权限验证等复杂逻辑。 +- **使用 `WebSecurityCustomizer`**: + - 静态资源(如`/css/**`, `/js/**`)完全无需安全处理。 + - 公开API(如健康检查`/actuator/health`)无需任何安全机制。 + +------ + +### **最佳实践** + +- **优先用 `SecurityFilterChain`**:除非明确需要完全绕过安全,否则用`permitAll()`替代`ignoring()`,以确保安全特性(如CSRF)仍生效。 +- **谨慎使用 `ignoring()`**:被忽略的路径可能暴露敏感信息或成为安全漏洞。 \ No newline at end of file diff --git a/oracle/oracle.md b/oracle/oracle.md index 653d12a..d7f8c62 100644 --- a/oracle/oracle.md +++ b/oracle/oracle.md @@ -1,4 +1,4 @@ -### oracle 数据库 job 操作 +## oracle 数据库 job 操作 @@ -58,3 +58,61 @@ BEGIN END; ``` + + + + +## 关闭sesseion + +``` +SELECT + s.sid, + s.serial#, + s.username, + s.osuser, + s.machine, + s.program, + s.sql_id, + l.type, + l.lmode, + l.request +FROM + v$session s + JOIN v$lock l ON s.sid = l.sid +WHERE + l.id1 = (SELECT object_id FROM dba_objects WHERE object_name = 'MKT_TEST') + AND l.type = 'TM'; -- TM 锁表示表锁 + + + +SELECT + s.sid, + s.serial#, + s.username, + s.osuser, + s.machine, + s.program, + s.sql_id, + q.sql_text +FROM + v$session s + JOIN v$sql q ON s.sql_id = q.sql_id +WHERE + s.sid =250 -- 替换为实际的 SID + AND s.serial# = 53879; -- 替换为实际的 SERIAL# + +--关闭 +ALTER SYSTEM KILL SESSION '250,53879'; +--强制关闭 +ALTER SYSTEM DISCONNECT SESSION '250,53879' IMMEDIATE; +``` + + + + + +## 数据库重启 + +sqlplus / as sysdba +SQL> shutdown immediate; +SQL> startup;