Spring Boot-如何使用2个身份验证提供程序

时间:2019-10-04 12:31:13

标签: spring spring-boot kotlin

我正在尝试使用Kotlin在Spring Boot中使用2个身份验证提供程序:

此方法在一个类中:

ProviderManager

在应用运行后运行调试器时,AuthenticationManagerBuilder只有1个提供程序。不知何故,authenticationProvider没有使用此处添加的两个configure。我验证了自己的AuthenticationManagerBuilder方法正在被调用,并且AuthenticationManagerBuilder在此方法之后有2个身份验证提供程序。

正在执行我在这里所做的设置时发生了某些事情(或者Spring没有使用我已设置的{{1}}。

有人知道为什么吗?

1 个答案:

答案 0 :(得分:0)

我想知道是否正在配置其他安全性或正在加载自动配置。可以尝试在配置中设置import akka.actor.{Actor, ActorLogging, ActorSystem, Props} import akka.http.scaladsl.Http import akka.http.scaladsl.model.{ContentTypes, HttpEntity} import akka.http.scaladsl.server.Directives._ import akka.pattern.ask import akka.stream.ActorMaterializer import akka.util.Timeout import scala.concurrent.duration._ import scala.io.StdIn object WebServer3 { final case object IncAndGet //not a case class anymore class ActorClass extends Actor with ActorLogging { private var number: Int = 0 //inner state must be private and not accessible from outside of an actor def receive = { case IncAndGet => number += 1 context.sender() ! number // send current value back to sender } } def main(args: Array[String]) { implicit val system = ActorSystem("my-system") implicit val materializer = ActorMaterializer() implicit val executionContext = system.dispatcher implicit val timeout: Timeout = 2.seconds val actor1 = system.actorOf(Props[ActorClass], "SimpleActor") val route = path("counter") { get { onComplete((actor1 ? IncAndGet).mapTo[Int]) { number => complete( HttpEntity(ContentTypes.`text/html(UTF-8)`, s"<h1>You visited $number times</h1>")) } } } val bindingFuture = Http().bindAndHandle(route, "localhost", 8080) println(s"Server online at http://localhost:8080/\nPress RETURN to stop...") StdIn.readLine() // let it run until user presses return val _ = bindingFuture .flatMap(_.unbind()) // trigger unbinding from the port } }