// Path: src/main/java/com/github/segator/proxylive/helper/AuthorityRoles.java
// public enum AuthorityRoles {
//     USER("USER"),
//     SERVICE_ACCOUNT("SERVICE_ACCOUNT"),
//     ALLOW_ENCODING("ENCODE_PULLER"),
//     ADMIN("ADMIN");
//     private String authority;
//     AuthorityRoles(String authority) {
//         this.authority = authority;
//     }
// 
//     public String getAuthority() {
//         return authority;
//     }
// }


import com.github.segator.proxylive.helper.AuthorityRoles;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;
package com.github.segator.proxylive.config;


@Component
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

    private final JWTBasicFilter jwtBasicFilter;
    private final JwtConfiguration jwtConfiguration;

    public WebSecurityConfiguration(JWTBasicFilter jwtBasicFilter, JwtConfiguration jwtConfiguration) {
        this.jwtBasicFilter = jwtBasicFilter;
        this.jwtConfiguration = jwtConfiguration;
    }
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/login","/error","/actuator/**");
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .cors()
                .and()
                .csrf().disable()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                .authorizeRequests(configurer ->
                        configurer
                                .antMatchers("/channel/**","/view/raw","/api/**")
// Path: src/main/java/com/github/segator/proxylive/helper/AuthorityRoles.java
// public enum AuthorityRoles {
//     USER("USER"),
//     SERVICE_ACCOUNT("SERVICE_ACCOUNT"),
//     ALLOW_ENCODING("ENCODE_PULLER"),
//     ADMIN("ADMIN");
//     private String authority;
//     AuthorityRoles(String authority) {
//         this.authority = authority;
//     }
// 
//     public String getAuthority() {
//         return authority;
//     }
// }


// Path: src/main/java/com/github/segator/proxylive/config/WebSecurityConfiguration.java
import com.github.segator.proxylive.helper.AuthorityRoles;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;

package com.github.segator.proxylive.config;


@Component
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

    private final JWTBasicFilter jwtBasicFilter;
    private final JwtConfiguration jwtConfiguration;

    public WebSecurityConfiguration(JWTBasicFilter jwtBasicFilter, JwtConfiguration jwtConfiguration) {
        this.jwtBasicFilter = jwtBasicFilter;
        this.jwtConfiguration = jwtConfiguration;
    }
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/login","/error","/actuator/**");
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .cors()
                .and()
                .csrf().disable()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                .authorizeRequests(configurer ->
                        configurer
                                .antMatchers("/channel/**","/view/raw","/api/**")
                                .hasRole(AuthorityRoles.USER.getAuthority())