├── web-security
├── settings.gradle
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── static
│ │ │ │ ├── test.txt
│ │ │ │ └── images
│ │ │ │ │ └── web-security-ignoring-test-file.png
│ │ │ ├── application-test.yml
│ │ │ ├── application-debug.yml
│ │ │ ├── application-postgres.yml
│ │ │ ├── application.yml
│ │ │ ├── db
│ │ │ │ ├── data.sql
│ │ │ │ ├── README.md
│ │ │ │ └── schema.sql
│ │ │ └── templates
│ │ │ │ └── index.html
│ │ ├── vue
│ │ │ ├── common
│ │ │ │ ├── css
│ │ │ │ │ ├── footer.scss
│ │ │ │ │ └── common.scss
│ │ │ │ ├── common.js
│ │ │ │ ├── blank.vue
│ │ │ │ └── mixins
│ │ │ │ │ └── common-mixin.js
│ │ │ ├── page
│ │ │ │ ├── main.vue
│ │ │ │ ├── login.vue
│ │ │ │ └── index.vue
│ │ │ ├── store
│ │ │ │ └── store.js
│ │ │ ├── index.js
│ │ │ ├── App.vue
│ │ │ ├── README.md
│ │ │ └── route
│ │ │ │ └── route.js
│ │ └── java
│ │ │ └── kr
│ │ │ └── kdev
│ │ │ └── demo
│ │ │ ├── repository
│ │ │ └── AbstractRepository.java
│ │ │ ├── service
│ │ │ ├── AbstractService.java
│ │ │ ├── RepositoryService.java
│ │ │ ├── UserService.java
│ │ │ └── AuthenticationService.java
│ │ │ ├── bean
│ │ │ ├── CurrentUser.java
│ │ │ ├── UserState.java
│ │ │ ├── Repository.java
│ │ │ └── User.java
│ │ │ ├── WebSecurityApplication.java
│ │ │ ├── config
│ │ │ ├── WebConfig.java
│ │ │ └── SecurityConfig.java
│ │ │ ├── api
│ │ │ ├── UserApi.java
│ │ │ ├── LoginApi.java
│ │ │ ├── BaseApi.java
│ │ │ └── RepositoryApi.java
│ │ │ ├── expression
│ │ │ └── RepositoryChecker.java
│ │ │ ├── controller
│ │ │ └── IndexController.java
│ │ │ └── interceptor
│ │ │ └── UserStateInjectionInterceptor.java
│ └── test
│ │ └── java
│ │ └── kr
│ │ └── kdev
│ │ └── demo
│ │ ├── WebSecurityApplicationTests.java
│ │ ├── context
│ │ └── WithMockAdmin.java
│ │ ├── config
│ │ ├── ServiceTestConfigurer.java
│ │ ├── ServiceTest.java
│ │ └── ApiTestConfigurer.java
│ │ ├── api
│ │ ├── LoginApiTests.java
│ │ └── UserApiTests.java
│ │ ├── util
│ │ └── RequestMatcherTests.java
│ │ └── service
│ │ ├── RepositoryServiceTests.java
│ │ └── UserServiceTests.java
├── .eslintrc.js
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── postcss.config.js
├── .babelrc.js
├── .gitignore
├── build.gradle
├── package.json
├── gradlew.bat
├── webpack.config.js
├── gradlew
└── README.md
├── web-security-session
├── settings.gradle
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application-embedded-redis.yml
│ │ │ ├── static
│ │ │ │ └── images
│ │ │ │ │ └── max-sessions-prevents-login.PNG
│ │ │ ├── application-debug.yml
│ │ │ ├── templates
│ │ │ │ └── index.html
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── kr
│ │ │ └── kdev
│ │ │ └── demo
│ │ │ ├── controller
│ │ │ └── IndexController.java
│ │ │ ├── WebSecurityApplication.java
│ │ │ ├── api
│ │ │ ├── UserApi.java
│ │ │ └── BaseApi.java
│ │ │ └── config
│ │ │ ├── SessionConfig.java
│ │ │ └── SecurityConfig.java
│ └── test
│ │ └── java
│ │ └── kr
│ │ └── kdev
│ │ └── demo
│ │ └── WebSecurityApplicationTests.java
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradlew.bat
├── README.md
└── gradlew
├── web-security-oauth-server
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── static
│ │ │ │ └── images
│ │ │ │ │ ├── token-endpoint-jwt.PNG
│ │ │ │ │ ├── oauth-approval-scopes.PNG
│ │ │ │ │ ├── token-endpoint-request-post.PNG
│ │ │ │ │ └── token-endpoint-not-allowed-get.PNG
│ │ │ ├── application-debug.yml
│ │ │ ├── application.yml
│ │ │ ├── db
│ │ │ │ ├── user.json
│ │ │ │ └── client.json
│ │ │ ├── messages
│ │ │ │ └── messages_ko_KR.yml
│ │ │ └── templates
│ │ │ │ └── index.ftl
│ │ └── java
│ │ │ └── kr
│ │ │ └── kdev
│ │ │ └── demo
│ │ │ ├── service
│ │ │ ├── AbstractService.java
│ │ │ ├── AuthenticationService.java
│ │ │ ├── UserService.java
│ │ │ └── ClientService.java
│ │ │ ├── controller
│ │ │ └── IndexController.java
│ │ │ ├── WebSecurityApplication.java
│ │ │ ├── config
│ │ │ ├── SessionConfig.java
│ │ │ └── WebConfig.java
│ │ │ ├── bean
│ │ │ ├── CurrentUser.java
│ │ │ ├── User.java
│ │ │ └── Client.java
│ │ │ ├── endpoint
│ │ │ └── JwkSetEndpoint.java
│ │ │ ├── interceptor
│ │ │ └── PrincipalInjectionInterceptor.java
│ │ │ └── api
│ │ │ ├── BaseApi.java
│ │ │ └── UserApi.java
│ └── test
│ │ └── java
│ │ └── kr
│ │ └── kdev
│ │ └── demo
│ │ └── WebSecurityApplicationTests.java
├── .gitignore
├── build.gradle
├── gradlew.bat
└── gradlew
├── web-security-oauth-kakao-login
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── static
│ │ │ │ └── images
│ │ │ │ │ ├── kakao-app.PNG
│ │ │ │ │ ├── oauth-login-form.PNG
│ │ │ │ │ ├── kakao-app-information.PNG
│ │ │ │ │ ├── kakao-app-redirect-uri.PNG
│ │ │ │ │ ├── kakao-app-client-secret.PNG
│ │ │ │ │ ├── kakao-app-settings-user.PNG
│ │ │ │ │ ├── kakao-app-setting-platform.PNG
│ │ │ │ │ ├── oauth-login-authentication-debug.PNG
│ │ │ │ │ └── kakao-app-settings-user-redirect-uri.PNG
│ │ │ ├── application-debug.yml
│ │ │ ├── templates
│ │ │ │ └── index.html
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── kr
│ │ │ └── kdev
│ │ │ └── demo
│ │ │ ├── WebSecurityApplication.java
│ │ │ ├── controller
│ │ │ └── IndexController.java
│ │ │ ├── bean
│ │ │ └── KakaoOAuth2User.java
│ │ │ ├── api
│ │ │ ├── BaseApi.java
│ │ │ └── UserApi.java
│ │ │ └── config
│ │ │ └── SecurityConfig.java
│ └── test
│ │ └── java
│ │ └── kr
│ │ └── kdev
│ │ └── demo
│ │ └── WebSecurityApplicationTests.java
├── .gitignore
├── build.gradle
├── gradlew.bat
├── gradlew
└── README.md
├── .gitignore
└── README.md
/web-security/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'demo'
2 |
--------------------------------------------------------------------------------
/web-security-session/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'demo'
2 |
--------------------------------------------------------------------------------
/web-security-oauth-server/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'demo'
2 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'demo'
2 |
--------------------------------------------------------------------------------
/web-security/src/main/resources/static/test.txt:
--------------------------------------------------------------------------------
1 | You can download test.txt because web security ignore static locations.
--------------------------------------------------------------------------------
/web-security/src/main/resources/application-test.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org.springframework.test.context: ERROR
--------------------------------------------------------------------------------
/web-security-session/src/main/resources/application-embedded-redis.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | redis:
3 | host: localhost
4 | port: 6380
--------------------------------------------------------------------------------
/web-security/.eslintrc.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | extends: ['plugin:vue/recommended'],
4 | rules: {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/web-security/src/main/vue/common/css/footer.scss:
--------------------------------------------------------------------------------
1 | #sticky-footer {
2 | position: fixed;
3 | bottom: 0;
4 | width: 100%;
5 | }
--------------------------------------------------------------------------------
/web-security/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/web-security-session/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-session/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/repository/AbstractRepository.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.repository;
2 |
3 | public abstract class AbstractRepository {
4 | }
5 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/page/main.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/web-security-oauth-server/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-server/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app.PNG
--------------------------------------------------------------------------------
/web-security/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('postcss-cssnext'),
4 | require('precss'),
5 | require('autoprefixer'),
6 | require('cssnano')
7 | ]
8 | }
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/static/images/token-endpoint-jwt.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-server/src/main/resources/static/images/token-endpoint-jwt.PNG
--------------------------------------------------------------------------------
/web-security/src/main/resources/static/images/web-security-ignoring-test-file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security/src/main/resources/static/images/web-security-ignoring-test-file.png
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/oauth-login-form.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/oauth-login-form.PNG
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/static/images/oauth-approval-scopes.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-server/src/main/resources/static/images/oauth-approval-scopes.PNG
--------------------------------------------------------------------------------
/web-security-session/src/main/resources/static/images/max-sessions-prevents-login.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-session/src/main/resources/static/images/max-sessions-prevents-login.PNG
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-information.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-information.PNG
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-redirect-uri.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-redirect-uri.PNG
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/static/images/token-endpoint-request-post.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-server/src/main/resources/static/images/token-endpoint-request-post.PNG
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-client-secret.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-client-secret.PNG
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-settings-user.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-settings-user.PNG
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-setting-platform.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-setting-platform.PNG
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/static/images/token-endpoint-not-allowed-get.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-server/src/main/resources/static/images/token-endpoint-not-allowed-get.PNG
--------------------------------------------------------------------------------
/web-security/src/main/resources/application-debug.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org:
4 | springframework:
5 | web:
6 | servlet:
7 | mvc: INFO
8 |
9 | spring:
10 | http:
11 | log-request-details: true
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/oauth-login-authentication-debug.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/oauth-login-authentication-debug.PNG
--------------------------------------------------------------------------------
/web-security-session/src/main/resources/application-debug.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org:
4 | springframework:
5 | web:
6 | servlet:
7 | mvc: INFO
8 |
9 | spring:
10 | http:
11 | log-request-details: true
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/application-debug.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org:
4 | springframework:
5 | web:
6 | servlet:
7 | mvc: INFO
8 |
9 | spring:
10 | http:
11 | log-request-details: true
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/application-debug.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | org:
4 | springframework:
5 | web:
6 | servlet:
7 | mvc: INFO
8 |
9 | spring:
10 | http:
11 | log-request-details: true
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-settings-user-redirect-uri.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kdevkr/spring-demo-security/HEAD/web-security-oauth-kakao-login/src/main/resources/static/images/kakao-app-settings-user-redirect-uri.PNG
--------------------------------------------------------------------------------
/web-security/.babelrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: ['syntax-dynamic-import'],
3 | presets: [
4 | [
5 | '@babel/preset-env',
6 | {
7 | modules: false
8 | }
9 | ]
10 | ],
11 | }
--------------------------------------------------------------------------------
/web-security/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/web-security-session/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/store/store.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex from 'vuex'
3 |
4 | Vue.use(Vuex)
5 |
6 | export default new Vuex.Store({
7 | state: {
8 |
9 | },
10 | mutations: {
11 |
12 | },
13 | actions: {
14 |
15 | }
16 | })
--------------------------------------------------------------------------------
/web-security-oauth-server/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/service/AbstractService.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.service;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | public abstract class AbstractService {
7 | protected Logger LOG = LoggerFactory.getLogger(getClass());
8 | }
9 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/service/AbstractService.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.service;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | public abstract class AbstractService {
7 | protected Logger LOG = LoggerFactory.getLogger(getClass());
8 | }
9 |
--------------------------------------------------------------------------------
/web-security/src/main/resources/application-postgres.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | driver-class-name: org.postgresql.Driver
4 | hikari:
5 | username: kdevkr
6 | password: password
7 | maximum-pool-size: 100
8 | minimum-idle: 50
9 | url: 'jdbc:postgresql://localhost:5432/demo'
--------------------------------------------------------------------------------
/web-security/src/main/vue/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 | import '~/vue/common/common'
4 |
5 | import store from '~/vue/store/store'
6 | import router from '~/vue/route/route'
7 |
8 | new Vue({
9 | router,
10 | store,
11 | el: '#app',
12 | render: h => h(App)
13 | })
--------------------------------------------------------------------------------
/web-security/src/test/java/kr/kdev/demo/WebSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class WebSecurityApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/web-security-session/src/test/java/kr/kdev/demo/WebSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class WebSecurityApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/test/java/kr/kdev/demo/WebSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class WebSecurityApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/test/java/kr/kdev/demo/WebSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class WebSecurityApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/common/common.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import BootstrapVue from 'bootstrap-vue'
3 | import Vuelidate from 'vuelidate'
4 | import axios from 'axios'
5 | import '~/vue/common/css/common.scss'
6 |
7 | Vue.use(BootstrapVue)
8 | Vue.use(Vuelidate)
9 |
10 | axios.defaults.withCredentials = true
11 | Vue.prototype.$http = axios
12 | window.$http = axios
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | bin/
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | nbproject/private/
22 | build/
23 | nbbuild/
24 | dist/
25 | nbdist/
26 | .nb-gradle/
--------------------------------------------------------------------------------
/web-security/src/main/vue/common/css/common.scss:
--------------------------------------------------------------------------------
1 | @import '~bootstrap';
2 | @import '~bootstrap-vue';
3 | @import 'footer.scss';
4 |
5 | .form-group {
6 | &.text-value {
7 | .form-row {
8 | .col {
9 | padding-top: calc(.375rem + 1px);
10 | padding-bottom: calc(.375rem + 1px);
11 | }
12 | }
13 | }
14 | }
15 |
16 | .login-form {
17 | max-width: 350px;
18 | }
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/bean/CurrentUser.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.bean;
2 |
3 | import org.springframework.security.core.annotation.AuthenticationPrincipal;
4 |
5 | import java.lang.annotation.*;
6 |
7 | @Target({ ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Documented
10 | @AuthenticationPrincipal
11 | public @interface CurrentUser {
12 | }
--------------------------------------------------------------------------------
/web-security/src/test/java/kr/kdev/demo/context/WithMockAdmin.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.context;
2 |
3 | import org.springframework.security.test.context.support.WithMockUser;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @WithMockUser(value = "admin", roles = "ADMIN")
10 | public @interface WithMockAdmin {
11 | }
12 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | freemarker:
3 | suffix: .ftl
4 |
5 | resources:
6 | static-locations: 'classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/, classpath:/META-INF/resources/webjars'
7 |
8 | server:
9 | forward-headers-strategy: NATIVE
10 |
11 | logging:
12 | level:
13 | kr:
14 | kdev:
15 | demo: DEBUG
--------------------------------------------------------------------------------
/web-security/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | freemarker:
3 | suffix: .html
4 |
5 | resources:
6 | static-locations: 'classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/, classpath:/dist/, classpath:/META-INF/resources/webjars'
7 | datasource:
8 | driver-class-name: org.h2.Driver
9 |
10 | logging:
11 | level:
12 | kr:
13 | kdev:
14 | demo: DEBUG
15 |
--------------------------------------------------------------------------------
/web-security-session/src/main/java/kr/kdev/demo/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.Model;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 |
7 |
8 | @Controller
9 | public class IndexController {
10 |
11 | @GetMapping("/")
12 | public String index(Model model) {
13 | return "index";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.ui.Model;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 |
7 |
8 | @Controller
9 | public class IndexController {
10 |
11 | @GetMapping("/")
12 | public String index(Model model) {
13 | return "index";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/web-security-session/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Spring Demo Security
8 |
9 |
10 |
11 |
Hello World
12 |
13 |
14 |
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/bean/UserState.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.bean;
2 |
3 | import lombok.Data;
4 |
5 | import java.util.Locale;
6 | import java.util.TimeZone;
7 |
8 | @Data
9 | public class UserState {
10 | private String userId = "";
11 | private String name = "";
12 | private String role = "";
13 | private TimeZone timeZone = TimeZone.getDefault();
14 | private Locale locale = Locale.getDefault();
15 | private String sessionId = "";
16 | }
17 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/common/blank.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
19 |
--------------------------------------------------------------------------------
/web-security/src/main/resources/db/data.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO users (id, password, name, role) VALUES ('admin', '{bcrypt}$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG', 'admin', 'ADMIN');
2 | INSERT INTO users (id, password, name, role) VALUES ('user', '{bcrypt}$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG', 'user', 'USER');
3 |
4 | INSERT INTO users_authority (user_id, authority)
5 | SELECT user_id, 'REPOSITORY_CREATE' FROM users where id = 'user' ON CONFLICT (user_id, authority) DO NOTHING;
--------------------------------------------------------------------------------
/web-security-session/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | freemarker:
3 | suffix: .html
4 |
5 | resources:
6 | static-locations: 'classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/, classpath:/META-INF/resources/webjars'
7 | session:
8 | store-type: redis
9 |
10 |
11 | logging:
12 | level:
13 | kr:
14 | kdev:
15 | demo: DEBUG
16 | server:
17 | servlet:
18 | session:
19 | timeout: 60m
20 | persistent: true
--------------------------------------------------------------------------------
/web-security-session/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**
6 | !**/src/test/**
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 |
17 | ### IntelliJ IDEA ###
18 | .idea
19 | *.iws
20 | *.iml
21 | *.ipr
22 | out/
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 |
31 | ### VS Code ###
32 | .vscode/
33 |
--------------------------------------------------------------------------------
/web-security-oauth-server/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**
6 | !**/src/test/**
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 |
17 | ### IntelliJ IDEA ###
18 | .idea
19 | *.iws
20 | *.iml
21 | *.ipr
22 | out/
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 |
31 | ### VS Code ###
32 | .vscode/
33 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**
6 | !**/src/test/**
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 |
17 | ### IntelliJ IDEA ###
18 | .idea
19 | *.iws
20 | *.iml
21 | *.ipr
22 | out/
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 |
31 | ### VS Code ###
32 | .vscode/
33 |
34 | application-kakao.yml
--------------------------------------------------------------------------------
/web-security/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**
6 | !**/src/test/**
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 |
17 | ### IntelliJ IDEA ###
18 | .idea
19 | *.iws
20 | *.iml
21 | *.ipr
22 | out/
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 |
31 | ### VS Code ###
32 | .vscode/
33 |
34 | node_modules/
35 | src/main/resources/dist/
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/bean/Repository.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.bean;
2 |
3 | import lombok.Data;
4 |
5 | import javax.validation.constraints.NotBlank;
6 |
7 | /**
8 | * 저장소
9 | */
10 | @Data
11 | public class Repository {
12 | private String id;
13 | @NotBlank private String name;
14 | private String description;
15 | private boolean isPublic = true;
16 |
17 | private String ownerId;
18 |
19 | private long created = System.currentTimeMillis();
20 | private long modified = System.currentTimeMillis();
21 | }
22 |
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/WebSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class WebSecurityApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | SpringApplication.run(WebSecurityApplication.class, args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/common/mixins/common-mixin.js:
--------------------------------------------------------------------------------
1 | export default {
2 | mixins: [],
3 | data() {
4 | // this.getState()
5 |
6 | return {
7 | state: window.state
8 | }
9 | },
10 | methods: {
11 | getState() {
12 | async function state() {
13 | let response = await $http.get('/api/state')
14 | return response
15 | }
16 |
17 | state().then((res) => {
18 | this.state = res.data
19 | })
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/web-security-session/src/main/java/kr/kdev/demo/WebSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class WebSecurityApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | SpringApplication.run(WebSecurityApplication.class, args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/web-security/src/main/resources/db/README.md:
--------------------------------------------------------------------------------
1 | ## PostgreSQL with Docker
2 | ```sh
3 | # install postgres container
4 | docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -d postgres:9.6
5 |
6 | # connect postgres container using bash
7 | docker exec -i -t postgres /bin/bash
8 |
9 | # change to postgres user
10 | su - postgres
11 |
12 | #
13 | psql
14 |
15 | # create database
16 | create database demo;
17 |
18 | # create user and grant
19 | create user kdevkr with encrypted password 'password';
20 | grant all privileges on database demo to kdevkr;
21 | ```
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/WebSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class WebSecurityApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | SpringApplication.run(WebSecurityApplication.class, args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/java/kr/kdev/demo/WebSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class WebSecurityApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | SpringApplication.run(WebSecurityApplication.class, args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Spring Demo Security
8 |
9 |
10 |
11 |
${authentication.name}
12 |
13 | ${authentication.principal}
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/config/SessionConfig.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.security.core.session.SessionRegistry;
6 | import org.springframework.security.core.session.SessionRegistryImpl;
7 |
8 | @Configuration(proxyBeanMethods = false)
9 | public class SessionConfig {
10 |
11 | @Bean
12 | public SessionRegistry sessionRegistry() {
13 | return new SessionRegistryImpl();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/bean/CurrentUser.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.bean;
2 |
3 | import org.springframework.security.core.annotation.AuthenticationPrincipal;
4 |
5 | import java.lang.annotation.Documented;
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | @Target({ElementType.PARAMETER, ElementType.TYPE})
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Documented
14 | @AuthenticationPrincipal
15 | public @interface CurrentUser {
16 | }
17 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/db/user.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "userId": 1,
4 | "name": "system",
5 | "id": "system",
6 | "password": "$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG",
7 | "role": "SYSTEM"
8 | },
9 | {
10 | "userId": 2,
11 | "name": "admin",
12 | "id": "admin",
13 | "password": "$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG",
14 | "role": "ADMIN"
15 | },
16 | {
17 | "userId": 3,
18 | "name": "user",
19 | "id": "user",
20 | "password": "$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG",
21 | "role": "USER"
22 | }
23 | ]
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/config/WebConfig.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.config;
2 |
3 | import kr.kdev.demo.interceptor.UserStateInjectionInterceptor;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7 |
8 | @Configuration(proxyBeanMethods = false)
9 | public class WebConfig {
10 |
11 | @Configuration
12 | public static class WebMvcConfig implements WebMvcConfigurer {
13 |
14 | @Override
15 | public void addInterceptors(InterceptorRegistry registry) {
16 | registry.addInterceptor(new UserStateInjectionInterceptor());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/java/kr/kdev/demo/config/WebConfig.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.config;
2 |
3 | import kr.kdev.demo.interceptor.PrincipalInjectionInterceptor;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7 |
8 | @Configuration(proxyBeanMethods = false)
9 | public class WebConfig {
10 |
11 | @Configuration
12 | public static class WebMvcConfig implements WebMvcConfigurer {
13 |
14 | @Override
15 | public void addInterceptors(InterceptorRegistry registry) {
16 | registry.addInterceptor(new PrincipalInjectionInterceptor());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/web-security/src/main/vue/README.md:
--------------------------------------------------------------------------------
1 | ```sh
2 | npm init -y
3 |
4 | # npm install for webpack.
5 | npm i -D webpack webpack-cli webpack-dev-server webpack-merge mini-css-extract-plugin friendly-errors-webpack-plugin compression-webpack-plugin
6 | npm i -D file-loader css-loader style-loader style-resources-loader sass-loader node-sass
7 |
8 | # npm install for babel.
9 | npm i -D babel-loader babel-polyfill @babel/core @babel/polyfill @babel/preset-env babel-plugin-syntax-dynamic-import
10 |
11 | # npm install for vuejs.
12 | npm i -D vue vue-loader vue-router vuex vue-style-loader vue-template-compiler
13 | npm i -D bootstrap bootstrap-vue axios
14 |
15 | # npm install for postcss.
16 | npm i -D postcss-loader postcss-cssnext precss cssnano
17 |
18 | # npm install for eslint.
19 | npm i -D eslint eslint-loader eslint-plugin-vue
20 |
21 | ```
--------------------------------------------------------------------------------
/web-security-oauth-server/src/main/resources/db/client.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "client_1",
4 | "clientId": "e0113ca5-486f-43e9-9615-674b2232caed",
5 | "clientSecret": "$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG",
6 | "authorizedGrantTypes": "authorization_code, client_credentials, refresh_token",
7 | "registeredRedirectUri": "http://localhost:8080",
8 | "accessTokenValidity": 86400,
9 | "refreshTokenValidity": 604800
10 | },
11 | {
12 | "name": "client_2",
13 | "clientId": "429c4db4-821c-414e-bccd-2f4826ea08c4",
14 | "clientSecret": "$2a$12$ry/T4SyQyiNpaWbadf9sne3Cko..q92Oh2klkCMv4XB1qG6cy8iaG",
15 | "authorizedGrantTypes": "authorization_code, implicit, client_credentials",
16 | "registeredRedirectUri": "http://localhost:8080",
17 | "accessTokenValidity": 86400
18 | }
19 | ]
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/java/kr/kdev/demo/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.controller;
2 |
3 | import org.springframework.security.core.Authentication;
4 | import org.springframework.security.core.context.SecurityContext;
5 | import org.springframework.security.core.context.SecurityContextHolder;
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.ui.Model;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 |
10 |
11 | @Controller
12 | public class IndexController {
13 |
14 | @GetMapping("/")
15 | public String index(Model model) {
16 | SecurityContext context = SecurityContextHolder.getContext();
17 | Authentication authentication = context.getAuthentication();
18 | model.addAttribute("authentication", authentication);
19 | return "index";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/web-security/src/test/java/kr/kdev/demo/config/ServiceTestConfigurer.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.config;
2 |
3 | import org.junit.Before;
4 | import org.junit.runner.RunWith;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.security.core.context.SecurityContext;
8 | import org.springframework.security.core.context.SecurityContextHolder;
9 | import org.springframework.test.context.ActiveProfiles;
10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11 |
12 | @ActiveProfiles({"test"})
13 | @RunWith(SpringJUnit4ClassRunner.class)
14 | @ServiceTest
15 | public class ServiceTestConfigurer {
16 |
17 | protected Logger LOG = LoggerFactory.getLogger(getClass());
18 | protected SecurityContext securityContext;
19 |
20 | @Before
21 | public void setUp() {
22 | this.securityContext = SecurityContextHolder.getContext();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/web-security-oauth-kakao-login/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | freemarker:
3 | suffix: .html
4 |
5 | resources:
6 | static-locations: 'classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/, classpath:/META-INF/resources/webjars'
7 | security:
8 | oauth2:
9 | client:
10 | registration:
11 | kakao:
12 | client-id:
13 | client-secert:
14 | redirect-uri: '{baseUrl}/login/oauth2/code/{registrationId}'
15 | authorization-grant-type: authorization_code
16 | provider:
17 | kakao:
18 | authorization-uri: https://kauth.kakao.com/oauth/authorize
19 | token-uri: https://kauth.kakao.com/oauth/token
20 | user-info-uri: https://kapi.kakao.com/v2/user/me
21 | user-info-authentication-method: POST
22 |
23 | logging:
24 | level:
25 | kr:
26 | kdev:
27 | demo: DEBUG
--------------------------------------------------------------------------------
/web-security/src/main/vue/route/route.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter from 'vue-router'
3 |
4 | // const Blank = () => import(/* webpackChunkName: "common-view" */ '~/vue/common/blank')
5 | // const Index = () => import(/* webpackChunkName: "index-view" */ '~/vue/page/index')
6 | // const Main = () => import(/* webpackChunkName: "main-view" */ '~/vue/page/main')
7 |
8 | import Blank from '~/vue/common/blank'
9 | import Index from '~/vue/page/index'
10 | import Main from '~/vue/page/main'
11 | import Login from '~/vue/page/login'
12 |
13 | Vue.use(VueRouter)
14 |
15 | const routes = [
16 | {
17 | path: '',
18 | component: Index,
19 | meta: {
20 | title: 'index'
21 | }
22 | },
23 | {
24 | path: '/login',
25 | component: Login,
26 | meta: {
27 | title: 'login'
28 | },
29 | }
30 | ]
31 |
32 | export default new VueRouter({
33 | mode: 'history',
34 | routes
35 | })
--------------------------------------------------------------------------------
/web-security/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Spring Demo Security
5 |
6 |
7 |
8 |
9 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/web-security/src/main/java/kr/kdev/demo/api/UserApi.java:
--------------------------------------------------------------------------------
1 | package kr.kdev.demo.api;
2 |
3 | import org.springframework.http.ResponseEntity;
4 | import org.springframework.security.core.Authentication;
5 | import org.springframework.security.core.annotation.AuthenticationPrincipal;
6 | import org.springframework.security.core.context.SecurityContextHolder;
7 | import org.springframework.security.core.userdetails.UserDetails;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @RestController
12 | public class UserApi extends BaseApi {
13 |
14 | @GetMapping("/users/me")
15 | public ResponseEntity