1:添加依赖:

        <dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

2:创建验证service集成UserDetailService

package com.qingwenwei.security;

import java.util.ArrayList;
import java.util.List; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import com.qingwenwei.persistence.model.User;
import com.qingwenwei.service.UserService;
import org.springframework.stereotype.Service;

//授权认证
@Service
public class MyUserDetailsService implements UserDetailsService{ Logger logger = LogManager.getLogger(MyUserDetailsService.class);
@Autowired
private UserService userService; @Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
logger.debug("得到用户");
User user = this.userService.findByUsername(username); //加密之后的密码。才能进行下面的授权认证。
logger.debug(user.getUsername()+"密码"+user.getPassword()); //加密之后的密码。
if(null == user) {
throw new UsernameNotFoundException("Can't find user by username: " + username);
} List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<>();
// grant roles to user
for (String role : user.getRolesSet()) {
logger.debug(role);
grantedAuthorities.add(new SimpleGrantedAuthority(role));
}
// user.setGrantedAuthorities(authorities); //用于登录时 @AuthenticationPrincipal 标签取值
return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), grantedAuthorities);
}
}

3:进行配置

package com.qingwenwei.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
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.crypto.bcrypt.BCryptPasswordEncoder; @Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
} @Autowired
MyUserDetailsService myUserDetailsService;
// @Bean
// UserDetailsService myUserDetailsService() { // register userDetailsService
// return new MyUserDetailsService();
// } @Bean
public AuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
// authenticationProvider.setUserDetailsService(this.myUserDetailsService());
authenticationProvider.setUserDetailsService(myUserDetailsService);
authenticationProvider.setPasswordEncoder(this.bCryptPasswordEncoder());
return authenticationProvider;
} @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { //全局配置
// auth.inMemoryAuthentication() //內存中存在的验证
// .withUser("t").password("t").roles("USER")
// .and()
// .withUser("admin").password("admin").roles("ADMIN"); auth.userDetailsService(myUserDetailsService).passwordEncoder(this.bCryptPasswordEncoder());
// auth.userDetailsService(myUserDetailsService).passwordEncoder(new BCryptPasswordEncoder());
// auth.authenticationProvider(this.authenticationProvider()); // different approach
} @Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/user/settings").authenticated() // order matters
.antMatchers("/", "/js/**", "/css/**","/avatar/**", "/images/**", "/fonts/**", "/bootstrap-select/**", "/bootstrap-datetimepicker/**", "/custom/**", "/daterangepicker/**", "/chartjs/**").permitAll() // these paths are configure not to require any authentication
.antMatchers("/post/**").permitAll() // all posts are allowed to be viewed without authentication
.antMatchers("/user/**").permitAll() // all user profiles are allowed to be viewed without authentication
.antMatchers("/category/**").permitAll() // all categories are allowed to be viewed without authentication
.antMatchers("/user/registration").permitAll()
.antMatchers("/avatar/**").permitAll() // temp
.antMatchers("/avatar1/**").permitAll() // temp
.anyRequest().authenticated() // every request requires the user to be authenticated
.and()
.formLogin()
.loginPage("/user/login")
.permitAll() // login URL can be accessed by anyone
.and()
.logout()
.invalidateHttpSession(true)
.clearAuthentication(true)
.logoutSuccessUrl("/?logout")
.permitAll();
}
}

4:userController.java

package com.qingwenwei.web.controller;

import com.qingwenwei.exception.BadRequestException;
import com.qingwenwei.exception.ResourceNotFoundException;
import com.qingwenwei.persistence.model.User;
import com.qingwenwei.service.UserService;
import com.qingwenwei.util.NewUserFormValidator;
import com.qingwenwei.web.dto.UserRegistrationDto;
import com.qingwenwei.web.dto.UserSettingsDto;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
import java.util.Map; @Controller
public class UserController { Logger logger = LogManager.getLogger(UserController.class);
// private static final Logger logger = LoggerFactory.getLogger(UserController.class); @Autowired
private UserService userService; @Autowired
private NewUserFormValidator userValidator; @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET)
public String showUserProfilePage(@RequestParam(value = "tab", required = false) String tabType,
@PathVariable Long userId, Model model) {
if (null == userId) {
throw new BadRequestException("Path variable userId cound not be null.");
}
Map<String, Object> attributes = this.userService.getUserProfileAndPostsByUserIdByTabType(userId, tabType);
if (null == attributes) {
throw new ResourceNotFoundException("attributes not found.");
}
model.addAllAttributes(attributes);
return "forum/user-profile";
} @RequestMapping(value = "/user/registration", method = RequestMethod.GET)
public String showRegistrationPage(Model model) {
model.addAttribute("userDto", new UserRegistrationDto());
return "forum/user-registration"; //注册页面
} @RequestMapping(value = "/user/registration", method = RequestMethod.POST) //提交注册
public String registerNewUser(@Valid @ModelAttribute("userDto") UserRegistrationDto userDto,
BindingResult bindingResult, Model model, HttpServletRequest request) {
/*
* form validation, check username and email uniqueness
*/
this.userValidator.validate(userDto, bindingResult);
if (bindingResult.hasErrors()) {
logger.info("BindingResult has errors >> " + bindingResult.getFieldError());
return "forum/user-registration";
}
logger.debug("注册"+userDto.getMatchingPassword());
Map<String, Object> attributes = this.userService.registerUserAccount(userDto, request);
if (null == attributes) {
throw new ResourceNotFoundException("attributes not found.");
}
model.addAllAttributes(attributes);
return "forum/user-registration-result";
} @RequestMapping(value = "/user/login", method = RequestMethod.GET)
public String displayLoginPage(Model model) {
logger.debug("user/login登录");
model.addAttribute("title", "用户登陆");
return "forum/user-login"; //登录界面,验证没通过。
} @RequestMapping(value = "/user/login-success", method = RequestMethod.GET)
public String showAdminPage() {
logger.debug("登录成功");
return "forum/user-login";
// return "/";
} @RequestMapping(value = "/confirm", method = RequestMethod.GET)
public String confirmRegistration(@RequestParam("token") String token) {
return "forum/confirmation";
} @RequestMapping(value = "/confirm", method = RequestMethod.POST)
public String processConfirmation() {
return "forum/confirmation";
} @RequestMapping(value = "/user/settings", method = RequestMethod.GET)
public String showUserSettingsPage(Model model) {
Map<String, Object> attributes = this.userService.getUserSettingPage();
if (null == attributes) {
throw new ResourceNotFoundException("attributes not found.");
}
model.addAllAttributes(attributes);
return "forum/user-settings";
} @RequestMapping(value = "/user/settings", method = RequestMethod.POST)
public String handleFileUpload(@ModelAttribute("userSettingsDto") UserSettingsDto userSettingsDto, Model model) {
// User byConfirmationToken = userService.findByConfirmationToken(userSettingsDto.getPasswordConfirmation());
// logger.debug(byConfirmationToken.getPassword());
// logger.debug(userSettingsDto.getPassword()); if (null == userSettingsDto) {
throw new BadRequestException("UserSettingsDto cound not be null.");
}
Map<String, Object> attributes = this.userService.updateUserProfile(userSettingsDto);
if (null == attributes) {
throw new ResourceNotFoundException("attributes not found.");
}
model.addAllAttributes(attributes);
return "forum/user-settings";
} }

5:UserService.java UserServiceImpl.java

package com.qingwenwei.service;

import com.qingwenwei.persistence.model.User;
import com.qingwenwei.web.dto.UserRegistrationDto;
import com.qingwenwei.web.dto.UserSettingsDto; import javax.servlet.http.HttpServletRequest;
import java.util.Map; public interface UserService { int save(User user); User findById(Long id); User findByUsername(String username); User findByEmail(String email); User findByConfirmationToken(String confirmationToken); User findAuthenticatedUser(); Map<String, Object> getUserProfileAndPostsByUserIdByTabType(Long userId, String tabType); Map<String, Object> updateUserProfile(UserSettingsDto newUserSettingsForm); Map<String, Object> getUserSettingPage(); Map<String, Object> registerUserAccount(UserRegistrationDto userDto, HttpServletRequest request); }
package com.qingwenwei.service.impl;

import com.qingwenwei.event.OnRegistrationCompleteEvent;
import com.qingwenwei.persistence.dao.CommentMapper;
import com.qingwenwei.persistence.dao.PostMapper;
import com.qingwenwei.persistence.dao.UserMapper;
import com.qingwenwei.persistence.model.Comment;
import com.qingwenwei.persistence.model.Post;
import com.qingwenwei.persistence.model.User;
import com.qingwenwei.service.StorageService;
import com.qingwenwei.service.UserService;
import com.qingwenwei.web.dto.UserRegistrationDto;
import com.qingwenwei.web.dto.UserSettingsDto;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.*; @Service("userService")
public class UserServiceImpl implements UserService { // private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
org.apache.logging.log4j.Logger logger = LogManager.getLogger(UserServiceImpl.class);
@Autowired
private UserMapper userMapper; @Autowired
private PostMapper postMapper; @Autowired
private CommentMapper commentMapper; // @Autowired
// private VerificationTokenMapper verificationTokenMapper; @Autowired
private StorageService storageService; @Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder; @Autowired
private ApplicationEventPublisher evenPublisher; @Override
public User findById(Long id) {
return userMapper.findById(id);
} @Override
public User findByEmail(String email) {
return userMapper.findByEmail(email);
} @Override
public User findByConfirmationToken(String confirmationToken) {
return userMapper.findByConfirmationToken(confirmationToken);
} @Override
public User findByUsername(String username) {
return userMapper.findByUsername(username);
} @Override //重置密码
public int save(User user) {
user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); //保存时应该将密码编码
return userMapper.save(user);
}
// @Override
// public int save(User user) {
// user.setPassword(user.getPassword());
// return userMapper.save(user);
// } @Override
public Map<String, Object> getUserProfileAndPostsByUserIdByTabType(Long userId, String tabType) {
if (null == userId) {
return null;
}
User user = this.userMapper.findById(userId);
if (null == user) {
return null;
}
Map<String, Object> attributes = new HashMap<>();
attributes.put("user", user);
String activeTab = tabType == null ? "posts" : tabType;
if ("posts".equalsIgnoreCase(activeTab)) {
List<Post> posts = this.postMapper.findPostsByUserId(userId);
attributes.put("posts", posts);
} else if ("comments".equalsIgnoreCase(activeTab)) {
List<Comment> comments = this.commentMapper.findCommentsByUserId(userId);
attributes.put("comments", comments);
}
attributes.put("activeTab", activeTab);
return attributes;
} @Override
public User findAuthenticatedUser() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
return this.userMapper.findByUsername(username);
} /**
* 更新用户profile
* @param userSettingsDto
* @return
*/
@Override
public Map<String, Object> updateUserProfile(UserSettingsDto userSettingsDto) {
Map<String, Object> attributes = new HashMap<>();
// String authenticatedUsername = this.findAuthenticatedUser().getUsername();
User authenticatedUser = this.findAuthenticatedUser(); String authenticatedUsername = authenticatedUser.getUsername();
String password = authenticatedUser.getPassword();
logger.debug("passward"+password);
if (null == authenticatedUsername || authenticatedUsername.equalsIgnoreCase("")
|| null == userSettingsDto
|| userSettingsDto.getEmail().isEmpty()
|| userSettingsDto.getEmail().equals("")) {
attributes.put("uploadResultMessage", "uploadFailure");
return attributes;
}
// update user profile
User user = this.storageService.store(userSettingsDto.getAvatar(), authenticatedUsername);
if (null == user) {
attributes.put("uploadResultMessage", "uploadFailure");
user = this.findAuthenticatedUser(); // find authenticated user if no user found
}
user.setPassword(password);
user.setEmail(userSettingsDto.getEmail());
user.setBio(userSettingsDto.getBio()); this.userMapper.update(user); // return attributes
attributes.put("user", user);
attributes.put("uploadResultMessage", "uploadSuccess");
return attributes;
} @Override
public Map<String, Object> getUserSettingPage() {
User user = this.findAuthenticatedUser();
UserSettingsDto newUserSettingsForm = new UserSettingsDto();
newUserSettingsForm.setBio(user.getBio());
newUserSettingsForm.setEmail(user.getEmail());
Map<String, Object> attributes = new HashMap<>();
attributes.put("user", user);
attributes.put("userSettingsDto", newUserSettingsForm);
return attributes;
} @Override
public Map<String, Object> registerUserAccount(UserRegistrationDto userDto, HttpServletRequest request) {
Map<String, Object> attributes = new HashMap<>(); // save newly registered user
User user = new User(); user.setPassword(bCryptPasswordEncoder.encode(userDto.getPassword())); //保存时应该将密码编码 // user.setPassword(userDto.getPassword());
user.setUsername(userDto.getUsername());
user.setEmail(userDto.getEmail());
user.setDateCreated(new Timestamp(System.currentTimeMillis()));
user.activated(true);
user.setRoles(User.USER);
user.setConfirmationToken(UUID.randomUUID().toString()); // save new user and get number of affected row
logger.debug("用户注册");
int affectedRow = userMapper.save(user);
logger.debug("用户注册成功");
// publish registration event
String appUrl = "http://" + request.getServerName() + ":" + request.getServerPort();
Locale locale = request.getLocale();
OnRegistrationCompleteEvent event = new OnRegistrationCompleteEvent(user.getUsername(), appUrl, locale);
this.evenPublisher.publishEvent(event); // populate attributes
String registrationResult = affectedRow == 1 ? "success" : "failure";
attributes.put("userRegistrationResult", registrationResult);
return attributes;
} }

6:UserMapper.java

package com.qingwenwei.persistence.dao;

import com.qingwenwei.persistence.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import java.util.List; @Mapper
public interface UserMapper { int save(@Param("user") User user); int update(@Param("user") User user); List<User> findAll(); User findById(Long id); User findByUsername(String username); User findByEmail(String email); User findByConfirmationToken(String confirmationToken); }

7;UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qingwenwei.persistence.dao.UserMapper"> <resultMap id="UserResultMap" type="com.qingwenwei.persistence.model.User">
<id property="id" column="id"/>
<result property="username" column="username"/>
<result property="password" column="password"/>
<result property="email" column="email"/>
<result property="confirmationToken" column="confirmation_token"/>
<result property="activated" column="activated"/>
<result property="dateCreated" column="date_created"/>
<result property="avatarLocation" column="avatar_location"/>
<result property="bio" column="bio"/>
</resultMap> <sql id="baseColumns" >
id, username, password, email, activated, date_created, avatar_location, bio,roles
</sql>
<insert id="save" parameterType="com.qingwenwei.persistence.model.User">
INSERT INTO `T_USER`
(
username,
password,
email,
confirmation_token,
activated,
date_created,
avatar_location,
bio,
roles
)
VALUES
(
#{user.username},
#{user.password},
#{user.email},
#{user.confirmationToken},
#{user.activated},
#{user.dateCreated},
#{user.avatarLocation},
#{user.bio},
#{user.roles}
)
</insert> <select id="findById" parameterType="Long" resultMap="UserResultMap">
SELECT
id,
username,
password,
email,
activated,
date_created,
avatar_location,
bio,
roles
FROM T_USER
WHERE id = #{id}
</select> <select id="findByUsername" parameterType="String" resultMap="UserResultMap">
SELECT
id,
username,
password,
email,
activated,
date_created,
avatar_location,
bio,
roles
FROM T_USER
WHERE username = #{username}
</select> <select id="findByEmail" parameterType="String" resultMap="UserResultMap">
SELECT
id,
username,
password,
email,
activated,
date_created,
avatar_location,
bio,
roles
FROM T_USER
WHERE email = #{email}
</select> <select id="findByConfirmationToken" parameterType="String" resultMap="UserResultMap">
SELECT
id,
username,
password,
email,
activated,
date_created,
avatar_location,
bio,
confirmation_token,
roles
FROM T_USER
WHERE confirmation_token = #{confirmationToken}
</select> <select id="findAll" resultMap="UserResultMap">
SELECT
id,
username,
password,
email,
activated,
date_created,
avatar_location,
bio,
confirmation_token,
roles
FROM T_USER
</select> <update id="update" parameterType="com.qingwenwei.persistence.model.User">
UPDATE T_USER SET
password = #{user.password},
email = #{user.email},
date_created = #{user.dateCreated},
avatar_location = #{user.avatarLocation},
bio = #{user.bio}
WHERE id = #{user.id}
</update> </mapper>

8;User.java

package com.qingwenwei.persistence.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; public class User implements Serializable { private static final long serialVersionUID = 1L; // constants
public static String USER = "USER"; //两种用户
public static String ADMIN = "ADMIN"; private Long id;
private String username;
private String password;
private String email;
private String confirmationToken;
private Long activated;
private Timestamp dateCreated;
private String avatarLocation;
private String bio;
private String roles; public User() { } public Long getId() {
return id;
} public void setId(Long id) {
this.id = id;
} public String getUsername() {
return username;
} public void setUsername(String userName) {
this.username = userName;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public String getConfirmationToken() {
return confirmationToken;
} public void setConfirmationToken(String confirmationToken) {
this.confirmationToken = confirmationToken;
} public Long getActivated() {
return activated;
} public void setActivated(Long activated) {
this.activated = activated;
} public static void setUSER(String USER) {
User.USER = USER;
} public static void setADMIN(String ADMIN) {
User.ADMIN = ADMIN;
} public static long getSerialVersionUID() {
return serialVersionUID; } public static String getUSER() {
return USER;
} public static String getADMIN() {
return ADMIN;
} public Timestamp getDateCreated() {
return dateCreated;
} public void setDateCreated(Timestamp dateCreated) {
this.dateCreated = dateCreated;
} public String getAvatarLocation() {
return avatarLocation;
} public void setAvatarLocation(String avatarLocation) {
this.avatarLocation = avatarLocation;
} public String getBio() {
return bio;
} public void setBio(String bio) {
this.bio = bio;
} public String getRoles() {
return roles;
} public void setRoles(String roles) {
this.roles = roles;
} //赋予该用户的角色 public Set<String> getRolesSet() {
if (null == roles) {
return null;
}
return Collections.unmodifiableSet(
new HashSet<String>(Arrays.asList(getRoles().split(","))));
} public void addRole(String role) {
String currRoles = this.getRoles();
if (null == currRoles || this.getRoles().contains(role)) {
return;
}
this.setRoles(currRoles + "," + role);
} public void activated(boolean activated) {
this.setActivated(activated == true ? 1L : 0L);
} @Override
public String toString() {
return "User [id=" + id + ", username=" + username + ", password=" + password + ", email=" + email
+ ", confirmationToken=" + confirmationToken + ", activated=" + activated + ", dateCreated="
+ dateCreated + ", avatarLocation=" + avatarLocation + ", bio=" + bio + ", roles=" + roles + "]";
} }

9:配置成功。

github:https://github.com/1367356/springBootForum

Spring boot Security 用于权限管理,用户添加等。的更多相关文章

  1. Spring boot整合shiro权限管理

    Apache Shiro功能框架: Shiro聚焦与应用程序安全领域的四大基石:认证.授权.会话管理和保密. #,认证,也叫作登录,用于验证用户是不是他自己所说的那个人: #,授权,也就是访问控制,比 ...

  2. 使用Spring Security实现权限管理

    使用Spring Security实现权限管理 1.技术目标 了解并创建Security框架所需数据表 为项目添加Spring Security框架 掌握Security框架配置 应用Security ...

  3. boke练习: spring boot: security post数据时,要么关闭crst,要么添加隐藏域

    spring boot: security post数据时,要么关闭crst,要么添加隐藏域 http.csrf().disable(); 或者: <input name="${_cs ...

  4. Spring Boot Security Oauth2之客户端模式及密码模式实现

    Spring Boot Security Oauth2之客户端模式及密码模式实现 示例主要内容 1.多认证模式(密码模式.客户端模式) 2.token存到redis支持 3.资源保护 4.密码模式用户 ...

  5. Spring Boot Security JWT 整合实现前后端分离认证示例

    前面两章节我们介绍了 Spring Boot Security 快速入门 和 Spring Boot JWT 快速入门,本章节使用 JWT 和 Spring Boot Security 构件一个前后端 ...

  6. Spring Boot Security配置教程

    1.简介 在本文中,我们将了解Spring Boot对spring Security的支持. 简而言之,我们将专注于默认Security配置以及如何在需要时禁用或自定义它. 2.默认Security设 ...

  7. Spring Boot Security 保护你的程序

    Spring Boot Security 本示例要内容 基于角色的权限访问控制 加密.解密 基于Spring Boot Security 权限管理框架保护应用程序 String Security介绍 ...

  8. Spring Boot Security OAuth2 实现支持JWT令牌的授权服务器

    概要 之前的两篇文章,讲述了Spring Security 结合 OAuth2 .JWT 的使用,这一节要求对 OAuth2.JWT 有了解,若不清楚,先移步到下面两篇提前了解下. Spring Bo ...

  9. Spring Boot Security 整合 OAuth2 设计安全API接口服务

    简介 OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到广泛应用,目前的版本是2.0版.本文重点讲解Spring Boot项目对OAuth2进行的实现,如果你对OAut ...

随机推荐

  1. 从0开始:Windows内核利用的另一种方式

    https://www.anquanke.com/post/id/91063 从0开始:Windows内核利用的另一种方式 阅读量    9168 |   稿费 200   分享到: 发布时间:201 ...

  2. SQL-游标-查询数据库中的所有表的数据个数

    --sql语句-游标等使用 ) ) declare @i INT ) declare @cstucount INT --上方设置变量 --初始值 declare mCursor cursor --设置 ...

  3. python基础---->python的使用(七)

    这里记录python关于io.装饰器和序列化的一些知识.面对大河我无限惭愧,我年华虚度,空有一身疲倦,和所有以梦为马的诗人一样,岁月易逝 一滴不剩. python的一些知识 一.python中的装饰器 ...

  4. Qt获取CPU编号和硬盘序列号

    windows下执行命令除了用cmd之外,还有个东西叫WMIC,非常强大,可以通过他获取很多信息,包括硬件信息. QString frmMain::getWMIC(const QString & ...

  5. MFC 刷新函数:Invaldate,UpdateWindow,InvaldateRect

    在窗口刷新和绘制的过程中,常常需要用到窗口刷新函数.一般用于窗口图形刷新的函数有:UpdateWindows().Invaldate().InvaldateRect(). 先说UpdateWindow ...

  6. Linux命令 swap:内存交换空间

    swap 内存交换空间的概念 swap使用上的限制

  7. [转]F5负载均衡名词LTM和GTM

    LTM就是本地流量管理,也就是通常所说的服务器负载均衡.可以将多个提供相同服务的设备(pool)虚拟成一个逻辑设备,供用户访问.也就是说,对于用 户来讲,看到的只有一个设备,而实际上用户是服务请求是在 ...

  8. Shell语法整理,持续维护

    Shell shell条件表达式: CONDITIONAL EXPRESSIONSConditional expressions are used by the [[ compound command ...

  9. nginx fastcgi配置

    1.1 nginx概述nginx简介Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/P ...

  10. AES加密工具类(对称加密算法)

    import java.nio.charset.Charset; import java.security.Key; import javax.crypto.Cipher;import javax.c ...