0
votes

Is it possible to customize /oauth/user/authorize path in OAuth for Spring Security?

The path is configured in org.springframework.security.oauth2.provider.verification.VerificationCodeFilter class, but I can't find a way to define custom filter or to change this path in other way.

I'm using OAuth2 protocol and version 1.0.0.M3 of OAuth for Spring Security.

1

1 Answers

0
votes

You have to use a well-known hack to customize bean properties not exposed in namespace configuration - the BeanPostProcessor:

@Component
public class VerificationCodeFilterBeanPostProcessor implements BeanPostProcessor {

   private final String filterProcessesUrl = "/your/path/here";

   @Override
   public final Object postProcessAfterInitialization(final Object bean, final String beanName) {
        return bean;
   }

   @Override
   public final Object postProcessBeforeInitialization(final Object bean, final String beanName) {
        if (bean instanceof VerificationCodeFilter) {
            final VerificationCodeFilter filter = (VerificationCodeFilter) bean;
            filter.setFilterProcessesUrl(filterProcessesUrl);
        }
        return bean;
    }
}