Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

539
Vistas
¿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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda