Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

538
Views
¿Cómo habilitar Spring Security Kotlin DSL?

¿Cómo podemos habilitar el soporte para Spring Security Kotlin DSL?

Como puede ver en la captura de pantalla del IDE (IntelliJ), el DSL no está disponible:

ingrese la descripción de la imagen aquí

Este es el archivo SecurityConfig.kt completo:

 package com.example.backend.core import org.springframework.context.annotation.Bean import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity import org.springframework.security.config.web.server.ServerHttpSecurity import org.springframework.security.web.server.SecurityWebFilterChain @EnableWebFluxSecurity class SecurityConfig { @Bean fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain? { return http { csrf { disable() } formLogin { disable() } httpBasic { disable() } // ... } } }

Este es nuestro build.gradle.kts

 import org.jetbrains.kotlin.gradle.tasks.KotlinCompile val springBootVersion = "2.4.2" plugins { id("org.springframework.boot") version "2.4.2" id("io.spring.dependency-management") version "1.0.11.RELEASE" kotlin("jvm") version "1.4.21" kotlin("plugin.spring") version "1.4.21" } group = "com.example" version = "0.0.1-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_11 configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) } } repositories { mavenCentral() } dependencies { implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server") implementation("org.springframework.boot:spring-boot-starter-oauth2-client") implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") implementation("org.flywaydb:flyway-core") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") developmentOnly("org.springframework.boot:spring-boot-devtools") runtimeOnly("io.micrometer:micrometer-registry-prometheus") runtimeOnly("org.postgresql:postgresql") annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("io.projectreactor:reactor-test") testImplementation("org.springframework.security:spring-security-test") } tasks.withType<KotlinCompile> { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") jvmTarget = "11" } } tasks.withType<Test> { useJUnitPlatform() }

Y esta es la versión intellij:

 IntelliJ IDEA 2020.3 (Community Edition) Build #IC-203.5981.155, built on November 30, 2020 Runtime version: 11.0.9+11-b1145.21 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains sro Linux 5.4.0-64-generic GC: ParNew, ConcurrentMarkSweep Memory: 1979M Cores: 12 Registry: compiler.automake.allow.when.app.running=true Non-Bundled Plugins: Key Promoter X, Dart, io.flutter, Lombook Plugin, org.jetbrains.kotlin Current Desktop: X-Cinnamon

¿Echamos de menos alguna dependencia? ¿Requiere alguna configuración específica de intellij?

over 4 years ago · Hanz Gallego
3 answers
Answer question

0

Noté que su pregunta se refería a WebFlux , pero solo complementaba la respuesta de @Eleftheria.

Para la gente WebMvc , debe importar:

 import org.springframework.security.config.web.servlet.invoke

(servlet vs servidor)

over 4 years ago · Hanz Gallego Report

0

Este DSL está integrado a partir de la versión Spring Security 5.3. Por ejemplo, la biblioteca org.springframework.security:spring-security-config:5.3.4.RELEASE lo tiene: org.springframework.security.config.web.servlet.HttpSecurityDsl#csrf Y, por ejemplo, el

 compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.3.3.RELEASE'

la biblioteca lo contendrá.

over 4 years ago · Hanz Gallego Report

0

Debe importar manualmente la invoke de ServerHttpSecurity .

 import org.springframework.security.config.web.server.invoke

Debido a este problema de Kotlin en 1.4, el IDE no lo sugiere como debería.

Esto está programado para corregirse en Kotlin 1.4.30.

over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!