【发布时间】:2020-04-08 08:39:54
【问题描述】:
我按照https://dzone.com/articles/build-an-oauth-20-authorization-server-with-spring 的说明使用 okta 应用程序创建了一个示例 spring-boot
当我在本地网络中运行应用程序(没有任何网络代理)时,它运行良好。
它重定向到我的 okta 登录页面,成功登录后它也显示了我的主页。
但是当我在我的测试环境(使用网络代理)中运行相同的构建时,它显示的是 404 页面而不是我的主页。
它重定向到我的 okta 登录页面,成功登录后它重定向到我的主页,但显示的是 404 页面而不是主页
注意:相同的构建在我的本地工作正常,但是当我在代理设置的测试环境中运行时,它显示 404 页面而不是成功登录 okta 时的主页。
这是我的代码库: application.yml
server:
port: 8080
okta:
oauth2:
issuer: https://dev-XXXXXX.okta.com/oauth2/default
client-id: XXXXXX
client-secret: XXXXXX
spring:
thymeleaf:
cache: false
SecurityConfiguration.java
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests()
.antMatchers("/").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login();
}
}
home.html
<html>
<body>
<h1> secured home page </h1>
</body>
</html>
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.baji.okta</groupId>
<artifactId>OktaOAuthClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>OktaOAuthClient</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.okta.spring</groupId>
<artifactId>okta-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity5 -->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
标签: spring-boot spring-security spring-security-oauth2 okta