houzhongjian
2024-12-03 874287a4c02d0a980d8b97c4a691b4f37ec5e812
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.iailab.framework.security.config;
 
import com.iailab.framework.web.config.WebProperties;
import org.springframework.core.Ordered;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
 
import javax.annotation.Resource;
 
/**
 * 自定义的 URL 的安全配置
 * 目的:每个 Maven Module 可以自定义规则!
 *
 * @author iailab
 */
public abstract class AuthorizeRequestsCustomizer
        implements Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry>, Ordered {
 
    @Resource
    private WebProperties webProperties;
 
    protected String buildAdminApi(String url) {
        return webProperties.getAdminApi().getPrefix() + url;
    }
 
    protected String buildAppApi(String url) {
        return webProperties.getAppApi().getPrefix() + url;
    }
 
    @Override
    public int getOrder() {
        return 0;
    }
 
}