小编shi*_*ang的帖子

在Spring Boot中禁用特定URL模式的CSRF保护

我使用Spring Boot和Spring Security来创建我的Web项目.我想为特定的URL模式禁用CSRF保护,以便为Android设备提供API.

运用

我写了以下配置:

package com.hnu.tutorial.configs;

import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.util.matcher.RegexRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

import javax.servlet.http.HttpServletRequest;
import java.util.regex.Pattern;

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        CsrfSecurityRequestMatcher crm = new CsrfSecurityRequestMatcher();
        http.csrf().requireCsrfProtectionMatcher(crm).and()
                .authorizeRequests().antMatchers("/**").permitAll().anyRequest().fullyAuthenticated();
//        http.csrf().disable();
    }

    public class CsrfSecurityRequestMatcher implements RequestMatcher {
        private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");
        private RegexRequestMatcher unprotectedMatcher …
Run Code Online (Sandbox Code Playgroud)

csrf spring-security spring-boot

9
推荐指数
2
解决办法
6709
查看次数

与 hive 相比,spark sql 读取表非常慢

我有一个 Hive 表,大约有 2500 列,当我通过 Spark sql 读取它时,如下所示:

val df = spark.sql("select * from dbName.tableName")
Run Code Online (Sandbox Code Playgroud)

大约需要3个小时才能读完hive表,而我使用hive sql来读取这个表,它只表了我大约几秒钟。

有谁知道为什么spark sql和hive sql的性能差异如此之大?多谢!

hive apache-spark apache-spark-sql

2
推荐指数
1
解决办法
2120
查看次数