springsecurity6配置三
springsecurity配置多种登录方式,比如手机验证码登录、邮箱登录、微信小程序登录等,下面就以微信小程序登录为例进行讲解。
一、小程序用户实体实现springsecurity中的UserDetails接口
package com.school.information.core.security.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.school.information.entity.SysWechatUserEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WechatAppUser implements UserDetails {
/**
* 微信小程序返回的session_key
*/
private String sessionKey;
/**
* 小程序的基本信息
*
* @return
*/
private SysWechatUserEntity sysWechatUser;
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
@Ove