-
-
Save monkey-codes/d191fe4cbae29466c3f1a213ab3edfae to your computer and use it in GitHub Desktop.
Spring boot - Microservice spring config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @SpringBootApplication | |
| @RestController | |
| class MicroserviceApplication { | |
| @RequestMapping(value = '/{id}', method = RequestMethod.GET) | |
| public Map readFoo(@PathVariable Integer id, Principal principal) { | |
| [ | |
| id: id, | |
| resource: "${UUID.randomUUID()}" as String, | |
| user: principal.getName() | |
| ] | |
| } | |
| @Configuration | |
| @EnableResourceServer | |
| public static class ResourceServiceConfiguration extends ResourceServerConfigurerAdapter { | |
| @Override | |
| void configure(HttpSecurity http) throws Exception { | |
| http.csrf().disable() | |
| .authorizeRequests() | |
| .antMatchers("/**").hasAuthority('ROLE_READER') | |
| } | |
| } | |
| public static void main(String[] args) { | |
| SpringApplication.run(MicroserviceApplication.class, args) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment