com.healthy.common.security.authorize.HealthyAuthorizeConfigProvider Maven / Gradle / Ivy
package com.healthy.common.security.authorize;
import cn.hutool.core.util.StrUtil;
import com.healthy.common.security.properties.SecurityConstants;
import com.healthy.common.security.properties.SecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;
/**
* HealthyAuthorizeConfigProvider
*
* @author xiaomingzhang
*/
@Component
@Order(Integer.MIN_VALUE)
public class HealthyAuthorizeConfigProvider implements AuthorizeConfigProvider {
@Autowired
private SecurityProperties securityProperties;
@Override
public boolean config(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry config) {
config.antMatchers(SecurityConstants.DEFAULT_BASIC_ERROR_CONTROLLER_URL,
SecurityConstants.DEFAULT_UNAUTHENTICATION_URL,
SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_MOBILE,
SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_OPENID,
SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/*",
SecurityConstants.DEFAULT_SOCIAL_USER_INFO_URL,
securityProperties.getBrowser().getSignInPage(),
securityProperties.getBrowser().getSignUpUrl(),
securityProperties.getBrowser().getSession().getSessionInvalidUrl()).permitAll();
if (StrUtil.isNotBlank(securityProperties.getBrowser().getLogOutSuccessUrl())) {
config.antMatchers(securityProperties.getBrowser().getLogOutSuccessUrl()).permitAll();
}
return false;
}
}