Tiếp theo bài trước: Add Security (Login Page) to Angular Spring Boot App.
Thêm class sau để dùng basic auth với user nam và pass cài ở application.properties
package com.example.springangularfrontendserver.config;
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.web.SecurityFilterChain;
@Configuration
public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((authz) -> authz
.anyRequest().authenticated()
)
.httpBasic(Customizer.withDefaults());
return http.build();
}
}
I do not know if it’s just me or if everyone else encountering issues with your site.
It appears like some of the written text on your posts
are running off the screen. Can someone else please comment and let me know if
this is happening to them too? This could be a problem
with my internet browser because I’ve had this happen previously.
Cheers