package com.ningdatech.carapi.user.security.auth;

import com.ningdatech.basic.factory.PropertySourceFactory;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author LiuXinXin
 * @Date 2020/8/1 6:06 下午
 * @Version 1.0
 **/
@Configuration
@PropertySource(value = "classpath:security/auth-${spring.profiles.active}.yml"
        , encoding = "utf-8", factory = PropertySourceFactory.class)
@ConfigurationProperties(prefix = "security.auth")
@Component
@Data
public class AuthProperties {

    private String authRequireUrl;

    private String invalidSessionUrl;

    private String passwordLoginUrl;

    private String logoutUrl;

    private List<String> ignoreAuthUrls;

    private List<String> ignoreCsrfUrls;

    public String[] getIgnoreAuthUrlsArray() {
        String[] stringArray = new String[ignoreAuthUrls.size()];
        return ignoreAuthUrls.toArray(stringArray);
    }

    public String[] getIgnoreCsrfUrlsArray() {
        String[] stringArray = new String[ignoreCsrfUrls.size()];
        return ignoreCsrfUrls.toArray(stringArray);
    }
}
