我按照https://dzone.com/articles/build-an-oauth-20-authorization-server-with-spring的说明创建了一个带有okta应用程序的spring-boot示例>
当我在本地网络(没有任何网络代理)中运行应用程序时,它可以正常工作。
它重定向到了我的okta登录页面,成功登录后,它也显示了我的主页。
但是当我在测试环境(使用网络代理)中运行相同的构建时,它显示的是404页而不是我的主页。
它重定向到我的okta登录页面,并在成功登录后重定向到我的主页,但它显示的不是404页面,而是主页。>
注意:同一版本在我的本地环境中运行良好,但是当我在具有代理设置的测试环境中运行时,如果成功登录okta,它将显示404页而不是主页。
这是我的代码库: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>
我按照https://dzone.com/articles/build-an-oauth-20-authorization-server-with-spring中的说明创建了一个带有okta应用程序的示例spring-boot。 ..
成功登录后,Okta将请求重定向回登录后重定向网址。似乎在您的情况下,您已经将localhost配置为您的重定向URL,但是在测试环境中,情况并非如此。