org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration Java Examples

The following examples show how to use org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultipleResourceServerConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void orderIsUnchangedWhenThereAreMultipleResourceServerConfigurations() {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.register(DoubleResourceConfiguration.class);
	TestPropertyValues
			.of("security.oauth2.resource.tokenInfoUri:https://example.com", "security.oauth2.client.clientId=acme")
			.applyTo(this.context);
	this.context.refresh();
	assertThat(this.context.getBean("adminResources", ResourceServerConfiguration.class).getOrder()).isEqualTo(3);
	assertThat(this.context.getBean("otherResources", ResourceServerConfiguration.class).getOrder()).isEqualTo(4);
}
 
Example #2
Source File: MultipleResourceServerConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Bean
protected ResourceServerConfiguration adminResources() {

	ResourceServerConfiguration resource = new ResourceServerConfiguration() {
		// Switch off the Spring Boot @Autowired configurers
		@Override
		public void setConfigurers(List<ResourceServerConfigurer> configurers) {
			super.setConfigurers(configurers);
		}
	};
	resource.setOrder(3);
	return resource;
}
 
Example #3
Source File: MultipleResourceServerConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Bean
protected ResourceServerConfiguration otherResources() {

	ResourceServerConfiguration resource = new ResourceServerConfiguration() {
		// Switch off the Spring Boot @Autowired configurers
		@Override
		public void setConfigurers(List<ResourceServerConfigurer> configurers) {
			super.setConfigurers(configurers);
		}
	};
	resource.setOrder(4);
	return resource;
}
 
Example #4
Source File: CustomResourceServerConfiguration.java    From spring-microservice-boilerplate with MIT License 5 votes vote down vote up
/**
 * Resource of api
 *
 * @return {@link ResourceServerConfiguration}
 */
@Bean protected ResourceServerConfiguration adminResources() {

  ResourceServerConfiguration resource = new ResourceServerConfiguration() {
    // Switch off the Spring Boot @Autowired configurers
    public void setConfigurers(List<ResourceServerConfigurer> configurers) {
      super.setConfigurers(configurers);
    }
  };

  resource.setConfigurers(Collections.singletonList(new ResourceServerConfigurerAdapter() {

    @Override public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
      resources.resourceId(RESOURCE_ID);
    }

    @Override public void configure(HttpSecurity http) throws Exception {
      http
          .csrf().disable()
          .authorizeRequests()
          .antMatchers(OPEN_URL).permitAll()
          .antMatchers(MANAGEMENT_URL).hasAnyAuthority("root", "management")
          .antMatchers(APP_URL).hasAnyAuthority("root", "management", "app");
    }
  }));

  resource.setOrder(1);

  return resource;
}