Das habe ich hier getan
Code: Select all
@Bean
public AnnotationTemplateExpressionDefaults annotationTemplateExpressionDefaults(){
return new AnnotationTemplateExpressionDefaults();
}
Code: Select all
@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize(value = "hasAnyRole({roles})")
public @interface HasAnyRole {
String[] roles();
}
Code: Select all
@PostMapping("/create")
@HasAnyRole(roles = {"'MANAGING_DIRECTOR'","'OPERATIONS_MANAGER'","'PROJECT_MANAGER'"})
public ResponseEntity createProject(@Valid @RequestBody ProjectCreationRequest projectCreationRequest)
throws ProjectNotCreatedException{
return projectService.generateProjectCreationRequest(projectCreationRequest);
}
Code: Select all
Failed to evaluate expression 'hasAnyRole({roles})'"
Meine Frage ist, was mache ich falsch, weil ich der Dokumentation gefolgt bin und immer noch nicht das gewünschte Ergebnis erhalten habe