Using Spring Security for basic authorization
The Moviee web service uses Spring Security to authenticate users and authorize them to list, get, and rate movies. The Maven Spring Security starter needs to be specified as follows to enable Spring Security in the web service:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> </dependencies>
The Moviee web service uses basic authentication, an authentication mechanism that uses a header named Authorization
with the "Basic "+base64encode(username:password)
value. The following is the Spring Security configuration:
@Configuration @EnableWebFluxSecurity class SecurityConfig { @Bean fun securityWebFilterChain(http : ServerHttpSecurity) : SecurityWebFilterChain { http.authorizeExchange() .pathMatchers("/movies/**") .authenticated() ...