commit
5a11b9d391
22
build.gradle
22
build.gradle
@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
springBootVersion = '1.5.6.RELEASE'
|
springBootVersion = '2.0.2.RELEASE'
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -14,6 +14,14 @@ apply plugin: 'java'
|
|||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'org.springframework.boot'
|
apply plugin: 'org.springframework.boot'
|
||||||
|
apply plugin: 'io.spring.dependency-management'
|
||||||
|
|
||||||
|
dependencyManagement {
|
||||||
|
imports {
|
||||||
|
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
|
||||||
|
}
|
||||||
|
applyMavenExclusions = false
|
||||||
|
}
|
||||||
|
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
@ -33,17 +41,17 @@ dependencies {
|
|||||||
compile('org.springframework.boot:spring-boot-starter-data-jpa')
|
compile('org.springframework.boot:spring-boot-starter-data-jpa')
|
||||||
compile('org.flywaydb:flyway-core')
|
compile('org.flywaydb:flyway-core')
|
||||||
compile('org.springframework.boot:spring-boot-starter-hateoas')
|
compile('org.springframework.boot:spring-boot-starter-hateoas')
|
||||||
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.0')
|
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
|
||||||
compile('org.springframework.boot:spring-boot-starter-web')
|
compile('org.springframework.boot:spring-boot-starter-web')
|
||||||
compile('io.jsonwebtoken:jjwt:0.7.0')
|
compile('io.jsonwebtoken:jjwt:0.9.0')
|
||||||
compile('org.springframework.boot:spring-boot-starter-security')
|
compile('org.springframework.boot:spring-boot-starter-security')
|
||||||
compile('joda-time:joda-time:2.9.9')
|
compile('joda-time:joda-time:2.9.9')
|
||||||
compileOnly('org.projectlombok:lombok')
|
compileOnly('org.projectlombok:lombok')
|
||||||
runtime('com.h2database:h2')
|
runtime('com.h2database:h2')
|
||||||
testCompile 'io.rest-assured:rest-assured:3.0.2'
|
testCompile 'io.rest-assured:rest-assured:3.1.0'
|
||||||
testCompile 'io.rest-assured:spring-mock-mvc:3.0.2'
|
testCompile 'io.rest-assured:spring-mock-mvc:3.1.0'
|
||||||
testCompile 'org.springframework.security:spring-security-test:4.0.4.RELEASE'
|
testCompile 'org.springframework.security:spring-security-test'
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||||
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
|
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
|
||||||
testCompile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.0')
|
testCompile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.2')
|
||||||
}
|
}
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,5 @@
|
|||||||
#Mon Aug 07 11:04:20 CST 2017
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
|
|
||||||
|
@ -9,7 +9,7 @@ import io.spring.core.article.ArticleRepository;
|
|||||||
import io.spring.core.user.User;
|
import io.spring.core.user.User;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
@ -14,7 +14,7 @@ import io.spring.core.comment.CommentRepository;
|
|||||||
import io.spring.core.user.User;
|
import io.spring.core.user.User;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
@ -9,7 +9,7 @@ import io.spring.core.user.User;
|
|||||||
import io.spring.core.user.UserRepository;
|
import io.spring.core.user.UserRepository;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.hibernate.validator.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
@ -11,8 +11,8 @@ import io.spring.core.user.User;
|
|||||||
import io.spring.core.user.UserRepository;
|
import io.spring.core.user.UserRepository;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.hibernate.validator.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -2,10 +2,10 @@ package io.spring.api.security;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class CORSConfig extends WebMvcConfigurerAdapter {
|
public class CORSConfig implements WebMvcConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**")
|
registry.addMapping("/**")
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package io.spring.api.security;
|
package io.spring.api.security;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
|
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
@ -40,7 +41,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
http.csrf().disable()
|
http.csrf().disable()
|
||||||
.cors()
|
.cors()
|
||||||
.and()
|
.and()
|
||||||
.exceptionHandling().authenticationEntryPoint(new Http401AuthenticationEntryPoint("Unauthenticated"))
|
.exceptionHandling().authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
|
||||||
.and()
|
.and()
|
||||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
|
@ -27,9 +27,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@WebMvcTest(CommentsApi.class)
|
@WebMvcTest(CommentsApi.class)
|
||||||
|
@ -19,8 +19,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@WebMvcTest(CurrentUserApi.class)
|
@WebMvcTest(CurrentUserApi.class)
|
||||||
|
@ -18,7 +18,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static io.spring.TestHelper.articleDataFixture;
|
import static io.spring.TestHelper.articleDataFixture;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@WebMvcTest(ArticlesApi.class)
|
@WebMvcTest(ArticlesApi.class)
|
||||||
|
@ -19,7 +19,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
|
@ -26,8 +26,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given;
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user