小编Shi*_*mar的帖子

如何从 Spring 环境自动生成邮递员集合

我有一个需求,在何处测试应用程序的性能,我需要应用程序流程中使用的 API 的所有邮递员集合,以实现流程自动化。

我在 baeldung 中看到了这个关于如何生成集合的例子。以类似的方式,如何以邮递员集合的形式获取所有 API 的输出。

我正在使用带有登录、注销和仪表板 JSP 的 Spring MVC Legacy 应用程序和 Rest API。

java spring postman

7
推荐指数
1
解决办法
1825
查看次数

Spring Security MultiHttpSecurity 配置以便我可以执行两种类型的身份验证。JWT 令牌和会话 Cookie

我已经为我的应用程序设置了 Spring Security Cookie 机制,现在仅用于 API,我需要添加基于 JWT 令牌的身份验证机制。我将 Spring Security 的 MultiHttpSecurityConfiguration 与两个嵌套类一起使用。

会话和 JWT 令牌机制是否应该一起包含在一个应用程序中是一个完全不同的问题,我需要实现两件事。

  1. Spring Security 使用 cookie 的基于会话的身份验证将像以前一样工作。
  2. 需要为 API 添加一个身份验证标头
package com.leadwinner.sms.config;

import java.util.Collections;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import com.leadwinner.sms.CustomAuthenticationSuccessHandler;
import com.leadwinner.sms.CustomLogoutSuccessHandler;
import com.leadwinner.sms.config.jwt.JwtAuthenticationProvider;
import com.leadwinner.sms.config.jwt.JwtAuthenticationTokenFilter; …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-security jwt

6
推荐指数
1
解决办法
1259
查看次数

标签 统计

java ×2

spring ×2

jwt ×1

postman ×1

spring-mvc ×1

spring-security ×1