【问题标题】:How to pass HTTP URL to the antMacher如何将 HTTP URL 传递给 antMacher
【发布时间】:2019-06-20 07:20:06
【问题描述】:

我试过了:

http.requestMatcher(new NegatedRequestMatcher(new AntPathRequestMatcher("http://domainnamea.com/**")));
        http.antMatcher("http://domainnamea.com/**");

我得到了错误:

defaultTarget must start with '/' or with 'http(s)'

我有两个域名,需要为此配置两个单独的自定义身份验证提供程序类。

如何将 URL 传递给 antMacher

【问题讨论】:

    标签: spring-boot spring-security oauth-2.0


    【解决方案1】:

    你可以简单地使用:

    .antMatchers("/register")
    Or with multiple:
    
    .antMatchers("/register","/login","/user","/admin")
    We also specify individual pages or directories –
    
    .antMatchers("register.html"); // Individual
    .antMatchers("/admin/**"); // Directory
    

    【讨论】:

    • 是的,我知道这一点,但我的源配置为域名为 domaina.com 和 domainb.com 我需要根据域名更改配置,domaina.comdomainb.com,can 我这样做?
    • 如果你的域有认证,你可以使用http.cors();
    • @A.perera 不,你不能这样做。如果你想对不同的域名应用不同的安全规则,你将不得不使用代理服务器(例如,Nginx),它将一个域名与一个上下文路径相关联,而另一个与另一个相关联。
    猜你喜欢
    • 1970-01-01
    • 2015-08-31
    • 2018-05-17
    • 1970-01-01
    • 2018-02-12
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 2013-05-18
    相关资源
    最近更新 更多