为什么字符“;”在OAuth2

时间:2019-04-16 08:51:02

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

有些授权服务器(UAA)以及资源服务器和网关应用程序已正常运行。身份验证的场景为authorization_code。认证后的第一次,请求的末尾被添加;jesessionid=[value],由于请求中包含HttpFirewall,因此其结果是Gateway应用程序的';'的异常。
我的问题是,这是什么?为什么在请求末尾添加jessionid?以及如何与HttpFirewall相适应。
我已经找到了解决方法,但是我知道它存在一些风险。就像这样:

@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirwall() {
    StrictHttpFirewall firewall = new StrictHttpFirewall();
    firewall.setAllowSemicolon(true);
    return firewall;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .csrf()
            .disable()
            .headers().cacheControl().disable()
            .and()
            .headers()
            .cacheControl()
            .disable()
            .frameOptions()
            .sameOrigin()
            .and()
            .httpBasic().disable()
            .authorizeRequests()
            .requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()
            .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
            .mvcMatchers("/uaa/**", "/login**", "/favicon.ico", "/error**").permitAll()
            .anyRequest().authenticated()
            .and()
            .logout()
            .permitAll();
}

@Override
public void configure(WebSecurity web) throws Exception {
    super.configure(web);
    web.httpFirewall(allowUrlEncodedSlashHttpFirwall());
}

如上配置,;被跳过,但是不正确,存在一定风险。

解决此问题的正确方法和配置是什么?

0 个答案:

没有答案