vue调用接口修改密码_vue-element添加修改密码弹窗

这篇博客详细介绍了如何在Vue应用中调用接口来实现用户修改密码的功能。通过配置Spring Security,允许无权限访问特定的修改密码URL,并启用JWT过滤器进行身份验证。在WebSecurityConfig中,禁用了CSRF并定义了登录、登出处理以及添加了JWT认证过滤器,确保了安全性。
摘要由CSDN通过智能技术生成

import com.vuebg.admin.security.JwtAuthenticationFilter;

import com.vuebg.admin.security.JwtAuthenticationProvider;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.http.HttpMethod;

import org.springframework.security.authentication.AuthenticationManager;

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.core.userdetails.UserDetailsService;

import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;/**

* Spring Security Config

* @author

* @date 2018-12-12*/@Configuration

@EnableWebSecurity

@EnableGlobalMethodSecurity(prePostEnabled= true)public classWebSecurityConfig extends WebSecurityConfigurerAdapter {

@AutowiredprivateUserDetailsService userDetailsService;

@Overridepublic voidconfigure(AuthenticationManagerBuilder auth) throws Exception {//使用自定义身份验证组件

auth.authenticationProvider(newJwtAuthenticationProvider(userDetailsService));

}/**

* 添加不需要进行权限验证的url

* @param http

* @throws Exception*/@Overrideprotected voidconfigure(HttpSecurity http) throws Exception {//禁用 csrf, 由于使用的是JWT,我们这里不需要csrf

http.cors().and().csrf().disable()

.authorizeRequests()//跨域预检请求

.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()...//修改密码

.antMatchers("/user/pwdupd").permitAll()//其他所有请求需要身份认证

.anyRequest().authenticated();//退出登录处理器

http.logout().logoutSuccessHandler(newHttpStatusReturningLogoutSuccessHandler());//token验证过滤器

http.addFilterBefore(new JwtAuthenticationFilter(authenticationManager()), UsernamePasswordAuthenticationFilter.class);

}

@Bean

@OverridepublicAuthenticationManager authenticationManager() throws Exception {returnsuper.authenticationManager();

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值