Spring Security блокирует все запросы. Код ответа 401

Разрабатываю Spring приложение, реализующее rest api. У меня возникли проблемы после создания файла конфигурации spring security.

src/main/resources/config/CustomSecurityConfiguration.kt:

package config

import org.springframework.context.annotation.Bean
import org.springframework.http.HttpMethod
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.core.userdetails.User
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.provisioning.InMemoryUserDetailsManager
import org.springframework.security.web.SecurityFilterChain


@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true)
public class SecurityConfig {

    @Bean
    fun userDetailsService(bCryptPasswordEncoder: BCryptPasswordEncoder?): UserDetailsService? {
        val manager = InMemoryUserDetailsManager()
        if (bCryptPasswordEncoder != null) {
            manager.createUser(
                User.withUsername("user")
                    .password(bCryptPasswordEncoder.encode("userPass"))
                    .roles("USER")
                    .build()
            )
        }
        if (bCryptPasswordEncoder != null) {
            manager.createUser(
                User.withUsername("admin")
                    .password(bCryptPasswordEncoder.encode("adminPass"))
                    .roles("USER", "ADMIN")
                    .build()
            )
        }
        return manager
    }

    @Bean
    @Throws(Exception::class)
    fun authManager(
        http: HttpSecurity,
        bCryptPasswordEncoder: BCryptPasswordEncoder?,
        userDetailService: UserDetailsService?
    ): AuthenticationManager? {
        return http.getSharedObject(AuthenticationManagerBuilder::class.java)
            .userDetailsService(userDetailsService(bCryptPasswordEncoder))
            .passwordEncoder(bCryptPasswordEncoder)
            .and()
            .build()
    }


    @Bean
    @Throws(Exception::class)
    fun filterChain(http: HttpSecurity): SecurityFilterChain? {
        http.csrf()
            .disable()
            .authorizeRequests()
            .antMatchers(HttpMethod.DELETE)
            .hasRole("ADMIN")
            .antMatchers("/admin/**")
            .hasAnyRole("ADMIN")
            .antMatchers("/user/**")
            .hasAnyRole("USER", "ADMIN")
            .antMatchers("/signup")
            .anonymous()
            .anyRequest()
            .authenticated()
            .and()
            .httpBasic()
            .and()
            .csrf().disable()
            .cors()
        return http.build()
    }

}

Теперь на каждый мой запрос я получаю ответ с кодом 401, что логично. Однако, когда я перехожу по роуту для регистрации (/api/auth/signup) я так же получаю 401 не смотря на то, что к этому роуту применяется permitAll(). После этого я заменил .antMatchers(HttpMethod.POST, "/api/auth/signup").permitAll() на .antMatchers("/**").permitAll(). Я ожидал что теперь любые запросы, по роутам начинающиеся на /, будут разрешены... Но, увы, я снова увидел код 401.

Проблема кажется тривиальной, но к сожалению, моих знаний Spring и Kotlin/Java не хватает для ее решения((

src/main/resources/application.yml

server:
  port: 1232

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/kissing_company
    username: admin
    password: admin
    driver-class-name: org.postgresql.Driver
  jpa:
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQL10Dialect
    hibernate:
      ddl-auto: update
    properties:
      hibernate.format_sql: true
      hibernate.jdbc.lob.non_contextual_creation: true
  liquibase:
    change-log: classpath:/db/changelog/changelog.yml
    enabled: false

security:
  enable:
      csrf: false

logging:
  level:
    org:
      springframework:
        security: DEBUG


Буду благодарен, если кто-то поможет.

Ссылка на проект

Пример запроса: curl --location --request POST 'http://localhost:1232/signup' \ --header 'Content-Type: application/json' \ --data-raw '{ "username": "user1", "fname": "Николь", "sname": "Дэниелс", "password": "123" }'


Ответы (0 шт):