广告
返回顶部
首页 > 资讯 > 精选 >Spring Security如何实现登录验证
  • 421
分享到

Spring Security如何实现登录验证

2023-06-26 04:06:28 421人浏览 薄情痞子
摘要

这篇文章主要讲解了“spring Security如何实现登录验证”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Spring Security如何实现登录验证”吧!一、理

这篇文章主要讲解了“spring Security如何实现登录验证”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Spring Security如何实现登录验证”吧!

一、理论知识

我们先思考一下这个流程大致是如何的?

  • 填写邮件号码,获取验证码

  • 输入获取到的验证码进行登录(登录的接口:/email/login,这里不能使用默认的/login,因为我们是扩展)

  • 在自定义的过滤器 EmailCodeAuthenticationFilter 中获取发送过来的邮件号码及验证码,判断验证码是否正确,邮件账号是否为空等

  • 封装成一个需要认证的 Authentication ,此处我们自定义实现为 EmailCodeAuthenticationToken。

  • 将 Authentiction 传给 AuthenticationManager 接口中 authenticate 方法进行认证处理

  • AuthenticationManager 默认是实现类为 ProviderManager ,ProviderManager 又委托给 AuthenticationProvider 进行处理

  • 我们自定义一个 EmailCodeAuthenticationProvider 实现 AuthenticationProvider ,实现身份验证。

  • 自定义的 EmailCodeAuthenticationFilter 继承了 AbstractAuthenticationProcessingFilter 抽象类, AbstractAuthenticationProcessingFilter 在 successfulAuthentication 方法中对登录成功进行了处理,通过 SecurityContextHolder.getContext().setAuthentication() 方法将 Authentication 认证信息对象绑定到 SecurityContext即安全上下文中。

  • 其实对于身份验证通过后的处理,有两种方案,一种是直接在过滤器重写successfulAuthentication,另外一种就是实现AuthenticationSuccesshandler来处理身份验证通过。

  • 身份验证失败也是一样,可重写unsuccessfulAuthentication方法,也可以实现 AuthenticationFailureHandler来对身份验证失败进行处理。

大致流程就是如此。从这个流程中我们可以知道,需要重写的组件有以下几个:

  • EmailCodeAuthenticationFilter:邮件验证登录过滤器

  • EmailCodeAuthenticationToken:身份验证令牌

  • EmailCodeAuthenticationProvider:邮件身份认证处理

  • AuthenticationSuccessHandler:处理登录成功操作

  • AuthenticationFailureHandler:处理登录失败操作

接下来,我是模仿着源码写出我的代码,建议大家可以在使用的时候,多去看看,我这里去除了一些不是和这个相关的代码。

来吧!!

二、EmailCodeAuthenticationFilter

我们需要重写的 EmailCodeAuthenticationFilter,实际继承了AbstractAuthenticationProcessingFilter抽象类,我们不会写,可以先看看它的默认实现UsernamePassWordAuthenticationFilter是怎么样的吗,抄作业这是大家的强项的哈。

public class UsernamePasswordAuthenticationFilter extends AbstractAuthenticationProcessingFilter {        public static final String SPRING_SECURITY_FORM_USERNAME_KEY = "username";    public static final String SPRING_SECURITY_FORM_PASSWORD_KEY = "password";    private static final AntPathRequestMatcher DEFAULT_ANT_PATH_REQUEST_MATCHER = new AntPathRequestMatcher("/login",            "POST");    //从前台传过来的参数    private String usernameParameter = SPRING_SECURITY_FORM_USERNAME_KEY;    private String passwordParameter = SPRING_SECURITY_FORM_PASSWORD_KEY;    private boolean postOnly = true;        //  初始化一个用户密码 认证过滤器  默认的登录uri 是 /login 请求方式是POST    public UsernamePasswordAuthenticationFilter() {        super(DEFAULT_ANT_PATH_REQUEST_MATCHER);    }    public UsernamePasswordAuthenticationFilter(AuthenticationManager authenticationManager) {        super(DEFAULT_ANT_PATH_REQUEST_MATCHER, authenticationManager);    }        @Override    public Authentication attemptAuthentication(httpservletRequest request, HttpServletResponse response)            throws AuthenticationException {        if (this.postOnly && !request.getMethod().equals("POST")) {            throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());        }        String username = obtainUsername(request);        username = (username != null) ? username : "";        username = username.trim();        String password = obtainPassword(request);        password = (password != null) ? password : "";        //生成 UsernamePasswordAuthenticationToken 稍后交由AuthenticationManager中的authenticate进行认证        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);        // 可以放一些其他信息进去        setDetails(request, authRequest);        return this.getAuthenticationManager().authenticate(authRequest);    }    @Nullable    protected String obtainPassword(HttpServletRequest request) {        return request.getParameter(this.passwordParameter);    }    @Nullable    protected String obtainUsername(HttpServletRequest request) {        return request.getParameter(this.usernameParameter);    }    protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) {        authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));    }    //set、get方法}

接下来我们就抄个作业哈:

package com.crush.security.auth.email_code;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.security.authentication.AuthenticationManager;import org.springframework.security.authentication.AuthenticationServiceException;import org.springframework.security.core.Authentication;import org.springframework.security.core.AuthenticationException;import org.springframework.security.WEB.authentication.AbstractAuthenticationProcessingFilter;import org.springframework.security.web.util.matcher.AntPathRequestMatcher;import org.springframework.security.web.util.matcher.RequestMatcher;import javax.servlet.FilterChain;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.IOException;import java.util.ArrayList;public class EmailCodeAuthenticationFilter  extends AbstractAuthenticationProcessingFilter {        private final String DEFAULT_EMAIL_NAME="email";    private final String DEFAULT_EMAIL_CODE="e_code";    @Autowired    @Override    public void setAuthenticationManager(AuthenticationManager authenticationManager) {        super.setAuthenticationManager(authenticationManager);    }        private boolean postOnly = true;        public EmailCodeAuthenticationFilter() {        super(new AntPathRequestMatcher("/email/login","POST"));    }        @Override    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {        if(postOnly && !request.getMethod().equals("POST") ){            throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());        }else{            String email = getEmail(request);            if(email == null){                email = "";            }            email = email.trim();            //如果 验证码不相等 故意让token出错 然后走springsecurity 错误的流程            boolean flag = checkCode(request);            //封装 token            EmailCodeAuthenticationToken token = new EmailCodeAuthenticationToken(email,new ArrayList<>());            this.setDetails(request,token);            //交给 manager 发证            return this.getAuthenticationManager().authenticate(token);        }    }        public void setDetails(HttpServletRequest request , EmailCodeAuthenticationToken token ){        token.setDetails(this.authenticationDetailsSource.buildDetails(request));    }        public String getEmail(HttpServletRequest request ){        String result=  request.getParameter(DEFAULT_EMAIL_NAME);        return result;    }        public boolean checkCode(HttpServletRequest request ){        String code1 = request.getParameter(DEFAULT_EMAIL_CODE);        System.out.println("code1**********"+code1);        // TODO 另外再写一个链接 生成 验证码 那个验证码 在生成的时候  存进redis 中去        //TODO  这里的验证码 写在Redis中, 到时候取出来判断即可 验证之后 删除验证码        if(code1.equals("123456")){            return true;        }        return false;    }// set、get方法...}

三、EmailCodeAuthenticationToken

我们EmailCodeAuthenticationToken是继承AbstractAuthenticationToken的,按照同样的方式,我们接着去看看AbstractAuthenticationToken的默认实现是什么样的就行了。

public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationToken {    private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;    // 这里指的账号密码哈    private final Object principal;    private Object credentials;        public UsernamePasswordAuthenticationToken(Object principal, Object credentials) {        super(null);        this.principal = principal;        this.credentials = credentials;        setAuthenticated(false);    }        public UsernamePasswordAuthenticationToken(Object principal, Object credentials,            Collection<? extends GrantedAuthority> authorities) {        super(authorities);        this.principal = principal;        this.credentials = credentials;        super.setAuthenticated(true); // must use super, as we override    }    @Override    public Object getCredentials() {        return this.credentials;    }    @Override    public Object getPrincipal() {        return this.principal;    }    @Override    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {        Assert.isTrue(!isAuthenticated,                "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");        super.setAuthenticated(false);    }    @Override    public void eraseCredentials() {        super.eraseCredentials();        this.credentials = null;    }}

日常抄作业哈:

public class EmailCodeAuthenticationToken extends AbstractAuthenticationToken {        private final Object principal;    public EmailCodeAuthenticationToken(Object principal) {        super((Collection) null);        this.principal = principal;        setAuthenticated(false);    }    public EmailCodeAuthenticationToken(Object principal, Collection<? extends GrantedAuthority> authorities) {        super(authorities);        this.principal = principal;        super.setAuthenticated(true);    }    @Override    public Object getCredentials() {        return null;    }    @Override    public Object getPrincipal() {        return this.principal;    }    @Override    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {        if (isAuthenticated) {            throw new IllegalArgumentException("Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");        } else {            super.setAuthenticated(false);        }    }}

这个很简单的哈

四、EmailCodeAuthenticationProvider

自定义的EmailCodeAuthenticationProvider是实现了AuthenticationProvider接口,抄作业就得学会看看源码。我们接着来。

4.1、先看看AbstractUserDetailsAuthenticationProvider,我们再来模仿

AuthenticationProvider 接口有很多实现类,不一一说明了,直接看我们需要看的AbstractUserDetailsAuthenticationProvider, 该类旨在响应 UsernamePasswordAuthenticationToken 身份验证请求。但是它是一个抽象类,但其实就一个步骤在它的实现类中实现的,很简单,稍后会讲到。

在这个源码中我把和检查相关的一些操作都给删除,只留下几个重点,我们一起来看一看哈。

//该类旨在响应UsernamePasswordAuthenticationToken身份验证请求。public abstract class AbstractUserDetailsAuthenticationProvider        implements AuthenticationProvider, InitializingBean, MessageSourceAware {    protected final Log logger = LogFactory.getLog(getClass());    private UserCache userCache = new NullUserCache();    @Override    public Authentication authenticate(Authentication authentication) throws AuthenticationException {        Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication,                () -> this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports",                        "Only UsernamePasswordAuthenticationToken is supported"));        //获取用户名        String username = determineUsername(authentication);        //判断缓存中是否存在        boolean cacheWasUsed = true;        UserDetails user = this.userCache.getUserFromCache(username);        if (user == null) {            cacheWasUsed = false;            try {                // 缓存中没有 通过字类实现的retrieveUser 从数据库进行检索,返回一个 UserDetails 对象                user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication);            }            catch (UsernameNotFoundException ex) {                this.logger.debug("Failed to find user '" + username + "'");                if (!this.hideUserNotFoundExceptions) {                    throw ex;                }                throw new BadCredentialsException(this.messages                        .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));            }            Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");        }        try {            //进行相关检查  因为可能是从缓存中取出来的 并非是最新的            this.preAuthenticationChecks.check(user);            additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication);        }        catch (AuthenticationException ex) {            if (!cacheWasUsed) {                throw ex;            }            // 没有通过检查, 重新检索最新的数据            cacheWasUsed = false;            user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication);            this.preAuthenticationChecks.check(user);            additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication);        }        // 再次进行检查        this.postAuthenticationChecks.check(user);        // 存进缓存中去        if (!cacheWasUsed) {            this.userCache.putUserInCache(user);        }        Object principalToReturn = user;        if (this.forcePrincipalAsString) {            principalToReturn = user.getUsername();        }        //创建一个可信的身份令牌返回        return createSuccessAuthentication(principalToReturn, authentication, user);    }    private String determineUsername(Authentication authentication) {        return (authentication.getPrincipal() == null) ? "NONE_PROVIDED" : authentication.getName();    }        protected Authentication createSuccessAuthentication(Object principal, Authentication authentication,            UserDetails user) {        UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(principal,                authentication.getCredentials(), this.authoritiesMapper.mapAuthorities(user.getAuthorities()));        result.setDetails(authentication.getDetails());        this.logger.debug("Authenticated user");        return result;    }        protected abstract UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)            throws AuthenticationException;    //...        //简而言之:当然有时候我们有多个不同的 `AuthenticationProvider`,它们分别支持不同的 `Authentication`对象,那么当一个具体的 `AuthenticationProvier`传进入 `ProviderManager`的内部时,就会在 `AuthenticationProvider`列表中挑选其对应支持的provider对相应的 Authentication对象进行验证    @Override    public boolean supports(Class<?> authentication) {        return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));    }}

关于 protected abstract UserDetails retrieveUser 的实现,AbstractUserDetailsAuthenticationProvider实现是DaoAuthenticationProvider.

DaoAuthenticationProvider主要操作是两个,第一个是从数据库中检索出相关信息,第二个是给检索出的用户信息进行密码的加密操作。

public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {    private UserDetailsService userDetailsService;        @Override    protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)            throws AuthenticationException {        prepareTimingAttackProtection();        try {            // 检索用户,一般我们都会实现 UserDetailsService接口,改为从数据库中检索用户信息 返回安全核心类 UserDetails            UserDetails loadedUser = this.getUserDetailsService().loadUserByUsername(username);            if (loadedUser == null) {                throw new InternalAuthenticationServiceException(                        "UserDetailsService returned null, which is an interface contract violation");            }            return loadedUser;        }        catch (UsernameNotFoundException ex) {            mitigateAgainstTimingAttack(authentication);            throw ex;        }        catch (InternalAuthenticationServiceException ex) {            throw ex;        }        catch (Exception ex) {            throw new InternalAuthenticationServiceException(ex.getMessage(), ex);        }    }    @Override    protected Authentication createSuccessAuthentication(Object principal, Authentication authentication,            UserDetails user) {        // 判断是否用了密码加密 针对这个点 没有深入 大家好奇可以去查一查这个知识点        boolean upgradeEncoding = this.userDetailsPasswordService != null                && this.passwordEncoder.upgradeEncoding(user.getPassword());        if (upgradeEncoding) {            String presentedPassword = authentication.getCredentials().toString();            String newPassword = this.passwordEncoder.encode(presentedPassword);            user = this.userDetailsPasswordService.updatePassword(user, newPassword);        }        return super.createSuccessAuthentication(principal, authentication, user);    }}

4.2、抄作业啦

看完源码,其实我们如果要重写的话,主要要做到以下几个事情:

重写public boolean supports(Class<?> authentication)方法。

有时候我们有多个不同的 AuthenticationProvider,它们分别支持不同的 Authentication对象,那么当一个具体的 AuthenticationProvier 传进入 ProviderManager的内部时,就会在 AuthenticationProvider列表中挑选其对应支持的 provider 对相应的 Authentication对象进行验证

简单说就是指定AuthenticationProvider验证哪个 Authentication 对象。如指定DaoAuthenticationProvider认证UsernamePasswordAuthenticationToken,

所以我们指定EmailCodeAuthenticationProvider认证EmailCodeAuthenticationToken。

检索数据库,返回一个安全核心类UserDetail。

创建一个经过身份验证的Authentication对象

了解要做什么事情了,我们就可以动手看看代码啦。

@Slf4jpublic class EmailCodeAuthenticationProvider implements AuthenticationProvider {    ITbUserService userService;    public EmailCodeAuthenticationProvider(ITbUserService userService) {        this.userService = userService;    }        @Override    public Authentication authenticate(Authentication authentication) throws AuthenticationException {        if (!supports(authentication.getClass())) {            return null;        }        log.info("EmailCodeAuthentication authentication request: %s", authentication);        EmailCodeAuthenticationToken token = (EmailCodeAuthenticationToken) authentication;        UserDetails user = userService.getByEmail((String) token.getPrincipal());        System.out.println(token.getPrincipal());        if (user == null) {            throw new InternalAuthenticationServiceException("无法获取用户信息");        }        System.out.println(user.getAuthorities());        EmailCodeAuthenticationToken result =                new EmailCodeAuthenticationToken(user, user.getAuthorities());                        result.setDetails(token.getDetails());        return result;    }    @Override    public boolean supports(Class<?> aClass) {        return EmailCodeAuthenticationToken.class.isAssignableFrom(aClass);    }}

五、在配置类中进行配置

主要就是做下面几件事:将过滤器、认证器注入到spring中
将登录成功处理、登录失败处理器注入到Spring中,或者在自定义过滤器中对登录成功和失败进行处理。
添加到过滤链中

    @Bean    public EmailCodeAuthenticationFilter emailCodeAuthenticationFilter() {        EmailCodeAuthenticationFilter emailCodeAuthenticationFilter = new EmailCodeAuthenticationFilter();        emailCodeAuthenticationFilter.setAuthenticationSuccessHandler(myAuthenticationSuccessHandler);        emailCodeAuthenticationFilter.setAuthenticationFailureHandler(myAuthenticationFailureHandler);        return emailCodeAuthenticationFilter;    }    @Bean    public EmailCodeAuthenticationProvider emailCodeAuthenticationProvider() {        return new EmailCodeAuthenticationProvider(userService);    }        @Override    protected void configure(AuthenticationManagerBuilder auth) throws Exception {        auth.userDetailsService(userDetailService).passwordEncoder(passwordEncoder());        //authenticationProvider 根据传入的自定义AuthenticationProvider添加身份AuthenticationProvider 。        auth.authenticationProvider(emailCodeAuthenticationProvider());    }
.and()    .authenticationProvider(emailCodeAuthenticationProvider())    .addFilterBefore(emailCodeAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class)    .authenticationProvider(mobileCodeAuthenticationProvider())    .addFilterBefore(mobileCodeAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class)

感谢各位的阅读,以上就是“Spring Security如何实现登录验证”的内容了,经过本文的学习后,相信大家对Spring Security如何实现登录验证这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!

--结束END--

本文标题: Spring Security如何实现登录验证

本文链接: https://www.lsjlt.com/news/306774.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Spring Security如何实现登录验证
    这篇文章主要讲解了“Spring Security如何实现登录验证”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Spring Security如何实现登录验证”吧!一、理...
    99+
    2023-06-26
  • 详解使用Spring Security进行自动登录验证
    在之前的博客使用SpringMVC创建Web工程并使用SpringSecurity进行权限控制的详细配置方法 中,我们描述了如何配置一个基于SpringMVC、SpringSecurity框架的网站系统。在这篇博客中,我们将继续描述如何使用...
    99+
    2023-05-31
    spring security 登录
  • Spring security如何重写Filter实现json登录
    Spring security 重写Filter实现json登录 在使用SpringSecurity中,大伙都知道默认的登录数据是通过key/value的形式来传递的,默认情况下不支...
    99+
    2022-11-12
  • SpringBoot security安全认证登录如何实现
    本文小编为大家详细介绍“SpringBoot security安全认证登录如何实现”,内容详细,步骤清晰,细节处理妥当,希望这篇“SpringBoot security安全认证登录如何实现”文章能帮助大家解决疑惑,下面跟...
    99+
    2023-07-05
  • Spring Security短信验证码实现详解
    目录需求实现步骤获取短信验证码短信验证码校验过滤器短信验证码登录认证配置类进行综合组装需求 输入手机号码,点击获取按钮,服务端接受请求发送短信 用户输入验证码点击...
    99+
    2022-11-12
  • Spring Security如何实现用户名密码登录
    小编给大家分享一下Spring Security如何实现用户名密码登录,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!引言你在服务端的安全管理使用了 Sp...
    99+
    2023-06-21
  • Spring Security如何实现HTTP认证
    今天小编给大家分享一下Spring Security如何实现HTTP认证的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下...
    99+
    2023-06-30
  • Spring Security如何使用数据库登录认证授权
    本篇文章给大家分享的是有关Spring Security如何使用数据库登录认证授权,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。一、搭建项目环境1、创建 RBAC五张...
    99+
    2023-06-22
  • spring-boot集成spring-security的oauth2如何实现github登录网站
    这篇文章主要为大家展示了“spring-boot集成spring-security的oauth2如何实现github登录网站”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“spring-boot集...
    99+
    2023-05-30
    spring boot oauth2.0
  • Express实现登录验证
    本文实例为大家分享了Express实现登录验证的具体代码,供大家参考,具体内容如下 Express实现的路由登录,这套代码适用于很多场景,特此记录,以备后用。 首先是主文件:serv...
    99+
    2022-11-12
  • spring-security关闭登录框的实现示例
    事情要从同事的一个项目说起,项目中需要集成公司的单点登录系统,但是无论如何都无法跳转到正常的登录页面。相反,却始终跳转到另外一个登录页面。 但是代码却非常简单,简化一下 @Co...
    99+
    2022-11-12
  • Vue如何实现验证码登录
    本文小编为大家详细介绍“Vue如何实现验证码登录”,内容详细,步骤清晰,细节处理妥当,希望这篇“Vue如何实现验证码登录”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。效果展示第一步:创建验证码组件这里是组件的代码...
    99+
    2023-06-29
  • php如何实现验证码登录
    本文操作环境:windows10系统、php 7、thinkpad t480电脑。验证码在我们的日常生活中非常常见,使用验证码有诸多好处,如:防止恶意的破解密码。如一些黑客为了获取到用户信息,通过不同的手段向服务器发送数据,验证猜测用户信息...
    99+
    2017-10-10
    php 验证码
  • javaweb如何实现登录验证码
    这篇文章给大家分享的是有关javaweb如何实现登录验证码的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。使用:Controller:生成验证码@RequestMapping("/user/check.j...
    99+
    2023-05-30
    javaweb
  • 如何用JDBC实现验证登录
    这篇文章主要介绍“如何用JDBC实现验证登录”,在日常操作中,相信很多人在如何用JDBC实现验证登录问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用JDBC实现验证登录”的疑惑有所帮助!接下来,请跟着小编...
    99+
    2023-06-02
  • Java如何实现Token登录验证
    这篇文章主要介绍“Java如何实现Token登录验证”,在日常操作中,相信很多人在Java如何实现Token登录验证问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Java如何实现Token登录验证”的疑惑有所...
    99+
    2023-07-05
  • Spring AOP实现用户登录统一验证功能
    目录一. 用户登陆统一验证功能1.1 用户登录验证的几种方法1.2 创建前端页面1.3 创建登陆方法和欢迎进入方法1.4 自定义一个拦截器1.5 验证拦截功能1.6 小结一. 用户登...
    99+
    2023-01-14
    Spring AOP用户登录统一验证 Spring AOP用户登录验证 Spring AOP用户登录
  • Spring Security配置多个数据源并添加登录验证码的实例代码
    目录1.配置多个数据源2. 添加登录验证码1.配置多个数据源 多个数据源是指在同一个系统中,用户数据来自不同的表,在认证时,如果第一张表没有查找到用户,那就去第二张表中査询,依次类推...
    99+
    2022-11-13
    Spring Security登录验证码 Spring Security配置多个数据源
  • Spring Security实现用户名密码登录详解
    目录环境用户名密码登录E-R图POM依赖配置文件MapperService设计HTMLController启动完整代码环境 JDK 1.8 Spring Boot 2.3.0.REL...
    99+
    2022-11-13
    Spring Security用户名密码登录 Spring Security 密码登录 Spring Security 登录
  • Android实现验证码登录
    本文实例为大家分享了Android实现验证码登录的具体代码,供大家参考,具体内容如下 结果展示 1.导包 1.1在项目的gradle中导入 maven { url "https...
    99+
    2022-11-11
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作