package vn.azteam.tpf.security.apiKey;

import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import vn.azteam.tpf.service.TBCustomerService;

public class ApiKeyConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {

    private final ApiKeyProvider apiKeyProvider;

    public ApiKeyConfigurer (ApiKeyProvider apiKeyProvider) {
        this.apiKeyProvider = apiKeyProvider;
    }

    @Override
    public void configure(HttpSecurity http) {
        ApiKeyFilter apiKeyFilter = new ApiKeyFilter(apiKeyProvider);
        http.addFilterBefore(apiKeyFilter, UsernamePasswordAuthenticationFilter.class);
    }
}
