In our app spring security uses ldap as a provider.
i am working on a change that will let you flip a flag in dev that will allow you to log in if your user/pass matches a value from database. the ldap server might be down and you can still log in.
What ive realized though is that some urls are secured with
@Secured( {"ROLE_USER","ROLE_MERCHANT"})
so i need to still have some dealings with spring security in order for my logins to work. How do i go about doing this?
You can configure 2 providers: one LDAP provider and another DAO provider.
If the LDAP fails, it will fall back to DAO authentication provider.
You will need to configure your own authentication filter to inject that flag into
yourDaoAuthenticationProviderso that when the authentication falls back toyourDaoAuthenticationProvider, it can check whether to proceed with further authentication (say, in development) or ignore it (say, in production). So, in yourauthenticationFilter, overridesetDetails()to store the flag:-myAuthenticationFilter bean
With this, have your
yourDaoAuthenticationProviderto check against this flag before proceeding with further authentication.In the end, your configuration will look something like this:-