From 2ff72fdcc58f8232a32c70807464937345874e63 Mon Sep 17 00:00:00 2001 From: YiRanCN <cniiot@163.com> Date: Thu, 29 Feb 2024 18:41:35 +0800 Subject: [PATCH] 2 --- docs/study/back/spring/@Resource@Autowired.md | 11 +++++++++++ docs/study/back/spring/SpringFramework.md | 2 ++ docs/study/back/spring/SpringSecurity.md | 11 +++++++++++ .../Oauth2.md" | 18 ++++++++++++++++++ .../\350\256\244\350\257\201.md" | 14 ++++++++++++++ ...217\346\264\236\346\224\273\345\207\273.md" | 7 +++++++ docs/study/encryption/index.md | 4 ++++ 7 files changed, 67 insertions(+) create mode 100644 docs/study/back/spring/@Resource@Autowired.md create mode 100644 docs/study/back/spring/SpringSecurity.md create mode 100644 "docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/Oauth2.md" create mode 100644 "docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\350\256\244\350\257\201.md" create mode 100644 "docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\351\230\262\350\214\203\346\274\217\346\264\236\346\224\273\345\207\273.md" diff --git a/docs/study/back/spring/@Resource@Autowired.md b/docs/study/back/spring/@Resource@Autowired.md new file mode 100644 index 000000000..fd46aed17 --- /dev/null +++ b/docs/study/back/spring/@Resource@Autowired.md @@ -0,0 +1,11 @@ +@Autowired 和 @Resource 都是用来实现依赖注入的注解(在 Spring/Spring Boot 项目中),但二者却有着 5 点不同: + +- 来源不同:@Autowired 来自 Spring 框架,而 @Resource 来自于(Java)JSR-250; +- 依赖查找的顺序不同:@Autowired 先根据类型再根据名称查询,而 @Resource 先根据名称再根据类型查询; +- 支持的参数不同:@Autowired 只支持设置 1 个参数,而 @Resource 支持设置 7 个参数; +- 依赖注入的用法支持不同:@Autowired 既支持构造方法注入,又支持属性注入和 Setter 注入,而 @Resource 只支持属性注入和 Setter 注入; +- 编译器 IDEA 的提示不同:当注入 Mapper 对象时,使用 @Autowired 注解编译器会提示错误,而使用 @Resource 注解则不会提示错误。 + +### 参考 + +- [CSDN-@Autowired 和@Resource 到底有什么区别](https://blog.csdn.net/xhbzl/article/details/126765893) diff --git a/docs/study/back/spring/SpringFramework.md b/docs/study/back/spring/SpringFramework.md index 6f894a04c..e8349f71c 100644 --- a/docs/study/back/spring/SpringFramework.md +++ b/docs/study/back/spring/SpringFramework.md @@ -1,5 +1,7 @@ # Spirng Framework +[官方参考文档](https://docs.spring.io/spring-framework/reference/overview.html) + ### 特性 - Core technologies: dependency injection, events, resources, i18n, validation, data binding, type conversion, SpEL, AOP. diff --git a/docs/study/back/spring/SpringSecurity.md b/docs/study/back/spring/SpringSecurity.md new file mode 100644 index 000000000..cd53f7a5e --- /dev/null +++ b/docs/study/back/spring/SpringSecurity.md @@ -0,0 +1,11 @@ +# Spring Security + +认证、授权、防止攻击 + +[官方参考文档](https://docs.spring.io/spring-security/reference/index.html) + +这样的安全框架还有, + +[Apache Shiro](https://shiro.apache.org/) + +[Sa-Token](https://sa-token.cc/) diff --git "a/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/Oauth2.md" "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/Oauth2.md" new file mode 100644 index 000000000..50a03ab8e --- /dev/null +++ "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/Oauth2.md" @@ -0,0 +1,18 @@ +# Oauth2 + +Oauth2 是目前最流行的授权机制,用来授权第三方应用,获取用户数据。 + +Oauth2 有四种角色,一个是客户端,一个是资源所有者,一个是授权服务器,还有一个是资源服务器。 + +### Oauth2 四种认证方式 + +- 授权码模式(authorization code):要授权,同意,给授权码,拿授权码要令牌 +- 简化模式(隐藏模式)(implicit):要授权,同意,直接拿令牌,**_一般是第三方应用只有前端_** +- 密码模式(resource owner password credentials),要授权,直接给用户名和密码,**_及其信任,很少用到_** +- 客户端模式(client credentials),要授权,直接给令牌;**_一般是第三方应用的后端,同时支持很多自己的用户_** + +不管是哪一种授权方式,第三方应用申请令牌之前,都必须先到系统备案,说明自己的身份,然后拿到两个身份的识别码,客户端和客户端密钥,这是防止密钥被滥用,没有备案过的第三方的应用,是不会拿到令牌的 + +### 参考文档 + +- [CSDN-前言技术之 Oauth2 全方面介绍](https://blog.csdn.net/m0_53151031/article/details/123737336) diff --git "a/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\350\256\244\350\257\201.md" "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\350\256\244\350\257\201.md" new file mode 100644 index 000000000..80ee8972e --- /dev/null +++ "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\350\256\244\350\257\201.md" @@ -0,0 +1,14 @@ +# 认证 + +参考 [Spring Security 认证](https://springdoc.cn/spring-security/servlet/authentication/index.html#servlet-authentication-mechanisms) + +### 认证机制 + +- Username 和 Password - 如何用用户名/密码进行认证 +- OAuth 2.0 Login - 使用 OpenID Connect 和非标准的 OAuth 2.0 登录(即 GitHub)的 OAuth 2.0 登录。 +- SAML 2.0 Login - SAML 2.0 登录 +- Central Authentication Server (CAS) - 中央认证服务器(CAS)支持。 +- Remember Me - 如何记住一个过了 session 有效期的用户。 +- JAAS Authentication - 用 JAAS 进行认证 +- Pre-Authentication Scenarios - 使用外部机制(如 SiteMinder 或 Java EE security)进行认证,但仍使用 Spring Security 进行授权并保护其免受常见漏洞的侵害。 +- X509 Authentication - X509 认证 diff --git "a/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\351\230\262\350\214\203\346\274\217\346\264\236\346\224\273\345\207\273.md" "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\351\230\262\350\214\203\346\274\217\346\264\236\346\224\273\345\207\273.md" new file mode 100644 index 000000000..2988385b3 --- /dev/null +++ "b/docs/study/back/\344\277\241\346\201\257\345\256\211\345\205\250/\351\230\262\350\214\203\346\274\217\346\264\236\346\224\273\345\207\273.md" @@ -0,0 +1,7 @@ +参考 [Spring Security 防范漏洞攻击](https://springdoc.cn/spring-security/features/exploits/index.html) + +包括: + +- CSRF 跨站请求伪造 +- HTTP Header : Spring Security 提供了一套默认的安全相关的 HTTP 响应头,以提供安全的默认值。 +- HTTP : 所有基于 HTTP 的通信,包括 静态资源,都应该通过使用 TLS 进行保护。作为一个框架,Spring Security 并不处理 HTTP 连接,因此并不直接提供对 HTTPS 的支持。然而,它确实提供了一些有助于 HTTPS 使用的功能。 diff --git a/docs/study/encryption/index.md b/docs/study/encryption/index.md index fe612b311..a0a6e9d40 100644 --- a/docs/study/encryption/index.md +++ b/docs/study/encryption/index.md @@ -33,3 +33,7 @@ 最有名的非对称加密算法当属 RSA 了,本文将对 RSA 算法的加/解密过程进行详细剖析。 非对称加密拥有两把密钥。 + +### 参考 + +- [WIKI-彩虹表](https://zh.wikipedia.org/wiki/%E5%BD%A9%E8%99%B9%E8%A1%A8)