@@ -0,0 +1,3460 @@
+package com.rizki.mufrizal.belajar.oauth2.configSecurity;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Qualifier;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.security.authentication.AuthenticationManager;%0Aimport org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;%0Aimport org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;%0Aimport org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;%0Aimport org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;%0Aimport org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;%0Aimport org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore;%0A%0A@Configuration%0Apublic class Oauth2Config %7B%0A%0A    private static final String RESOURCE_ID = %22BelajarOauth2%22;%0A%0A    @Configuration%0A    @EnableAuthorizationServer%0A    protected static class AuthorizationConfig extends AuthorizationServerConfigurerAdapter%7B%0A%0A        @Autowired%0A        @Qualifier(%22authenticationManagerBean%22)%0A        private AuthenticationManager authenticationManager;%0A%0A        @Override%0A        public void configure(AuthorizationServerEndpointsConfigurer authorizationServerEndpointsConfigurer) throws Exception%7B%0A            authorizationServerEndpointsConfigurer%0A                    .tokenStore(new InMemoryTokenStore())%0A                    .authenticationManager(authenticationManager);%0A        %7D%0A%0A        @Override%0A        public void configure(AuthorizationServerSecurityConfigurer authorizationServerSecurityConfigurer) throws Exception%7B%0A            authorizationServerSecurityConfigurer.checkTokenAccess(%22hasRole('CLIENT')%22);%0A        %7D%0A%0A        @Override%0A        public void configure(ClientDetailsServiceConfigurer clientDetailsServiceConfigurer) throws Exception%7B%0A            clientDetailsServiceConfigurer%0A                    .inMemory()%0A                    .withClient(%22clientauthcode%22)%0A                    .secret(%22123456%22)%0A                    .authorizedGrantTypes(%22authorization_code%22, %22refresh_token%22)%0A                    .scopes(%22read%22, %22write%22)%0A                    .resourceIds(RESOURCE_ID)%0A                    .and()%0A                    .withClient(%22clientcred%22)%0A                    .secret(%22123456%22)%0A                    .authorizedGrantTypes(%22client_credentials%22)%0A                    .scopes(%22trust%22)%0A                    .resourceIds(RESOURCE_ID)%0A                    .and()%0A                    .withClient(%22clientapp%22)%0A                    .secret(%22123456%22)%0A                    .authorizedGrantTypes(%22password%22)%0A                    .scopes(%22read%22, %22write%22)%0A                    .resourceIds(RESOURCE_ID)%0A                    .and()%0A                    .withClient(%22angularClient%22)%0A                    .secret(%22angularPassword%22)%0A                    .authorizedGrantTypes(%22implicit%22)%0A                    .scopes(%22read%22, %22write%22)%0A                    .resourceIds(RESOURCE_ID)%0A                    .authorities(%22CLIENT%22)%0A                    .redirectUris(%22http://localhost:20000/implicit-client/%22)%0A                    .accessTokenValiditySeconds(60 * 60 * 24) // token berlaku seharian, besok harus login ulang%0A                    .autoApprove(true);%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

Add Oauth2 Config