Q:

How to use @Autowired in not Spring's stereotype classes

I would like to use that repository in this class, but when I put a stereotype like @Component, I get an error from the IDE:

Could not autowire. No beans of 'Authentication' type found.

public class CustomMethodSecurityExpressionRoot extends SecurityExpressionRoot implements MethodSecurityExpressionOperations {

    @Autowired
    private FlatRepository flatRepository;

    public CustomMethodSecurityExpressionRoot(Authentication authentication) {
        super(authentication);
     }
}

A:

You cannot @Autowire inside a SecurityExpressionRoot.
You can however manually provide that FlatRepository dependency.
As you're configuring your Security objects inside a @Configuration class, there you're able to @Autowire any instance you need.
Simply make space for that new dependency in CustomMethodSecurityExpressionRoot  constructor
class CustomMethodSecurityExpressionRoot extends SecurityExpressionRoot 
                                         implements MethodSecurityExpressionOperations {
    private final FlatRepository flatRepository;

    CustomMethodSecurityExpressionRoot(
            final Authentication authentication,
            final FlatRepository flatRepository) {
        super(authentication);
        this.flatRepository = flatRepository;
    }

    ...
}

And manually inject it at instantiation point
final SecurityExpressionRoot root = new CustomMethodSecurityExpressionRoot(authentication, flatRepository);

