是否可以在OAuth for Spring Security中自定义/ oauth / user / authorize路径?
该路径在org.springframework.security.oauth2.provider.verification.VerificationCodeFilter类中配置,但我找不到定义自定义过滤器或以其他方式更改此路径的方法。
我正在使用OAuth2协议和OAuth版本1.0.0.M3进行Spring Security。
答案 0 :(得分:0)
你必须使用一个众所周知的hack来自定义未在命名空间配置中公开的bean属性 - 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;
}
}