package com.rizki.mufrizal.spring.oauth2.custom.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 *
 * @Author Rizki Mufrizal <mufrizalrizki@gmail.com>
 * @Web <https://RizkiMufrizal.github.io>
 * @Since Jan 30, 2017
 * @Time 1:17:05 PM
 * @Encoding UTF-8
 * @Project Spring-OAuth2-Custom
 * @Package com.rizki.mufrizal.spring.oauth2.custom.configuration
 *
 */
@Configuration
@EnableWebSecurity(debug = true)
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
        authenticationManagerBuilder
                .inMemoryAuthentication()
                .withUser("admin")
                .password("admin")
                .roles("ADMIN");
    }

    @Bean
    @Override
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }

}

@@ -57,16 +57,152 @@
 ation;%0A%0A
+import com.rizki.mufrizal.spring.oauth2.custom.service.impl.UserService;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -245,16 +245,16 @@
 n.Bean;%0A
-
 import o
@@ -783,16 +783,158 @@
 Adapter;
+%0Aimport org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;%0Aimport org.springframework.security.crypto.password.PasswordEncoder;
 %0A%0A/**%0A *
@@ -1373,16 +1373,177 @@
 pter %7B%0A%0A
+    @Autowired%0A    private UserService userService;%0A%0A    @Bean%0A    public PasswordEncoder passwordEncoder() %7B%0A        return new BCryptPasswordEncoder();%0A    %7D%0A%0A
     @Ove
@@ -1713,133 +1713,90 @@
    .
-inMemoryAuthentication()%0A                .withUser(%22admin%22)%0A                .password(%22admin%22)%0A                .roles(%22ADMIN%22
+userDetailsService(userService)%0A                .passwordEncoder(passwordEncoder()
 );%0A 

add web security configuration