Skip to content

Commit

Permalink
WIP for removing GUI related functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 16, 2025
1 parent 53f5dbf commit 1132048
Show file tree
Hide file tree
Showing 20 changed files with 11 additions and 1,004 deletions.
13 changes: 0 additions & 13 deletions src/main/java/pdp/PdpApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import pdp.policies.PolicyLoader;
import pdp.repositories.PdpPolicyRepository;
import pdp.sab.SabClient;
import pdp.stats.StatsContextHolder;
import pdp.teams.VootClient;
import pdp.web.SessionAliveInterceptor;
import pdp.xacml.PDPEngineHolder;

import java.io.IOException;
Expand Down Expand Up @@ -66,13 +62,4 @@ public PDPEngineHolder pdpEngine(
return new PDPEngineHolder(pdpPolicyRepository, vootClient, sabClient);
}

@Configuration
public static class WebMvcConfig implements WebMvcConfigurer {

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SessionAliveInterceptor());
}
}

}
14 changes: 0 additions & 14 deletions src/main/java/pdp/WebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.csrf.CsrfFilter;
import pdp.access.BasicAuthenticationProvider;
import pdp.access.PolicyIdpAccessEnforcerFilter;
import pdp.manage.Manage;
import pdp.web.CsrfProtectionMatcher;
import pdp.web.CsrfTokenResponseHeaderBindingFilter;

@Configuration
@EnableWebSecurity
Expand All @@ -38,7 +29,6 @@ public void configureGlobal(AuthenticationManagerBuilder auth) {
BasicAuthenticationProvider basicAuthenticationProvider =
new BasicAuthenticationProvider(policyEnforcementPointUserName, policyEnforcementPointPassword);
auth.authenticationProvider(basicAuthenticationProvider);

}

@Configuration
Expand All @@ -62,10 +52,6 @@ protected void configure(HttpSecurity http) throws Exception {
.and()
.csrf()
.disable()
.addFilterBefore(
new PolicyIdpAccessEnforcerFilter(authenticationManager(), manage),
BasicAuthenticationFilter.class
)
.authorizeRequests()
.antMatchers("/protected/**", "/decide/policy", "/manage/**")
.hasAnyRole("PEP", "ADMIN");
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/pdp/access/BasicAuthenticationProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.Collection;

import static org.springframework.security.core.authority.AuthorityUtils.createAuthorityList;
import static org.springframework.util.Assert.notNull;
import static pdp.access.FederatedUserBuilder.apiAuthorities;

/**
* EngineBlock and Dashboard call the PDP and we don't want to use OAuth for this as
* they are trusted clients
*/
public class BasicAuthenticationProvider implements AuthenticationProvider {

private static final Collection<? extends GrantedAuthority> API_AUTHORITIES = createAuthorityList("ROLE_USER", "ROLE_PEP");


private final String userName;
private final String password;

Expand All @@ -37,9 +43,9 @@ public Authentication authenticate(Authentication authentication) throws Authent
throw new BadCredentialsException("Bad credentials");
}
return new UsernamePasswordAuthenticationToken(
authentication.getPrincipal(),
authentication.getCredentials(),
apiAuthorities);
authentication.getPrincipal(),
authentication.getCredentials(),
API_AUTHORITIES);
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/pdp/access/FederatedUserBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class FederatedUserBuilder {

private static final Collection<? extends GrantedAuthority> shibAuthorities = createAuthorityList("ROLE_USER", "ROLE_ADMIN");

public static final Collection<? extends GrantedAuthority> apiAuthorities = createAuthorityList("ROLE_USER", "ROLE_PEP");

//shib headers
public static final String UID_HEADER_NAME = "uid";
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/pdp/access/PolicyIdpAccessAwareToken.java

This file was deleted.

250 changes: 0 additions & 250 deletions src/main/java/pdp/access/PolicyIdpAccessEnforcer.java

This file was deleted.

Loading

0 comments on commit 1132048

Please sign in to comment.