0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SpringSecurityのlogin画面とかを無効化するコードスニペット

0
Last updated at Posted at 2025-03-20

SpringSecurityの認証を無効化

以下をファイルとして保存するとSpringSecurityの基本認証を無効化することができる。
あとは適当にimportして完成

@Configuration  
@EnableWebSecurity  
class SecurityConfig {  
    @Bean  
    fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {  
        http  
            .authorizeHttpRequests { authorize ->  
                authorize.anyRequest().permitAll() // すべてのリクエストを許可  
            }  
            .formLogin { form ->  
                form.disable() // フォームログインを無効化  
            }  
            .httpBasic { basic ->  
                basic.disable() // HTTP Basic認証を無効化  
            }  
            .csrf { csrf ->  
                csrf.disable() // CSRF保護を無効化  
            }  
            .cors { cors ->  
                cors.disable() // CORS設定を無効化  
            }  
  
        return http.build()  
    }  
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?