mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: update SecurityConfig.java to be reused
parent
0f22d6310d
commit
1b4e3f29d8
|
|
@ -49,10 +49,31 @@ public class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
|
// Configure CORS and CSRF
|
||||||
|
configureHttpSecurity(http);
|
||||||
|
|
||||||
|
// Configure authorization rules
|
||||||
|
configureAuthorization(http);
|
||||||
|
|
||||||
|
// Configure HTTP Basic authentication
|
||||||
|
http.httpBasic(httpBasic -> {});
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure CORS and CSRF settings. Can be overridden by subclasses.
|
||||||
|
*/
|
||||||
|
protected void configureHttpSecurity(HttpSecurity http) throws Exception {
|
||||||
http.cors(cors -> cors.disable())
|
http.cors(cors -> cors.disable())
|
||||||
.csrf(csrf -> csrf.disable())
|
.csrf(csrf -> csrf.disable());
|
||||||
.authorizeHttpRequests(auth -> {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure authorization rules for CE. Can be extended by PRO subclass.
|
||||||
|
*/
|
||||||
|
protected void configureAuthorization(HttpSecurity http) throws Exception {
|
||||||
|
http.authorizeHttpRequests(auth -> {
|
||||||
auth.requestMatchers(HttpMethod.GET, RequestMappings.API + "/config/openvidu-publicurl").permitAll()
|
auth.requestMatchers(HttpMethod.GET, RequestMappings.API + "/config/openvidu-publicurl").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, RequestMappings.ACCEPT_CERTIFICATE).permitAll()
|
.requestMatchers(HttpMethod.GET, RequestMappings.ACCEPT_CERTIFICATE).permitAll()
|
||||||
.requestMatchers("/openvidu/**").permitAll() // Allow WebSocket connections
|
.requestMatchers("/openvidu/**").permitAll() // Allow WebSocket connections
|
||||||
|
|
@ -67,10 +88,7 @@ public class SecurityConfig {
|
||||||
} else {
|
} else {
|
||||||
auth.requestMatchers(HttpMethod.GET, RequestMappings.RECORDINGS + "/**").hasRole("ADMIN");
|
auth.requestMatchers(HttpMethod.GET, RequestMappings.RECORDINGS + "/**").hasRole("ADMIN");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.httpBasic(httpBasic -> {});
|
|
||||||
|
|
||||||
return http.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue