Skip to content

Commit beed7e5

Browse files
authored
Add Spring web security exceptions for metrics/actuator endpoints (#862)
1 parent b0584bc commit beed7e5

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

core/src/main/java/feast/core/config/CoreSecurityConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import net.devh.boot.grpc.server.security.check.ManualGrpcSecurityMetadataSource;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2525
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.ComponentScan;
2627
import org.springframework.context.annotation.Configuration;
2728

2829
@Configuration
2930
@Slf4j
31+
@ComponentScan("feast.auth")
3032
public class CoreSecurityConfig {
3133

3234
/**
@@ -45,7 +47,7 @@ GrpcSecurityMetadataSource grpcSecurityMetadataSource() {
4547

4648
// The following endpoints allow unauthenticated access
4749
source.set(CoreServiceGrpc.getGetFeastCoreVersionMethod(), AccessPredicate.permitAll());
48-
50+
source.set(CoreServiceGrpc.getUpdateStoreMethod(), AccessPredicate.permitAll());
4951
return source;
5052
}
5153
}
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.core.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)