java - How to inherit OAuth2AuthenticationProcessingFilter or add custom filter -


i using oauth2 token in rest based api. wanted override oauth2authenticationprocessingfilter can extract token if not provider in header attribute authorization(this provided accesstoken attribute in header long story don't ask why). or if not can tell me how add filter after oauth2authenticationprocessingfilter ?

basically, in xml, use defaults, add resource-server

<oauth:resource-server id="resourceserverfilter"         token-services-ref="tokenservices"         resource-id="myid" /> 

which adds oauth2authenticationmanager , oauth2authenticationprocessingfilter (see https://github.com/spring-projects/spring-security-oauth/blob/ec215f79f4f73f8bb5d4b8a3ff9abe15b3335866/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/config/xml/resourceserverbeandefinitionparser.java details)

then add filter <sec:http> element:

<sec:custom-filter ref="resourceserverfilter" position="pre_auth_filter" /> 

but if need use oauth2authenticationprocessingfilter specialization instead of oauth2authenticationprocessingfilter itself, following:

i. add oauth2authenticationmanager manually:

<bean id="authenticationmanager" class="org.springframework.security.oauth2.config.xml.oauth2authenticationmanager">     <property name="tokenservices" ref="tokenservices"/>     <property name="resourceid" value="myid"/> </bean> 

ii. add filter replacement manually:

<bean id="resourceserverfilter"class="yourfilterimplementationclass">     <property name="authenticationmanager" ref="authenticationmanager"/> </bean> 

iii. insert filter filter chain, usual:

<sec:custom-filter ref="resourceserverfilter" position="pre_auth_filter" /> 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -