-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Spring Security config and disable csrf protection
- Loading branch information
Showing
3 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package fi.oph.kitu | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.security.config.Customizer | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity | ||
import org.springframework.security.web.SecurityFilterChain | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
class WebSecurityConfig { | ||
@Bean | ||
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { | ||
http | ||
.csrf { csrf -> csrf.ignoringRequestMatchers("/api/*") } | ||
.authorizeHttpRequests { authorize -> | ||
authorize | ||
.anyRequest() | ||
.authenticated() | ||
}.httpBasic(Customizer.withDefaults()) | ||
.formLogin(Customizer.withDefaults()) | ||
|
||
return http.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters