Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package org.patinanetwork.codebloom.api.auth.security;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

Expand All @@ -20,7 +16,6 @@
* @see <a href= "https://github.com/tahminator/codebloom/tree/main/docs/auth.md">Authentication Documentation</a>
*/
@Configuration
@EnableConfigurationProperties(SecurityActuatorProperties.class)
@EnableWebSecurity
public class SecurityConfig {

Expand All @@ -30,29 +25,6 @@ public SecurityConfig(final AuthenticationSuccessHandler customAuthenticationSuc
this.customAuthenticationSuccessHandler = customAuthenticationSuccessHandler;
}

@Bean
UserDetailsService userDetailsService(SecurityActuatorProperties props) {
return new InMemoryUserDetailsManager(User.withUsername(props.username())
.password("{noop}" + props.password())
.roles("ACTUATOR")
.build());
}

/**
* Security filter chain for actuator endpoints with HTTP Basic authentication. This needs to be processed first
* (Order 1) to prevent OAuth from being applied.
*/
@Bean
@Order(1)
public SecurityFilterChain actuatorSecurityFilterChain(final HttpSecurity http) throws Exception {
http.securityMatcher("/actuator/**")
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth.anyRequest().hasRole("ACTUATOR"))
.httpBasic(basic -> {});

return http.build();
}

@Bean
@Order(2)
SecurityFilterChain embedSecurity(HttpSecurity http) throws Exception {
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ management:
prometheus:
enabled: true

security:
actuator:
username: ${ACTUATOR_USERNAME}
password: ${ACTUATOR_PASSWORD}

secret:
key: ${SECRET_KEY}

Expand Down
Loading