我开发了一个基本的 oauth/oidc 示例,使用 SpringBoot 2.1.7 和 Okta 提供身份验证服务。这是我的 Gradle 依赖项设置以供参考:
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '1.8'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.okta.spring:okta-spring-boot-starter:1.2.1'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
Run Code Online (Sandbox Code Playgroud)
Okta 端的所有元素都已正确配置,并且示例按预期工作。这里几乎是一个“hello world”类型的演示。我想添加一个自定义身份验证提供程序,它在 Spring 提供的所有其他 AuthenticationProvider 之后执行。我已经使用调试器逐步完成了代码,并注意到 Spring 自动配置了几个 AuthenticationProviders。他们是:
我想在第 6 个位置运行我的身份验证提供程序。即使 configure(AuthenticationManagerBuilder …