grant type password adject
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package io.bluemoon.authorizationserver2.config;
|
||||
|
||||
import io.bluemoon.authorizationserver2.service.user.CustomUserDetailsServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
@@ -11,6 +12,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
public class WebSecurity2Config extends WebSecurityConfigurerAdapter {
|
||||
private CustomUserDetailsServiceImpl customUserDetailsService;
|
||||
|
||||
@@ -33,7 +35,7 @@ public class WebSecurity2Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
super.configure(http);
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -14,6 +14,4 @@ public class AuthController {
|
||||
return user;
|
||||
}
|
||||
|
||||
SecurityContextHolder
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
package io.bluemoon.authorizationserver2.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class SignController {
|
||||
|
||||
@PostMapping("/middleWare")
|
||||
@ResponseBody
|
||||
private String mid(@RequestBody Map request, @RequestHeader Map header) {
|
||||
System.out.println(request);
|
||||
System.out.println(header);
|
||||
return "a";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ spring.jpa.show-sql=true
|
||||
#spring.jpa.generate-ddl=false
|
||||
#spring.jpa.hibernate.ddl-auto=none
|
||||
|
||||
|
||||
# jwt
|
||||
#security.oauth2.resource.prefer-token-info=false
|
||||
|
||||
logging.level.web=debug
|
||||
spring.http.log-request-details=true
|
||||
@@ -25,7 +25,11 @@ ext {
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-oauth2'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
|
||||
implementation 'com.google.code.gson:gson'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#Mon Jul 08 11:53:32 KST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
package io.bluemoon.testservice.config;
|
||||
|
||||
public class WebMvcConfig {
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/signIn").setViewName("signIn");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
package io.bluemoon.testservice.config;
|
||||
|
||||
public class WebSecurityConfig {
|
||||
import io.bluemoon.testservice.handler.CustomAuthFailureHandler;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
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.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@Order(-1)
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/signIn").permitAll()
|
||||
.antMatchers("/signInAfter").permitAll()
|
||||
.anyRequest()
|
||||
.authenticated();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,29 @@
|
||||
package io.bluemoon.testservice.controller;
|
||||
|
||||
import io.bluemoon.testservice.domain.user.User;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class SignController {
|
||||
@PostMapping("/signInAfter")
|
||||
private String signIn(HttpServletRequest request) {
|
||||
System.out.println(request);
|
||||
System.out.println(request.getAuthType());
|
||||
System.out.println(request.getSession());
|
||||
System.out.println(request.getParameterMap().toString());
|
||||
|
||||
return "aaaa";
|
||||
}
|
||||
|
||||
@PostMapping("/createOAuthUser")
|
||||
public String creatOAuthUser(@RequestBody @Valid User user, @RequestHeader Map header) {
|
||||
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package io.bluemoon.testservice.domain;
|
||||
package io.bluemoon.testservice.domain.user;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Data
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package io.bluemoon.testservice.domain.user;
|
||||
|
||||
public interface UserRepository {
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.bluemoon.authorizationserver.config.handler;
|
||||
package io.bluemoon.testservice.handler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
|
||||
@@ -8,4 +8,4 @@ server.servlet.context-path=/api
|
||||
#security.oauth2.client.client-id=system1
|
||||
#security.oauth2.client.client-secret=1234
|
||||
#security.oauth2.resource.token-info-uri=http://127.0.0.1:8081/mk-auth/oauth/check_token
|
||||
security.oauth2.resource.user-info-uri=http://127.0.0.1:8765/auth/user
|
||||
security.oauth2.resource.user-info-uri=http://127.0.0.1:8765/auth/check_token
|
||||
@@ -5,7 +5,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<form role="form" th:action="@{/login}" method="post">
|
||||
<form role="form" th:action="@{/signInAfter}" method="post">
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-sm-2 col-form-label">ID</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -24,14 +24,6 @@
|
||||
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<button type="submit" class="btn btn-primary">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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="/mk-auth/oauth2/authorization/google" class="btn btn-secondary btn-lg active" role="button" aria-pressed="false">Google</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user