package com.pandoli365.bibimbap.config;

import com.pandoli365.bibimbap.security.RbacInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private final RbacInterceptor rbacInterceptor;

    public InterceptorConfig(RbacInterceptor rbacInterceptor) {
        this.rbacInterceptor = rbacInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 잼 관리(/admin/jams/**)는 ADMIN 전용 인터셉터 대신 JamAdminController 의 GAME_JAM_MANAGE 게이트 헬퍼로 보호한다(SUBADMIN+키 통과 허용, D4-A).
        registry.addInterceptor(rbacInterceptor)
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/jams/**");
    }
}
