Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by HttpServlet Response res
Spring Security 정리
Spring Security의 개념부터 Form Login, JWT 기반 인증/인가, 권한 제어, Validation까지 한 번에 흐름을 잡을 수 있도록 정리합니다. 📌 목차 @AuthenticationPrincipal 1. Spring Security란? Spring Security는 Spring 서버에 필요한 인증(Authentication)과 인가(Authorization) 기능을 제공하는 보안 프레임워크입니다. 마치 Spring이 웹 서버 구현의 편의를 제공하듯, Spring Security는 보안 처리의 수고를 크게 덜어줍니다. 의존성 추가 (build.gradle) // Spring Security implementation 'org.springframework.boot:spring-boot-starter-security' Spring Security를 활성화하면 모든 요청이 Security 필터를 거치게 됩니다.
Spring Security 6.x User/Admin Filter & Interceptor 구조
전체 흐름 JWT → SecurityFilterChain → Custom Filter → Interceptor → Controller/Service user 구조 @Component public class UserInfoFilter extends OncePerRequestFilter { private final UserService userService; private final ObjectMapper objectMapper; public UserInfoFilter(UserService userService, ObjectMapper objectMapper) { this.userService = userService; this.objectMapper = objectMapper; } @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain)...
security 없이 JWT로 로그인 구현하기
security 없이 jwt만으로 구현하는 이유 배우는 입장에서 뭔가 security를 사용하지 않고 jwt로 로그인을 구현하는 것이 조금 더 도움이 될 것 같아서 spring security없이 구현하기로 했다 사용하는 라이브러리 비밀번호를 해시하기 위한 crypto, jwt관련라이브러리로는 jjwt를 사용했다. // 비밀번호 해시 implementation("org.springframework.security:spring-security-crypto") // JWT implementation("io.jsonwebtoken:jjwt-api:0.12.5") runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.5") runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.5") yml 들여쓰기때문에 고생했다.. spring과 같은 위치부터 작성하면 된다.
JWT(JSON Web Token)
JWT(JSON Web Token)是一种用于在各方之间作为 JSON 对象安全传输信息的开放标准(RFC 7519)。它是自包含的,既可以被验证,也可以被信任,因为它是通过数字签名的。JWT 在许多现代应用中用于身份验证和授权。 JWT 的结构 JWT 由三部分组成:Header(头部)、Payload(负载)、Signature(签名)。每部分使用 Base64Url 编码,并用点号(.)分隔。 Header: 包含令牌类型(JWT)和签名算法(如 HMAC SHA256 或 RSA)。 { "alg": "HS256", "typ": "JWT" } Payload: 包含声明(claims),即实体(通常是用户)及附加数据。标准声明包括 iss(签发者)、exp(过期时间)、sub(主题)等。 { "sub": "1234567890", "name": "John Doe", "iat": 1516239022 } Signature: 用于验证令牌的发送方及数据完整性。将编码后的 Header 和 Payload 通过指定算法进行签名。 HMACSHA256(...
http的basic 认证方式_basic auth-CSDN博客
写在前面 本文看下http的basic auth认证方式。 1:什么是basic auth认证 basic auth是一种http协议规范中的一种认证方式,即一种证明你就是你的方式。更进一步的它是一种规范,这种规范是这样子,如果是服务端使用了basic auth认证方式来处理用户请求的话,会从header中获取Authorization的头信息,如果是没有该头信息或者是头信息不正确,则会返回401状态码,并添加WWW-Authenticate响应头。如下代码所示: String base6AuthStr = req.getHeader("Authorization"); System.out.println("base6AuthStr=" + base6AuthStr); // base6AuthStr=Basic YWFhOmFhYQ== if (base6AuthStr == null) { res.setStatus(401); res.addHeader("WWW-Authenticate", "basic realm=\"no auth\""); return...
HTTP的认证方式之DIGEST 认证(摘要认证)
核心步骤: 步骤 1: 请求需认证的资源时,服务器会随着状态码 401Authorization Required,返回带WWW-Authenticate 首部字段的响应。该字段内包含质问响应方式认证所需的临时质询码(随机数,nonce)。首部字段 WWW-Authenticate 内必须包含realm 和nonce 这两个字段的信息。客户端就是依靠向服务器回送这两个值进行认证的。nonce 是一种每次随返回的 401 响应生成的任意随机字符串。该字符串通常推荐由Base64 编码的十六进制数的组成形式,但实际内容依赖服务器的具体实现。 步骤 2:接收到401状态码的客户端,返回的响应中包含 DIGEST 认证必须的首部字段 Authorization 信息。首部字段 Authorization 内必须包含 username、realm、nonce、uri 和response的字段信息。其中,realm 和 nonce 就是之前从服务器接收到的响应中的字段。 username是realm 限定范围内可进行认证的用户名。...
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with HttpServlet
Contact HttpServlet, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack