java - Provider order using AuthenticationManagerBuilder -
i'm using spring security 4.0.1 , want use multiple authentication providers authentication using java-based configuration. how specify provider order?
i hoping use authenticationmanagerbuilder, since that's websecurityconfigureradapter.configureglobal()
exposes, don't see way specify order. need create providermanager manually?
update: here's problem clarification based on arun's answer. specific providers want use activedirectoryldapauthenticationprovider
, daoauthenticationprovider
custom userservice
.
ultimately i'd authenticate against daoauthenticationprovider
first , activedirectoryldapauthenticationprovider
second.
the ad provider involves call authenticationmanagerbuilder.authenticationprovider()
dao provider involves calling authenticationmanagerbuilder.userservice()
, creates daoauthenticationprovider
around user service behind scenes. looking @ source code, doesn't directly place provider in provider list (it creates configurer), arun's answer isn't working me here.
i tried creating daoauthenticationprovider
manually , passing authenticationprovider()
. didn't impact order.
there no explicit ordering provision. order of invocation order in have provided authenticationprovider
to authenticationmanagerbuilder.authenticationprovider()
. refer here xml configuration. same should apply java config well.
for eg
auth.authenticationprovider(getauthenticationprovider2()); auth.authenticationprovider(getauthenticationprovider1());
will result in following order of invocation authenticationprovider2,authenticationprovider1
and
auth.authenticationprovider(getauthenticationprovider1()); auth.authenticationprovider(getauthenticationprovider2());
will result in following order of invocation authenticationprovider1,authenticationprovider2
Comments
Post a Comment