chore : clean code
This commit is contained in:
@@ -7,7 +7,6 @@ import io.bluemoon.authorizationserver.domain.oauth.client.ClientRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
server.port=8081
|
||||
server.servlet.context-path=/mk-auth
|
||||
server.use-forward-headers=false
|
||||
|
||||
security.oauth2.authorization.check-token-access=isAuthenticated()
|
||||
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1/oauth2?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
@@ -11,23 +9,16 @@ spring.datasource.password=bluemoon
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.platform=schema
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB53Dialect
|
||||
|
||||
|
||||
|
||||
spring.jpa.database = MYSQL
|
||||
spring.jpa.database=MYSQL
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.generate-ddl=true
|
||||
spring.jpa.show-sql=true
|
||||
#spring.jpa.generate-ddl=false
|
||||
#spring.jpa.hibernate.ddl-auto=none
|
||||
|
||||
spring.security.oauth2.client.registration.facebook.client-id=715358882216622
|
||||
spring.security.oauth2.client.registration.facebook.client-secret=a39d8f1e06e8c3863d12e8461f4991e8
|
||||
|
||||
spring.security.oauth2.client.registration.google.client-id=534360107417-qhkkasmnj4tml8iuk3v1dh72ipjvf2qp.apps.googleusercontent.com
|
||||
spring.security.oauth2.client.registration.google.client-secret=XkmQ3KPTpmTkWb8X6_1WRR5i
|
||||
|
||||
|
||||
#facebook.client.access-token-uri=https://graph.facebook.com/oauth/access_token
|
||||
#facebook.client.user-authorization-uri=https://www.facebook.com/dialog/oauth
|
||||
#facebook.client.token-name=oauth_token
|
||||
@@ -35,7 +26,5 @@ spring.security.oauth2.client.registration.google.client-secret=XkmQ3KPTpmTkWb8X
|
||||
#facebook.client.client-authentication-scheme=form
|
||||
#
|
||||
#facebook.resource.user-info-uri=https://graph.facebook.com/me?fields=id
|
||||
|
||||
|
||||
logging.level.web=debug
|
||||
spring.http.log-request-details=true
|
||||
spring.http.log-request-details=true
|
||||
|
||||
@@ -10,16 +10,16 @@
|
||||
protected resources
|
||||
with scope ${authorizationRequest.scope?join(", ")}.
|
||||
</p>
|
||||
<form id="confirmationForm" name="confirmationForm"
|
||||
action="../oauth/authorize" method="post">
|
||||
<input name="user_oauth_approval" value="true" type="hidden"/>
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<form action="../oauth/authorize" id="confirmationForm"
|
||||
method="post" name="confirmationForm">
|
||||
<input name="user_oauth_approval" type="hidden" value="true"/>
|
||||
<input id="csrf_token" name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
|
||||
<button class="btn btn-primary" type="submit">Approve</button>
|
||||
</form>
|
||||
<form id="denyForm" name="confirmationForm"
|
||||
action="../oauth/authorize" method="post">
|
||||
<input name="user_oauth_approval" value="false" type="hidden"/>
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<form action="../oauth/authorize" id="denyForm"
|
||||
method="post" name="confirmationForm">
|
||||
<input name="user_oauth_approval" type="hidden" value="false"/>
|
||||
<input id="csrf_token" name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
|
||||
<button class="btn btn-primary" type="submit">Deny</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,47 +1,52 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" rel="stylesheet">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<form role="form" th:action="@{/login}" method="post">
|
||||
<form method="post" role="form" th:action="@{/login}">
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-sm-2 col-form-label">ID</label>
|
||||
<label class="col-sm-2 col-form-label" for="username">ID</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="username" placeholder="id" name="username">
|
||||
<input class="form-control" id="username" name="username" placeholder="id" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-sm-2 col-form-label">Password</label>
|
||||
<label class="col-sm-2 col-form-label" for="password">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="password" placeholder="password" name="password">
|
||||
<input class="form-control" id="password" name="password" placeholder="password" type="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
<input id="csrf_token" name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
|
||||
<button class="btn btn-primary" type="submit">Sign in</button>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a href="/mk-auth/oauth2/authorization/facebook" class="btn btn-primary btn-lg active" role="button" aria-pressed="false">Facebook</a>
|
||||
<a aria-pressed="false" class="btn btn-primary btn-lg active" href="/mk-auth/oauth2/authorization/facebook"
|
||||
role="button">Facebook</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="/mk-auth/oauth2/authorization/google" class="btn btn-secondary btn-lg active" role="button" aria-pressed="false">Google</a>
|
||||
<a aria-pressed="false" class="btn btn-secondary btn-lg active" href="/mk-auth/oauth2/authorization/google"
|
||||
role="button">Google</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
</html>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||
</html>
|
||||
|
||||
@@ -13,15 +13,15 @@ import org.springframework.web.client.RestTemplate;
|
||||
@SpringBootApplication
|
||||
public class ContentsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ContentsApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@LoadBalanced
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ContentsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,11 @@ package io.bluemoon.gatewayzuul;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateCustomizer;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.oauth2.client.token.AccessTokenProviderChain;
|
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider;
|
||||
import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider;
|
||||
import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitAccessTokenProvider;
|
||||
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider;
|
||||
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -27,11 +17,6 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@EnableZuulProxy
|
||||
@SpringBootApplication
|
||||
@@ -43,7 +28,7 @@ public class GatewayZuulApplication {
|
||||
|
||||
@Controller
|
||||
public static class TestController {
|
||||
|
||||
|
||||
@RequestMapping(value = "/gateway/logout", method = RequestMethod.GET)
|
||||
public String signOut(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
Object details = authentication.getDetails();
|
||||
@@ -51,7 +36,7 @@ public class GatewayZuulApplication {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = "http://localhost:8081/mk-auth/revokeToken";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", "Bearer "+token);
|
||||
headers.set("Authorization", "Bearer " + token);
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<Object>(headers);
|
||||
restTemplate.exchange(url, HttpMethod.POST, requestEntity, Void.class);
|
||||
|
||||
@@ -59,14 +44,14 @@ public class GatewayZuulApplication {
|
||||
HttpSession httpSession = request.getSession();
|
||||
httpSession.invalidate();
|
||||
Cookie[] cookies = request.getCookies();
|
||||
for (Cookie cookie: cookies) {
|
||||
for (Cookie cookie : cookies) {
|
||||
cookie.setPath("/");
|
||||
cookie.setSecure(true);
|
||||
cookie.setMaxAge(0);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
return "redirect:"+"http://localhost:8765/mk-auth/rending";
|
||||
return "redirect:" + "http://localhost:8765/mk-auth/rending";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,12 @@ package io.bluemoon.gatewayzuul.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
|
||||
import org.springframework.security.web.csrf.*;
|
||||
import org.springframework.security.web.csrf.CsrfToken;
|
||||
import org.springframework.security.web.csrf.CsrfTokenRepository;
|
||||
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
@@ -19,47 +18,13 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Configuration
|
||||
@EnableOAuth2Sso
|
||||
@EnableResourceServer
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/", "/mk-auth/**", "/login").permitAll().anyRequest().authenticated()
|
||||
.and()
|
||||
.logout().logoutSuccessUrl("/gateway/logout").logoutRequestMatcher(new AntPathRequestMatcher("/logout")).invalidateHttpSession(true).deleteCookies("JSESSIONID").clearAuthentication(true);
|
||||
|
||||
}
|
||||
|
||||
private RequestMatcher csrfRequestMatcher() {
|
||||
return new RequestMatcher() {
|
||||
|
||||
private final Pattern allowedMethods = Pattern.compile("^(GET|HEAD|OPTIONS|TRACE)$");
|
||||
|
||||
// Disable CSFR protection on the following urls:
|
||||
private final AntPathRequestMatcher[] requestMatchers = { new AntPathRequestMatcher("/mk-auth/**") };
|
||||
|
||||
@Override
|
||||
public boolean matches(HttpServletRequest request) {
|
||||
if (allowedMethods.matcher(request.getMethod()).matches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AntPathRequestMatcher matcher : requestMatchers) {
|
||||
if (matcher.matches(request)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
private static Filter csrfHeaderFilter() {
|
||||
|
||||
@@ -85,6 +50,38 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/", "/mk-auth/**", "/login").permitAll().anyRequest().authenticated()
|
||||
.and()
|
||||
.logout().logoutSuccessUrl("/gateway/logout").logoutRequestMatcher(new AntPathRequestMatcher("/logout")).invalidateHttpSession(true).deleteCookies("JSESSIONID").clearAuthentication(true);
|
||||
|
||||
}
|
||||
|
||||
private RequestMatcher csrfRequestMatcher() {
|
||||
return new RequestMatcher() {
|
||||
|
||||
private final Pattern allowedMethods = Pattern.compile("^(GET|HEAD|OPTIONS|TRACE)$");
|
||||
|
||||
// Disable CSFR protection on the following urls:
|
||||
private final AntPathRequestMatcher[] requestMatchers = {new AntPathRequestMatcher("/mk-auth/**")};
|
||||
|
||||
@Override
|
||||
public boolean matches(HttpServletRequest request) {
|
||||
if (allowedMethods.matcher(request.getMethod()).matches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AntPathRequestMatcher matcher : requestMatchers) {
|
||||
if (matcher.matches(request)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ public class DynamicOauth2ClientContextFilter extends OAuth2ClientContextFilter
|
||||
protected void redirectUser(UserRedirectRequiredException e, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String redirectUri = e.getRedirectUri();
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(redirectUri);
|
||||
Map<String, String > requestParams = e.getRequestParams();
|
||||
for (Map.Entry<String ,String> param : requestParams.entrySet()) {
|
||||
Map<String, String> requestParams = e.getRequestParams();
|
||||
for (Map.Entry<String, String> param : requestParams.entrySet()) {
|
||||
builder.queryParam(param.getKey(), param.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,5 @@ public class HeaderEnhanceFilter implements Filter {
|
||||
// test if request url is permit all, then remove authorization from header
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,30 @@
|
||||
server.port=8765
|
||||
|
||||
zuul.sensitive-headers=
|
||||
|
||||
zuul.routes.mk2-service.path=/api/**
|
||||
zuul.routes.mk2-service.url=http://127.0.0.1:8082
|
||||
zuul.routes.mk2-service.sensitive-headers=
|
||||
|
||||
zuul.routes.mk2-oauth.path=/mk-auth/**
|
||||
#zuul.routes.mk2-oauth.url=https://59a7bc58.ngrok.io
|
||||
zuul.routes.mk2-oauth.url=http://localhost:8081
|
||||
zuul.routes.mk2-oauth.sensitive-headers=
|
||||
#zuul.routes.mk2-oauth.path=/mk2auth/**
|
||||
|
||||
zuul.routes.mk2-oauth.strip-prefix=false
|
||||
zuul.add-proxy-headers=true
|
||||
|
||||
security.oauth2.sso.login-path=/login
|
||||
|
||||
security.oauth2.client.access-token-uri=http://localhost:8081/mk-auth/oauth/token
|
||||
# /oauth/authorize 요청은 클라이언트가 리소스 서버의 api를 사용하기 위해 사용자(리소스 소유자)에게
|
||||
# 권한 위임 동의를 받기 위한 페이지를 출력하는 기능을 수행
|
||||
security.oauth2.client.user-authorization-uri=http://localhost:8081/mk-auth/oauth/authorize
|
||||
security.oauth2.resource.user-info-uri=http://localhost:8081/mk-auth/user
|
||||
|
||||
security.oauth2.resource.prefer-token-info=false
|
||||
|
||||
security.oauth2.client.client-id=system1
|
||||
security.oauth2.client.client-secret=1234
|
||||
|
||||
|
||||
#management.security.enabled=false
|
||||
#security.oauth2.resource.jwt.key-value="abc"
|
||||
#security.oauth2.resource.id=read
|
||||
#security.oauth2.resource.service-id=${PREFIX:}resource
|
||||
|
||||
|
||||
#management.endpoints.web.exposure.include=routes, health, filter
|
||||
#management.endpoint.routes.enabled=true
|
||||
#management.endpoint.filters.enabled=true
|
||||
logging.level.web=debug
|
||||
spring.http.log-request-details=true
|
||||
spring.http.log-request-details=true
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
spring.application.name=queue
|
||||
server.port=8080
|
||||
|
||||
spring.jackson.serialization.write-dates-as-timestamps=false
|
||||
|
||||
#spring.datasource.url=jdbc:mysql://rds.master.uneedcomms.net/mmc?charset=utf8
|
||||
#spring.datasource.username=mmc_crud
|
||||
#spring.datasource.password=s3art33c
|
||||
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
cloud.aws.credentials.access-key=AKIAJG77K3AKVKQVE3LA
|
||||
cloud.aws.credentials.secret-key=jCz0WxtU08pWv2opnQfSE4qL8cBZunX6yQuO2zAF
|
||||
cloud.aws.region.auto=false
|
||||
cloud.aws.region.static=ap-northeast-2
|
||||
cloud.aws.stack.auto=false
|
||||
|
||||
#sqs.queue_name=sender-sms.fifo
|
||||
#sqs.url=https://sqs.ap-northeast-2.amazonaws.com/203872522995/sender-sms.fifo
|
||||
|
||||
@@ -2,16 +2,16 @@ package io.bluemoon.testservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class TestServiceApplication {
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public static class TestController{
|
||||
public static class TestController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@@ -36,7 +36,7 @@ public class TestServiceApplication {
|
||||
System.out.println(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
// UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication)authentication;
|
||||
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) authentication;
|
||||
OAuth2AuthenticationDetails oAuth2AuthenticationDetails = (OAuth2AuthenticationDetails) oAuth2Authentication.getDetails();
|
||||
|
||||
// System.out.println(userDetails.getUsername());
|
||||
@@ -66,7 +66,7 @@ public class TestServiceApplication {
|
||||
public String helloMk2Secret(Principal principal) {
|
||||
return principal == null ? "hello anonymous" : "heelo" + principal.getName();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
server.port=8082
|
||||
server.servlet.context-path=/test
|
||||
|
||||
#security.oauth2.resource.user-info-uri=http://oauth.keepgrow.world/uaa/user
|
||||
security.oauth2.resource.user-info-uri=http://localhost:8765/uaa/user
|
||||
security.oauth2.resource.token-info-uri=http://localhost:8081/uaa/oauth/check_token
|
||||
security.oauth2.resource.prefer-token-info=false
|
||||
|
||||
|
||||
logging.level.web=debug
|
||||
spring.http.log-request-details=true
|
||||
spring.http.log-request-details=true
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" rel="stylesheet">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<form role="form" th:action="@{/signInMiddleWare}" method="post">
|
||||
<form method="post" role="form" th:action="@{/signInMiddleWare}">
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-sm-2 col-form-label">ID</label>
|
||||
<label class="col-sm-2 col-form-label" for="username">ID</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="username" placeholder="id" name="username">
|
||||
<input class="form-control" id="username" name="username" placeholder="id" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-sm-2 col-form-label">Password</label>
|
||||
<label class="col-sm-2 col-form-label" for="password">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="password" placeholder="password" name="password">
|
||||
<input class="form-control" id="password" name="password" placeholder="password" type="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
<input id="csrf_token" name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
|
||||
<button class="btn btn-primary" type="submit">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
</html>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||
</html>
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" rel="stylesheet">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<form role="form" th:action="@{/signUpMiddleWare}" method="post">
|
||||
<form method="post" role="form" th:action="@{/signUpMiddleWare}">
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-sm-2 col-form-label">ID</label>
|
||||
<label class="col-sm-2 col-form-label" for="username">ID</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="username" placeholder="id" name="username">
|
||||
<input class="form-control" id="username" name="username" placeholder="id" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-sm-2 col-form-label">Password</label>
|
||||
<label class="col-sm-2 col-form-label" for="password">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="password" placeholder="password" name="password">
|
||||
<input class="form-control" id="password" name="password" placeholder="password" type="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
<input id="csrf_token" name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
|
||||
<button class="btn btn-primary" type="submit">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
</html>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script crossorigin="anonymous"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||
</html>
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
|
||||
Reference in New Issue
Block a user