springboot 中利用security组件控制登录:通过 ip白名单进行 认证 鉴权

该博客介绍了如何在SpringBoot应用中使用Security组件来实现IP白名单认证。通过添加`spring-boot-starter-security`依赖,创建一个自定义的`AuthenticationProvider`类和配置`WebSecurityConfigurerAdapter`,允许特定IP地址的无感访问和登录访问。示例代码展示了如何设置多个IP地址的白名单,并在认证过程中检查请求的IP是否在白名单内。
摘要由CSDN通过智能技术生成

<!-- 实现白名单的依赖>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-security</artifactId>

</dependency>

第一个类: 验证入口

/*
 * Title:       V100R001C00<br>
 * Description:  [描述模块的功能、作用、使用方法和注意事项]<br>
 * Copyright:    Copyright (c) 1988-2015<br>
 * Company:      
 * @author      
 * @version      
 */
package com.huawei.IpController.controller;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.H

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值