Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why class SecurityEvaluationContextExtension can not be found in Spring Boot Project?

I have a spring boot based project with following declaration in pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

and following dependencies among others

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

But seems like spring boot is not pulling in SecurityEvaluationContextExtension class on the classpath.

Am I missing a dependency or am I using an older version of spring boot?

EDIT:

I directly added the following dependency in my pom.xml and now I can see the class, but STS is showing warning : "Duplicating managed version 4.0.3.RELEASE for spring-security-data"

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-data</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>       
like image 589
Tahir Akhtar Avatar asked Apr 02 '16 14:04

Tahir Akhtar


People also ask

How do I inject an authentication object into a spring context?

We can use SpEL (Spring Expression Language) with @CurrentSecurityContext to inject the Authentication object or the Principal. SpEL works together with type lookup. The type check is not enforced by default, but we can enable it via the errorOnInvalidType parameter of the @CurrentSecurityContext annotation.

How do I implement @currentsecuritycontext in spring?

Implementing with @CurrentSecurityContext We can use SpEL (Spring Expression Language) with @CurrentSecurityContext to inject the Authentication object or the Principal. SpEL works together with type lookup.

Does Spring Boot have custom error handling for protected APIs?

In the demo application produced in that article, no custom error handling is implemented. So, by making a request to a protected API including a wrong access token, the default Spring Boot error handling logic is applied. Let’s test it out.

What does Spring Boot look for in an error endpoint?

Particularly, Spring Boot looks for a mapping for the / error endpoint during the start-up. This mapping depends on what is set on a ViewResolver class.


1 Answers

I am not shure what you mean with 'spring is not pulling in..' But to use this extension you have to create a bean of this type see SecurityEvaluationContextExtension

EDIT : The warning you are getting is no problem. You can try removing the version from the dependency, because it seems available through dependencyManagement.

like image 71
Stefan Isele - prefabware.com Avatar answered Oct 16 '22 12:10

Stefan Isele - prefabware.com