Config login. security
parent
755fae4122
commit
39119b167d
6
pom.xml
6
pom.xml
|
@ -103,7 +103,11 @@
|
|||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<!--HikariCP-->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sitemesh</groupId>
|
||||
|
|
|
@ -21,13 +21,13 @@ public class OauthServiceImpl implements OauthService {
|
|||
private OauthRepository oauthRepository;
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public OauthClientDetails loadOauthClientDetails(String clientId) {
|
||||
return oauthRepository.findOauthClientDetails(clientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public List<OauthClientDetailsDto> loadAllOauthClientDetailsDtos() {
|
||||
List<OauthClientDetails> clientDetailses = oauthRepository.findAllOauthClientDetails();
|
||||
return OauthClientDetailsDto.toDtos(clientDetailses);
|
||||
|
@ -40,7 +40,7 @@ public class OauthServiceImpl implements OauthService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public OauthClientDetailsDto loadOauthClientDetailsDto(String clientId) {
|
||||
final OauthClientDetails oauthClientDetails = oauthRepository.findOauthClientDetails(clientId);
|
||||
return oauthClientDetails != null ? new OauthClientDetailsDto(oauthClientDetails) : null;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public UserJsonDto loadCurrentUserJsonDto() {
|
||||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
final Object principal = authentication.getPrincipal();
|
||||
|
@ -58,7 +58,7 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public UserOverviewDto loadUserOverviewDto(UserOverviewDto overviewDto) {
|
||||
List<User> users = userRepository.findUsersByUsername(overviewDto.getUsername());
|
||||
overviewDto.setUserDtos(UserDto.toDtos(users));
|
||||
|
@ -66,7 +66,7 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
|
||||
@Transactional(readOnly = true)
|
||||
public boolean isExistedUsername(String username) {
|
||||
final User user = userRepository.findByUsername(username);
|
||||
return user != null;
|
||||
|
|
|
@ -6,8 +6,12 @@ spring.application.name=spring-oauth-server
|
|||
#####################
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/oauth2_boot?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8
|
||||
spring.datasource.data-username=andaily
|
||||
spring.datasource.data-password=andaily
|
||||
spring.datasource.username=andaily
|
||||
spring.datasource.password=andaily
|
||||
#Datasource properties
|
||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||
spring.datasource.hikari.maximum-pool-size=20
|
||||
spring.datasource.hikari.minimum-idle=2
|
||||
#
|
||||
# MVC
|
||||
spring.mvc.ignore-default-model-on-redirect=false
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>注册client</title>
|
||||
<script src="${contextPath}/resources/angular.min.js"></script>
|
||||
<script src="${contextPath}/static/angular.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -28,7 +28,7 @@
|
|||
</p>
|
||||
|
||||
<div ng-controller="RegisterClientCtrl">
|
||||
<form:form commandName="formDto" cssClass="form-horizontal">
|
||||
<form:form modelAttribute="formDto" cssClass="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label for="clientId" class="col-sm-2 control-label">client_id<em class="text-danger">*</em></label>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<head>
|
||||
<title>Test [${clientDetailsDto.clientId}]</title>
|
||||
|
||||
<script src="${contextPath}/resources/angular.min.js"></script>
|
||||
<script src="${contextPath}/static/angular.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib tagdir="/WEB-INF/tags" prefix="custom" %>
|
||||
<!DOCTYPE HTML>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<h2>Spring Security&OAuth2 is work!</h2>
|
||||
|
||||
<p>
|
||||
<a href="${contextPath}/login.jsp">Login</a>
|
||||
<a href="${contextPath}/login">Login</a>
|
||||
|
|
||||
<a href="${contextPath}/logout.do">Logout</a>
|
||||
<a href="${contextPath}/signout">Logout</a>
|
||||
</p>
|
||||
|
||||
<div>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<label for="username" class="col-sm-3 control-label">Username</label>
|
||||
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="username" name="username" value="" placeholder="Type username"
|
||||
<input type="text" id="username" name="oidc_user" value="" placeholder="Type username"
|
||||
required="required" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<label for="password" class="col-sm-3 control-label">Password</label>
|
||||
|
||||
<div class="col-sm-9">
|
||||
<input type="password" name="password" id="password" value="" placeholder="Type password"
|
||||
<input type="password" name="oidcPwd" id="password" value="" placeholder="Type password"
|
||||
required="required" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
Principal: <strong>${SPRING_SECURITY_CONTEXT.authentication.principal}</strong>
|
||||
<br/>
|
||||
<a href="${contextPath}/logout.do">Logout</a>
|
||||
<a href="${contextPath}/signout">Logout</a>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<h2>Add User</h2>
|
||||
|
||||
<form:form commandName="formDto" cssClass="form-horizontal">
|
||||
<form:form modelAttribute="formDto" cssClass="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">Username<em class="text-danger">*</em></label>
|
||||
|
||||
|
|
Loading…
Reference in New Issue