@@ -0,0 +1,2606 @@
+package com.rizki.mufrizal.belajar.oauth2.configSecurity;%0A%0Aimport com.rizki.mufrizal.belajar.oauth2.filter.CORSFilter;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.core.annotation.Order;%0Aimport org.springframework.security.config.annotation.web.builders.HttpSecurity;%0Aimport org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;%0Aimport org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;%0Aimport org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;%0Aimport org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;%0Aimport org.springframework.security.oauth2.provider.token.RemoteTokenServices;%0Aimport org.springframework.security.web.access.channel.ChannelProcessingFilter;%0A%0A@Configuration%0Apublic class Oauth2Config %7B%0A%0A    private static final String RESOURCE_ID = %22BelajarOauth2%22;%0A%0A    @Configuration%0A    @Order(10)%0A    protected static class NonConfigOauth2 extends WebSecurityConfigurerAdapter%7B%0A%0A        @Override%0A        public void configure(HttpSecurity httpSecurity) throws Exception%7B%0A            httpSecurity%0A                    .authorizeRequests()%0A                        .antMatchers(%22/hello%22).permitAll()%0A                        .antMatchers(%22/**%22).permitAll()%0A                    .and()%0A                        .anonymous()%0A                    .and()%0A                        .addFilterBefore(new CORSFilter(), ChannelProcessingFilter.class);%0A        %7D%0A%0A    %7D%0A%0A    @Configuration%0A    @EnableResourceServer%0A    protected static class configOauth2 extends ResourceServerConfigurerAdapter%7B%0A%0A        @Override%0A        public void configure(ResourceServerSecurityConfigurer resourceServerSecurityConfigurer) throws Exception%7B%0A            RemoteTokenServices remoteTokenServices = new RemoteTokenServices();%0A            remoteTokenServices.setClientId(%22angularClient%22);%0A            remoteTokenServices.setClientSecret(%22angularPassword%22);%0A            remoteTokenServices.setCheckTokenEndpointUrl(%22http://localhost:8002/Belajar-Oauth2-Authorization-Server/oauth/check_token%22);%0A%0A            resourceServerSecurityConfigurer%0A                    .resourceId(RESOURCE_ID)%0A                    .tokenServices(remoteTokenServices);%0A        %7D%0A%0A        @Override%0A        public void configure(HttpSecurity httpSecurity) throws Exception%7B%0A            httpSecurity%0A                    .authorizeRequests()%0A                        .antMatchers(%22/admin%22).hasRole(%22ADMIN%22);%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

Add Oauth2 Config