Skip to content

Commit

Permalink
Removing unused permissions evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Wiens committed Jul 15, 2024
1 parent ada122f commit 58f6dbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 79 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper;

import us.dot.its.jpo.ode.api.auth.EndpointPermissionEvaluator;


/**
* Enables security annotations via like {@link org.springframework.security.access.prepost.PreAuthorize} and
Expand All @@ -26,32 +24,34 @@
havingValue = "true") // Allow disabling security
class MethodSecurityConfig {



private final ApplicationContext applicationContext;

private final PermissionEvaluator permissionEvaluator;

@Autowired
public MethodSecurityConfig(ApplicationContext applicationContext) {
public MethodSecurityConfig(PermissionEvaluator permissionEvaluator, ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
this.permissionEvaluator = permissionEvaluator;
System.out.println("Method-level security annotations are enabled");
}

@Bean
MethodSecurityExpressionHandler customMethodSecurityExpressionHandler() {

var expressionHandler = new DefaultMethodSecurityExpressionHandler();
expressionHandler.setApplicationContext(applicationContext);
expressionHandler.setPermissionEvaluator(permissionEvaluator());
expressionHandler.setPermissionEvaluator(permissionEvaluator);
return expressionHandler;
}

@Bean
GrantedAuthoritiesMapper keycloakAuthoritiesMapper() {

var mapper = new SimpleAuthorityMapper();
mapper.setConvertToUpperCase(true);
return mapper;
}

@Bean
public PermissionEvaluator permissionEvaluator() {
return new EndpointPermissionEvaluator();
}

}

0 comments on commit 58f6dbd

Please sign in to comment.