I have found several questions about similar problems but none of them is exactly my case.
I am using the following class to configure the authentication/authorization in