Skip to content
Permalink
Browse files

Added ResourceServerConfig

  • Loading branch information...
borabilgin committed Jan 21, 2019
1 parent aff44d4 commit e0218c7504972488076521743a5b6451c38a6020
Showing with 35 additions and 0 deletions.
  1. +35 −0 api/src/main/java/com/demo/imagebrowser/config/ResourceServerConfig.java
@@ -0,0 +1,35 @@
package com.demo.imagebrowser.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;

@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Autowired
private ResourceServerTokenServices tokenServices;

@Value("${security.jwt.resource-ids}")
private String jwtResourceIds;

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

@Override
public void configure(HttpSecurity http) throws Exception {
http
.requestMatchers()
.and()
.authorizeRequests()
.antMatchers("/actuator/**", "/api-docs/**").permitAll()
.antMatchers("/secure/**" ).authenticated();
}
}

0 comments on commit e0218c7

Please sign in to comment.
You can’t perform that action at this time.