小编Faz*_*iqi的帖子

Cookie CsrfTokenRepository.withHttpOnlyFalse() 做什么以及何时使用它?

我现在正在尝试学习 Spring Security,并且我已经看到许多使用它的不同示例。我知道 CSRF 是什么,并且 Spring Security 默认启用它。我很想知道的是这种定制。

  .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
  .and()
  .authorizeRequests(request -> {
                request
                    .antMatchers("/login").permitAll()
                    .anyRequest()
                    ....more code
Run Code Online (Sandbox Code Playgroud)

.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())条线做了什么样的定制,什么时候适合使用。如果有人能提供一个简单的解释,我将不胜感激。

java spring csrf spring-security spring-boot

7
推荐指数
1
解决办法
3820
查看次数

Spring Boot 中的 Mapstruct + Lombok 和 Gradle(未找到 Bean)

我正在尝试在 IntelliJ 的 Spring Boot 项目中使用带有 gradle 的 mapstruct 。由于任何原因它都不起作用。

这是我的 build.gradle

plugins {
    id 'org.springframework.boot' version '2.3.1.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_14

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    mavenLocal()

}

ext {
    mapstructVersion = "1.4.0.Beta2"
    lombokVersion = "1.18.12"
}

dependencies {
    compileOnly "org.mapstruct:mapstruct:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
    annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
    runtimeOnly'com.h2database:h2'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', …
Run Code Online (Sandbox Code Playgroud)

intellij-idea gradle lombok spring-boot mapstruct

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