commit
bf3bdd9ec0
@ -8,18 +8,28 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
|
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
||||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||||
|
import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler;
|
||||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||||
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
|
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@PropertySource({ "classpath:persistence.properties" })
|
@PropertySource({ "classpath:persistence.properties" })
|
||||||
@EnableResourceServer
|
@EnableResourceServer
|
||||||
public class OAuth2ResourceServerConfig {
|
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||||
|
public class OAuth2ResourceServerConfig extends GlobalMethodSecurityConfiguration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Environment env;
|
private Environment env;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
||||||
|
return new OAuth2MethodSecurityExpressionHandler();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package org.baeldung.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
|
||||||
import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
|
||||||
public class ResourceSecurityConfig extends GlobalMethodSecurityConfiguration {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
|
||||||
return new OAuth2MethodSecurityExpressionHandler();
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.boot.context.web.SpringBootServletInitializer;
|
import org.springframework.boot.context.web.SpringBootServletInitializer;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ResourceApplication extends SpringBootServletInitializer {
|
public class ResourceServerApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ResourceApplication.class, args);
|
SpringApplication.run(ResourceServerApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,6 +8,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan({ "org.baeldung.web.controller" })
|
@ComponentScan({ "org.baeldung.web.controller" })
|
||||||
public class ResourceWebConfig extends WebMvcConfigurerAdapter {
|
public class ResourceServerWebConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user