jpablog : security login, jsp taglib
This commit is contained in:
@@ -21,10 +21,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@@ -51,18 +51,18 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<!-- 시큐리티 태그 라이브러리 -->
|
<!-- 시큐리티 태그 라이브러리 -->
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-taglibs</artifactId>
|
<artifactId>spring-security-taglibs</artifactId>
|
||||||
<version>5.4.2</version>
|
<version>5.4.2</version>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<!-- JSP 템플릿 엔진 -->
|
<!-- JSP 템플릿 엔진 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import javax.servlet.http.HttpSession;
|
|||||||
public class UserApiController {
|
public class UserApiController {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final HttpSession session;
|
|
||||||
|
|
||||||
@PostMapping("/user")
|
@PostMapping("/user")
|
||||||
public ResponseDto<Integer> save(@RequestBody User user) {
|
public ResponseDto<Integer> save(@RequestBody User user) {
|
||||||
@@ -28,12 +27,13 @@ public class UserApiController {
|
|||||||
return new ResponseDto<>(result, HttpStatus.OK.value());
|
return new ResponseDto<>(result, HttpStatus.OK.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*// 기본 로그인
|
||||||
@PostMapping("/user/login")
|
@PostMapping("/user/login")
|
||||||
public ResponseDto<Integer> login(@RequestBody User user) {
|
public ResponseDto<Integer> login(@RequestBody User user, HttpSession session) {
|
||||||
User principal = userService.로그인(user);
|
User principal = userService.로그인(user);
|
||||||
if (principal != null) {
|
if (principal != null) {
|
||||||
session.setAttribute("principal", principal);
|
session.setAttribute("principal", principal);
|
||||||
}
|
}
|
||||||
return new ResponseDto<>(1, HttpStatus.OK.value());
|
return new ResponseDto<>(1, HttpStatus.OK.value());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||||
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||||
|
<sec:authorize access="isAuthenticated()">
|
||||||
|
<sec:authentication property="principal" var="principal"/>
|
||||||
|
</sec:authorize>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@@ -13,7 +16,6 @@
|
|||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
|
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
|
||||||
<a class="navbar-brand" href="/">블로그</a>
|
<a class="navbar-brand" href="/">블로그</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
|
||||||
@@ -21,7 +23,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="collapsibleNavbar">
|
<div class="collapse navbar-collapse" id="collapsibleNavbar">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${empty sessionScope.principal}">
|
<c:when test="${empty principal}">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/loginForm">로그인</a>
|
<a class="nav-link" href="/loginForm">로그인</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user