Skip to content

Commit aac4052

Browse files
mrzzyOleksii Moskalenko
authored andcommitted
Add WebSecurityConfig to Serving to disable for /metrics and /actuator endpoints
1 parent 55ee29a commit aac4052

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright 2018-2020 The Feast Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package feast.serving.config;
18+
19+
import org.springframework.context.annotation.Configuration;
20+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
21+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
22+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
23+
24+
/**
25+
* WebSecurityConfig disables auto configuration of Spring HTTP Security and allows security methods
26+
* to be overridden
27+
*/
28+
@Configuration
29+
@EnableWebSecurity
30+
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
31+
32+
/**
33+
* Allows for custom web security rules to be applied.
34+
*
35+
* @param http {@link HttpSecurity} for configuring web based security
36+
* @throws Exception
37+
*/
38+
@Override
39+
protected void configure(HttpSecurity http) throws Exception {
40+
41+
// Bypasses security/authentication for the following paths
42+
http.authorizeRequests()
43+
.antMatchers("/actuator/**", "/metrics/**")
44+
.permitAll()
45+
.anyRequest()
46+
.authenticated()
47+
.and()
48+
.csrf()
49+
.disable();
50+
}
51+
}

0 commit comments

Comments
 (0)