package ink.wgink.login.oauth2.server.config;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import ink.wgink.login.oauth2.server.converter.OAuth2AccessTokenMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @ClassName: OAuth2WebMvcConfigurer
 * @Description: OAuth2配置，该类是为了处理由于使用了Fastjson而不是原本的Jackson所导致的token格式变化
 * @Author: wanggeng
 * @Date: 2021/9/18 1:10 下午
 * @Version: 1.0
 */
@Configuration
public class OAuth2WebMvcConfigurer implements WebMvcConfigurer {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(0, new FastJsonHttpMessageConverter());
        converters.add(0, new OAuth2AccessTokenMessageConverter());
    }

}
