diff --git a/pom.xml b/pom.xml
index 024ab08..067f033 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.1.4.RELEASE
+ 2.3.1.RELEASE
com.example
@@ -39,10 +39,14 @@
org.springframework.boot
spring-boot-starter-security
+
+ org.springframework.security
+ spring-security-oauth2-jose
+
org.springframework.security.oauth.boot
spring-security-oauth2-autoconfigure
- 2.1.4.RELEASE
+ 2.3.1.RELEASE
@@ -50,15 +54,6 @@
h2
runtime
-
-
-
-
-
-
-
-
-
org.apache.commons
commons-lang3
diff --git a/src/main/java/com/example/template/config/JwkSetEndpointConfiguration.java b/src/main/java/com/example/template/config/JwkSetEndpointConfiguration.java
new file mode 100644
index 0000000..c81bcbf
--- /dev/null
+++ b/src/main/java/com/example/template/config/JwkSetEndpointConfiguration.java
@@ -0,0 +1,29 @@
+package com.example.template.config;
+
+import com.nimbusds.jose.jwk.JWKSet;
+import com.nimbusds.jose.jwk.RSAKey;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.security.KeyPair;
+import java.security.Principal;
+import java.security.interfaces.RSAPublicKey;
+import java.util.Map;
+
+@RestController
+public class JwkSetEndpointConfiguration {
+ KeyPair keyPair;
+
+ public JwkSetEndpointConfiguration(KeyPair keyPair) {
+ this.keyPair = keyPair;
+ }
+
+ @GetMapping("/.well-known/jwks.json")
+ @ResponseBody
+ public Map getKey(Principal principal) {
+ RSAPublicKey publicKey = (RSAPublicKey) this.keyPair.getPublic();
+ RSAKey key = new RSAKey.Builder(publicKey).build();
+ return new JWKSet(key).toJSONObject();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/template/config/OAuth2AuthorizationServerConfig.java b/src/main/java/com/example/template/config/OAuth2AuthorizationServerConfig.java
index 55ee9c1..ea238d6 100755
--- a/src/main/java/com/example/template/config/OAuth2AuthorizationServerConfig.java
+++ b/src/main/java/com/example/template/config/OAuth2AuthorizationServerConfig.java
@@ -59,21 +59,6 @@ public class OAuth2AuthorizationServerConfig extends AuthorizationServerConfigur
@Autowired
private Environment env;
- /**
- * DB 설정을 별도로 하게 되면 에러가 발생한다.
- * @throws Exception
- */
-// @Bean
-// public DataSource oauthDataSource() {
-//
-// DriverManagerDataSource dataSource = new DriverManagerDataSource();
-// dataSource.setDriverClassName(env.getProperty("spring.datasource.driverClassName"));
-// dataSource.setUrl(env.getProperty("spring.datasource.url"));
-// dataSource.setUsername(env.getProperty("spring.datasource.username"));
-// dataSource.setPassword(env.getProperty("spring.datasource.password"));
-// return dataSource;
-// }
-
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security.accessDeniedHandler((request, response, exception)->{
diff --git a/src/main/java/com/example/template/config/WebSecurityConfig.java b/src/main/java/com/example/template/config/WebSecurityConfig.java
index e007fbb..ffec78b 100755
--- a/src/main/java/com/example/template/config/WebSecurityConfig.java
+++ b/src/main/java/com/example/template/config/WebSecurityConfig.java
@@ -61,6 +61,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
.antMatchers("/js/**")
.antMatchers("/favicon*/**")
.antMatchers("/img/**")
+ .antMatchers("/.well-known/jwks.json")
;
}
diff --git a/src/main/java/com/example/template/entity/User.java b/src/main/java/com/example/template/entity/User.java
index 12b2af3..1381f65 100755
--- a/src/main/java/com/example/template/entity/User.java
+++ b/src/main/java/com/example/template/entity/User.java
@@ -12,7 +12,7 @@ import lombok.Setter;
import lombok.ToString;
@Entity
-@Table(name = "users")
+@Table(name = "users_table")
public class User implements UserDetails{
@Id
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 838a228..2336dca 100755
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -6,14 +6,7 @@ spring:
ddl-auto: update
properties:
hibernate:
- dialect: org.hibernate.dialect.MySQL57Dialect
show_sql: true
-# datasource:
-# url: jdbc:mysql://104.198.86.212:3306/uengine
-# username: root
-# password: test1234!@
-# # mybatis 설정시에는 driverClassName 을 넣어주어야함
-# driverClassName: com.mysql.cj.jdbc.Driver
---
spring: