Created
October 30, 2018 19:46
-
-
Save levinzonr/201e7ff9665bd884a82e7888abc2e913 to your computer and use it in GitHub Desktop.
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 | |
| class Application { | |
| @Bean | |
| fun provideTokenStore() : TokenStore { | |
| return InMemoryTokenStore() | |
| } | |
| @Bean | |
| fun providePasswordEncoder() : BCryptPasswordEncoder { | |
| return BCryptPasswordEncoder() | |
| } | |
| companion object { | |
| @JvmStatic | |
| fun main(args: Array<String>) { | |
| SpringApplication.run(Application::class.java, *args) | |
| } | |
| } | |
| } |
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
| package com.levinzonr.ezpad.security.resource | |
| import org.springframework.context.annotation.Configuration | |
| import org.springframework.http.HttpMethod | |
| import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity | |
| 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 | |
| @Configuration | |
| @EnableResourceServer | |
| @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) | |
| class ResourceServerConfiguration : ResourceServerConfigurerAdapter() { | |
| override fun configure(resources: ResourceServerSecurityConfigurer?) { | |
| resources?.resourceId(ResourceServerSettings.RESOURCE_ID) | |
| } | |
| override fun configure(http: HttpSecurity?) { | |
| http?.authorizeRequests() | |
| ?.antMatchers(HttpMethod.POST, "/oauth/**")?.permitAll() | |
| ?.antMatchers("/auth/**")?.permitAll() | |
| ?.antMatchers(HttpMethod.OPTIONS, "/api/**")?.permitAll() | |
| ?.and() | |
| ?.antMatcher("/api/**")?.authorizeRequests() | |
| ?.antMatchers(HttpMethod.POST, "/api/users")?.permitAll() | |
| ?.anyRequest()?.authenticated() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment