Demo:第三章:权限框架spring security oauth2

SpringSecurity+Oauth2获取AccessToken跨域CORS问题解决 问题: 在springboot+SpringSecurity+oauth2项目中,No ‘Access-Control-Allow-Origin’ 终极解决办法,在使用了corsFilter进行跨域处理,相关代码配置如下: @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, 阅读详情

直接上代码:
在这里插入图片描述

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>b8</artifactId>
        <groupId>com.pmpg</groupId>
        <version>1.0.0</version>
    </parent>
    <groupId>com.pmpg</groupId>
    <artifactId>b8-auth</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>b8-auth</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!--nacos 注册中心 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        </dependency>
        <!--        缓存配置-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>


        <!-- spring security oauth2-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>
        <!-- openfeign 服务远程调用 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>com.pmpg</groupId>
            <artifactId>b8-common-entity</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.pmpg</groupId>
            <artifactId>b8-common-redis</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
        </dependency>
<!--        日志-->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.10</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>b8-auth</finalName>
        <plugins>
            <!-- 打包生成fat jar -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.4.RELEASE</version>
                <configuration>
                    <mainClass>com.b8.auth.B8AuthApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>**/*.jks</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*.jks</include>
                </includes>
            </resource>
        </resources>
    </build>

</project>

AuthorizationServerConfig

package com.b8.auth.config;

import com.b8.auth.enhancer.B8AuthTokenEnhancer;
import com.b8.auth.service.B8AuthUserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
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.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description 基于DB模式配置授权服务器存储第三方客户端的信息
 * @Author zhiwei Liao
 * @Date 2021/8/17 15:42
 **/
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private DataSource dataSource;

    @Autowired
    @Qualifier("jwtTokenStore")
    private TokenStore tokenStore;
    
    @Autowired
    private JwtAccessTokenConverter jwtAccessTokenConverter;
    
    @Autowired
    private B8AuthUserDetailService userDetailService;
    
    @Autowired
    private AuthenticationManager authenticationManagerBean;
    
    @Autowired
    private B8AuthTokenEnhancer b8AuthTokenEnhancer;

    /**
     * @Description 第三方信息的存储
     * @MethodParameterTypes [org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer]
     * @MethodParameters [clients]
     * @MethodReturnType void
     * @Author zhiwei Liao
     * @Date 2021/8/17 14:57
     **/
    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        // 第三方信息的存储   基于jdbc
        clients.withClientDetails(clientDetailsService());
    }
    
    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        //配置JWT的内容增强器
        TokenEnhancerChain enhancerChain = new TokenEnhancerChain();
        List<TokenEnhancer> delegates = new ArrayList<>();
        delegates.add(b8AuthTokenEnhancer);
        delegates.add(jwtAccessTokenConverter);
        enhancerChain.setTokenEnhancers(delegates);
        
        //使用密码模式需要配置
        endpoints.authenticationManager(authenticationManagerBean)
                .reuseRefreshTokens(false)  //refresh_token是否重复使用
                .userDetailsService(userDetailService) //刷新令牌授权包含对用户信息的检查
                .tokenStore(new JdbcTokenStore(dataSource))  //指定token存储策略是jwt,存储到mysql
                .accessTokenConverter(jwtAccessTokenConverter)
                .tokenEnhancer(enhancerChain) //配置tokenEnhancer
                .allowedTokenEndpointRequestMethods(HttpMethod.GET,HttpMethod.POST); //支持GET,POST请求
    }

    @Bean
    public JdbcTokenStore jdbcTokenStore(){
        return new JdbcTokenStore(dataSource);
    }
    
    /**
     * 授权服务器安全配置
     * @param security
     * @throws Exception
     */
    @Override
    public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
        //第三方客户端校验token需要带入 clientId 和clientSecret来校验
        security.checkTokenAccess("isAuthenticated()")
                .tokenKeyAccess("isAuthenticated()");//来获取我们的tokenKey需要带入clientId,clientSecret
        //允许表单认证
        security.allowFormAuthenticationForClients();
    }
    
    @Bean
    public ClientDetailsService clientDetailsService(){
        return new JdbcClientDetailsService(dataSource);
    }
    
}

AuthResourceServerConfig

package com.b8.auth.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 资源服务配置
 */
@Configuration
@EnableResourceServer
public class AuthResourceServerConfig extends ResourceServerConfigurerAdapter {
    
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().authenticated();
    }
}

JwtTokenStoreConfig

package com.b8.auth.config;

import com.b8.auth.enhancer.B8AuthTokenEnhancer;
import com.b8.auth.properties.JwtCAProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
import org.springframework.security.rsa.crypto.KeyStoreKeyFactory;

import java.security.KeyPair;

@Configuration
@EnableConfigurationProperties(value = JwtCAProperties.class)
public class JwtTokenStoreConfig {

    @Bean
    public TokenStore jwtTokenStore(){
        return new JwtTokenStore(jwtAccessTokenConverter());
    }
    
    @Bean
    public B8AuthTokenEnhancer b8AuthTokenEnhancer() {
        return new B8AuthTokenEnhancer();
    }

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        JwtAccessTokenConverter accessTokenConverter = new
                JwtAccessTokenConverter();
        //配置JWT使用的秘钥 非对称加密
        accessTokenConverter.setKeyPair(keyPair());
        return accessTokenConverter;
    }
    
    @Autowired
    private JwtCAProperties jwtCAProperties;
    
    @Bean
    public KeyPair keyPair() {
        KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource(jwtCAProperties.getKeyPairName()), jwtCAProperties.getKeyPairSecret().toCharArray());
        return keyStoreKeyFactory.getKeyPair(jwtCAProperties.getKeyPairAlias(), jwtCAProperties.getKeyPairStoreSecret().toCharArray());
    }
}

RedisConfig

package com.b8.auth.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

/**
 * @author zhiwei Liao
 */
@Configuration
public class RedisConfig {
    
    @Autowired
    private RedisConnectionFactory redisConnectionFactory;
    
    @Bean
    public TokenStore tokenStore(){
        // access_token
        return new RedisTokenStore(redisConnectionFactory);
    }
}

WebSecurityConfig

package com.b8.auth.config;

import com.b8.auth.service.B8AuthUserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @Description 配置SpringSecurity,“将Spring Security与Spring Gateway一起使用时出现无法访问javax.servlet.Filter”错误”,
 * 把Spring Gateway和Spring Security放在一起,因为我想保护我的网关。但是在实现了以下扩展WebSecurityConfigurerAdapter的类之后,
 * 项目抛出java:无法访问javax.servlet.Filter
 * 从Spring Cloud Gateway文档中:Spring Cloud Gateway需要Spring Boot和Spring Webflux提供的Netty运行时。
 * 它不能在传统的Servlet容器中工作,也不能在构建为WAR时工作。扩展WebSecurityConfigurerAdapter是为了基于servlet的应用程序
 * @Author zhiwei Liao
 * @Date 2021/8/17 15:44
 **/

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    
    @Autowired
    private B8AuthUserDetailService userDetailService;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailService);
    }
    
    @Bean
    @Override
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }

    /**
     * @Description 密码模式
     * @MethodReturnType org.springframework.security.crypto.password.PasswordEncoder
     * @Author zhiwei Liao
     * @Date 2021/8/17 15:46
     **/
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
    
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.formLogin().permitAll()
                .and().authorizeRequests()
                .antMatchers("/oauth/**").permitAll()//不拦截
                .anyRequest()
                .authenticated()
                .and().logout().permitAll()//退出放行
                .and().csrf().disable();
    }
    
    
}

UserinfoDetails

package com.b8.auth.domain;

import com.common.entity.po.B8UserUserinfoEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Arrays;
import java.util.Collection;

/**
 * @author zhiwei Liao
 */
public class UserinfoDetails implements UserDetails {

    private B8UserUserinfoEntity userUserinfo;

    public UserinfoDetails(B8UserUserinfoEntity userUserinfo) {
        this.userUserinfo = userUserinfo;
    }
    
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        //返回当前用户的权限  BRAC   user  role  authority
        return Arrays.asList(new SimpleGrantedAuthority("TEST"));
    }

    // 获取用户密码(凭证)
    @Override
    public String getPassword() {
        return userUserinfo.getCredential();
    }

    // 获取用户名
    @Override
    public String getUsername() {
        return userUserinfo.getNickNameId();
    }

    // 判断帐号是否已经过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    // 判断帐号是否已被锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    // 判断用户凭证是否已经过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    // 判断用户帐号是否已启用
    @Override
    public boolean isEnabled() {
        return !userUserinfo.getUserStatus().equals("FREEZE");
    }

    public B8UserUserinfoEntity getUserUserinfo() {
        return userUserinfo;
    }

}

B8AuthTokenEnhancer

package com.b8.auth.enhancer;

import com.b8.auth.domain.UserinfoDetails;
import com.common.entity.po.B8UserUserinfoEntity;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import java.util.HashMap;
import java.util.Map;


public class B8AuthTokenEnhancer implements TokenEnhancer {

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        UserinfoDetails userinfoDetails = (UserinfoDetails) authentication.getPrincipal();
        final Map<String, Object> additionalInfo = new HashMap<>();
        final Map<String, Object> retMap = new HashMap<>();
        //todo 这里暴露userId到Jwt的令牌中,后期可以根据自己的业务需要 进行添加字段
        additionalInfo.put("userId",userinfoDetails.getUserUserinfo().getId());
        additionalInfo.put("userName",userinfoDetails.getUserUserinfo().getNickNameId());
        additionalInfo.put("nickName",userinfoDetails.getUserUserinfo().getDisplayName());
        additionalInfo.put("loginType",userinfoDetails.getUserUserinfo().getLoginType());
        retMap.put("additionalInfo",additionalInfo);
        ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(retMap);
        return accessToken;
    }
}

JwtCAProperties

package com.b8.auth.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @Description 读取配置文件中的属性配置
 * @Author zhiwei Liao
 * @Date 2021/8/18 10:04
 **/
@Data
@ConfigurationProperties(prefix = "b8auth.jwt")
public class JwtCAProperties {

    /**
     * 证书名称
     */
    private String keyPairName;


    /**
     * 证书别名
     */
    private String keyPairAlias;

    /**
     * 证书私钥
     */
    private String keyPairSecret;

    /**
     * 证书存储密钥
     */
    private String keyPairStoreSecret;

}

UserServiceHystrix

package com.b8.auth.service.impl;

import com.b8.auth.api.ResultData;
import com.b8.auth.service.UserInfoFeignService;
import com.common.entity.po.B8UserUserinfoEntity;
import org.springframework.stereotype.Component;

/**
 * @author zhiwei Liao
 * @version 1.0
 * @Description
 * @Date 2021/8/17 15:25
 */

@Component
public class UserServiceHystrix implements UserInfoFeignService {


    @Override
    public ResultData<B8UserUserinfoEntity> getUserinfoById(String userId) {
        return null;
    }

    @Override
    public ResultData<B8UserUserinfoEntity> getUserByUsername(String username) {
        return null;
    }
}

B8AuthUserDetailService

package com.b8.auth.service;

import com.b8.auth.api.ResultData;
import com.b8.auth.domain.UserinfoDetails;
import com.common.entity.po.B8UserUserinfoEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author zhiwei Liao
 * @version 1.0
 * @Description
 * @Date 2021/8/17 15:02
 */
@Service
@Slf4j
public class B8AuthUserDetailService implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        // TODO  查数据库获取用户信息   rpc调用
        // 加载用户信息
        if (StringUtils.isEmpty(username)) {
            log.warn("用户登陆用户名为空:{}", username);
            throw new UsernameNotFoundException("用户名不能为空");
        }

        B8UserUserinfoEntity userUserinfo = getByUsername(username);

        if (null == userUserinfo) {
            log.warn("根据用户名没有查询到对应的用户信息:{}", username);
        }

        log.info("根据用户名:{}获取用户登陆信息:{}", username, userUserinfo);

        // 用户信息的封装 implements UserDetails
        UserinfoDetails memberDetails = new UserinfoDetails(userUserinfo);
        return memberDetails;
    }

    @Autowired
    private UserInfoFeignService userInfoFeignService;

    public B8UserUserinfoEntity getByUsername(String username) {
        // fegin获取用户信息
        ResultData<B8UserUserinfoEntity> resultData = userInfoFeignService.getUserByUsername(username);
        return resultData.getData();
    }
}


UserInfoFeignService

package com.b8.auth.service;

import com.b8.auth.api.ResultData;
import com.b8.auth.service.impl.UserServiceHystrix;
import com.common.entity.po.B8UserUserinfoEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author zhiwei Liao
 * @version 1.0
 * @Description
 * @Date 2021/8/17 15:24
 */
@Component
@FeignClient(name = "user", fallback = UserServiceHystrix.class, path = "/user")
public interface UserInfoFeignService {

    @GetMapping("/getUserinfoById")
    ResultData<B8UserUserinfoEntity> getUserinfoById(@RequestParam("userId") String userId);

    @GetMapping("/getUserByUsername")
    ResultData<B8UserUserinfoEntity> getUserByUsername(@RequestParam("username") String username);
}

IErrorCode

package com.b8.auth.api;

/**
 * 封装API的错误码
 */
public interface IErrorCode {
    int getCode();

    String getMessage();
}

ResultCode

package com.b8.auth.api;


/**
 * 枚举了一些常用API操作码
 */
public enum ResultCode implements IErrorCode {
    SUCCESS(200, "操作成功"),
    FAILED(500, "操作失败"),
    VALIDATE_FAILED(404, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    AUTHORIZATION_HEADER_IS_EMPTY(600,"请求头中的token为空"),
    GET_TOKEN_KEY_ERROR(601,"远程获取TokenKey异常"),
    GEN_PUBLIC_KEY_ERROR(602,"生成公钥异常"),
    JWT_TOKEN_EXPIRE(603,"token校验异常"),
    TOMANY_REQUEST_ERROR(429,"后端服务触发流控"),
    BACKGROUD_DEGRADE_ERROR(604,"后端服务触发降级"),
    BAD_GATEWAY(502,"网关服务异常"),
    FORBIDDEN(403, "没有相关权限");
    private int code;
    private String message;

    private ResultCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}

ResultData

package com.b8.auth.api;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
public class ResultData<T> implements Serializable {
    /**
     * 状态码
     */
    public boolean status = true;

    /**
     * 状态码
     */
    private Integer code = 200;

    /**
     * 接口返回信息
     */
    private String msg;

    /**
     * 数据对象
     */
    private T data;

    /**
     * 初始化一个新创建的 ResultData 对象
     *
     * @param status 状态码
     * @param msg    返回内容
     */
    public ResultData(Boolean status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    /**
     * 初始化一个新创建的 ResultData 对象
     *
     * @param status 状态码
     * @param msg    返回内容
     * @param data   数据对象
     */
    public ResultData(Boolean status, String msg, T data, Integer code) {
        this.status = status;
        this.msg = msg;
        this.data = data;
        this.code = code;
    }

    public ResultData(T data) {
        this.data = data;
    }


    /**
     * 返回成功消息
     *
     * @param msg  返回内容
     * @param data 数据对象
     * @return 成功消息
     */
    public static <T> ResultData<T> success(String msg, T data) {
        return new ResultData<T>(true, msg, data, 200);
    }

    /**
     * 返回成功消息
     *
     * @param msg 返回内容
     * @return 成功消息
     */
    public static <T> ResultData<T> success(String msg) {
        return ResultData.success(msg, null);
    }

    /**
     * 返回成功消息
     *
     * @return 成功消息
     */
    public static <T> ResultData<T> success() {
        return ResultData.success(null);
    }

    /**
     * 返回成功数据
     *
     * @return 成功消息
     */
    public static <T> ResultData<T> success(T data) {
        return ResultData.success(null, data);
    }

    /**
     * 返回错误消息
     *
     * @return
     */
    public static <T> ResultData<T> error() {
        return ResultData.error(null);
    }


    /**
     * 返回错误消息
     *
     * @param msg 返回内容
     * @return 警告消息
     */
    public static <T> ResultData<T> error(String msg) {
        return ResultData.error(msg, null);
    }

    /**
     * 返回错误消息
     *
     * @param code 状态码
     * @param msg  返回内容
     * @return 警告消息
     */
    public static <T> ResultData<T> error(Integer code, String msg) {
        return new ResultData<T>(false, msg, null, code);
    }


    /**
     * 返回错误消息
     *
     * @param msg  返回内容
     * @param data 数据对象
     * @return 警告消息
     */
    public static <T> ResultData<T> error(String msg, T data) {
        return new ResultData<T>(false, msg, data, 500);
    }
}

B8AuthApplication

package com.b8.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

@SpringBootApplication
@EnableFeignClients
public class B8AuthApplication {

    public static void main(String[] args) {
        SpringApplication.run(B8AuthApplication.class, args);
        System.out.println("=======授权模块启动成功===========");
    }

}

在这里插入图片描述bootstrap.yml

# Tomcat
server:
  port: 10000
  tomcat:
    basedir: /tmp/tomcat
# Spring
spring:
  application:
    name: auth
  profiles:
    # 环境配置
    active: local
  messages:
    encoding: UTF-8
    basename: i18n/messages
  main:
    allow-bean-definition-overriding: true

##hystrix的超时时间
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 60000
##Ribbon超时重试配置
ribbon:
  ConnectTimeout: 10000  #毫秒    连接超时时间
  ReadTimeout: 600000     #毫秒      逻辑处理超时时间
  OkToRetryOnAllOperations: true    # 是否对所有操作都进行重试
  MaxAutoRetries: 3     # 对当前实例的最大重试次数(请求服务超时6s则会再请求一次)
  MaxAutoRetriesNextServer: 1     # 切换实例的最大重试次数(如果还失败就切换下

b8auth:
  jwt:
    keyPairName: jwt.jks
    keyPairAlias: jwt
    keyPairSecret: 123456
    keyPairStoreSecret: 123456

这里就已经搭建好了一套权限框架了,这里一般和网关配套使用,由网关获取请求头里的参数,进行校验access_token是否一致,判断当前请求是否合法。

Spring Security6 & OAuth2 实现流程 实现 Filter 接口,设置登陆的用户信息,然后继续执行请求。@Override// 在请求处理之前执行的操作// 设置登陆的用户信息// 继续传递请求和响应// 在响应处理之后执行的操作/** 禁用不必要的默认filter,处理异常响应内容 */// 禁用SpringSecurity默认filter。 阅读详情

相关推荐

Spring Security集成Oauth2实现用户身份验证+授权

前言 最近的项目有使用到Sping Security和Oauth做用户身份验证和授权机制,所以在网上找了点资料简单学习并写了个小demo,在此进行记录总结。 参考链接 1. Spring Security了解:https://www.springcloud.cc/spring-security-zhcn.html 2. Spring Boot集成Spring Security: https://www.jianshu.com/p/afe6619d9663 https://www.cnblogs.

qq_38586378的博客 5903

spring-security-oauth2(授权模式入门简单使用)

当前应用需要实现第三方登入,那么第三方是如何进行授权认证的?这就是oauth2协议。模拟实现微信端是如何进行授权认证登入。举例:豆瓣就是客户应用,授权服务器、资源服务器就是微信端持有。豆瓣需要向微信的授权服务器获取授权,获取到授权后再向资源服务器获取用户信息。那么我们就需要1.需要配置一个授权服务器(发放授权码)2.配置一个资源服务器(获取用户信息接口需要令牌才能访问)3.配置一个接口(获取返回用户信息)4.还要实现模拟用户的登入(因为授权服务器需要向用户发起是否允许授权的请求)......

IABQL的博客 3255

开发笔记 | 认证授权+Spring Security+OAuth2快速学习笔记

认证授权+Spring Security+OAuth2学习笔记

qq_37630282的博客 2733

SpringSecurityOAuth2登录流程分析

整个流程跟着源码走下来,结合log分析,还是能大体上理解的,不奢求所有细节都掌握,其中实际上跟我们关系比较大的就是几处自定义的地方,毕竟我们如果要自定义一些东西,还是得仰仗他们,比如微信的授权登录,就会用到,他有很多不同之处,也有一些坑,这个就留到下一篇再学习好了。

张氏小毛驴的博客 1497

Spring Security OAuth2入门Demo

写在前面 项目基于Spring Cloud,需要你对Spring Cloud有所了解,篇幅所限,本文只会列出关键代码,文末会给出完整的项目GIT地址,建议下载下来导入到idea中再进行查看。 项目的目录结构 其中auth-server为认证模块,client-user为资源模块。 auth-server模块配置 首先需要导入oauth2的包 <dependency> <groupId>org.springframework.cloud</groupId>

诺浅的专栏 2111

Spring Security OAuth2 配置详解

Spring Security 是一个强大且灵活的框架,用于保护基于 Java 的应用程序的安全性。在本文中,我们将详细介绍如何配置 Spring Security OAuth2,并提供相应的源代码示例。这是一个简单的示例,展示了如何配置 Spring Security OAuth2。但是,通过上述配置,你应该能够开始构建安全性强大的基于 OAuth2 的应用程序。我们配置了一个内存中的客户端,并指定了授权类型、范围和重定向 URL。我们配置了一个简单的规则,要求所有请求都必须经过身份验证。

DevSavantX的博客 481

详细分析Spring Security OAuth2中的JwtAccessTokenConverter基本知识(附Demo)

JwtAccessTokenConverter 是 Spring Security OAuth2 中的一个重要组件,主要用于生成和验证 JSON Web Token (JWT) JWT 的结构: JWT 由三部分组成:头部(Header)、负载(Payload)和签名(Signature) 头部通常包含令牌的类型(JWT)和签名算法(如 HMAC SHA256) 负载部分包含声明(Claims),即与用户相关的信息,例如权限、过期时间等 签名是使用头部和负载生成的,用于验证令牌的完整性

码农研究僧的博客 2372

保姆级教程:在iQuant平台从零写一个Python量化策略(附完整代码示例)

本文提供了一份详细的iQuant平台Python量化策略开发教程,从环境准备到策略实现、回测优化,再到实盘运行,每个步骤都配有完整代码示例和常见问题解决方案。适合量化交易新手快速上手,掌握双均线策略等核心开发技巧。

weixin_42783709的博客 484

从零开始的Spring Security Oauth2(一)

使用配置 1.简易的分为三个步骤 配置资源服务器 配置认证服务器 配置spring security 2.oauth2根据使用场景不同,分成了4种模式 授权码模式(authorization code) 简化模式(implicit) 密码模式(resource owner password credentials) 客户端模式(c...

小王的博客 4万+

【YOLOV5-5.x 源码讲解】整体项目文件导航

前言 这个项目是github的开源项目,YOLOV5:https://github.com/ultralytics/yolov5,目前已经有14.1k个Star 和 4.9k 个Folk了,非常的火。下面我会给大家逐个的文件介绍这个项目中的所有代码,希望能帮到大家。 我下的2021年4月12日更新的v5.0版本,整个项目我做了一点点的文件位置的改变,也加了点自己在其他论文中学到的tricks,不过我没有删除它源码任何一个代码。下面我会按文件逐个函数的进行攻破,因为我本人也还是研一,肯定会有很多的不足,希望大

qq_38253797的博客 6万+

LangChain与SkillLite集成:AI Agent安全沙箱实践

在AI与自动化技术领域,安全沙箱是实现可信计算的核心机制。其原理是通过资源隔离与权限控制,构建受限的执行环境。技术价值在于平衡功能开放性与系统安全性,尤其适用于处理用户提交的非受信代码或敏感数据。典型应用场景包括AI插件系统、在线代码评测平台等。本文以LangChain框架与SkillLite沙箱的深度集成为例,详解如何通过命名空间隔离、cgroups限制等机制,为AI Agent赋予安全执行动态技能的能力。其中涉及的关键技术点包括Python运行时隔离、动态资源配额管理,以及如何防范Shell注入等常见攻

weixin_34189116的博客 405

springboo2.x权限 demo(shiro,sprng security,oauth2)

前言 这是一篇关于权限方面的文章,这是去年的时候结合一些简单的项目,自己抽空瞎折腾的学习demo,进行了一定的整理,涉及的内容包括 spring boot 2.x,shiro,spring security,oauth2 公布出来的目的??,方便爱学习的你(骗赞)。 本文也不得介绍这些项目流程,也不会讲解怎么实现的,毕竟都是套路,难度不大,自己debug 调试,也算是能力的提高。 每个项目中很...

小张的专栏 3022

别再只跑Demo了!用MovieLens数据集完整复现一个电影推荐系统(Python/Pandas实战)

本文详细介绍了如何利用MovieLens数据集从零构建一个完整的电影推荐系统,涵盖数据清洗、特征工程、推荐算法实现(协同过滤和矩阵分解)以及Web服务部署的全流程。通过Python和Pandas实战,读者可以掌握推荐系统的核心技术和生产环境部署技巧,不再局限于简单的Demo运行。

weixin_29062865的博客 150

【安全框架】Spring Security、Oauth2、JWT 这一篇就够了

文章目录Spring Security1. 安全框架概述2. Spring Security 简述3.Spring Security3.1 创建项目3.2 项目依赖3.3 页面3.3.1 login.html3.3.2 main.html3.4 测试3.4.1 启动项目3.4.2 打开浏览器3.5 自定义登录逻辑3.5.1 Security 的配置类3.5.2 UserDetailsService 的实现类3.5.3 重启测试3.6 自定义登陆页面3.6.1 login.html3.6.2 Security

小源同学的博客 8483

PCB布线避坑指南:为什么你的差分线等长总调不好?AD19蛇形等长技巧详解

本文详细解析了AD19环境下PCB差分线等长调整的核心技巧与常见问题。从差分信号等长的底层逻辑到AD19规则配置,再到蛇形等长高级技巧和信号完整性验证,帮助工程师解决差分线等长调整中的难题,提升高速PCB设计的信号质量。

weixin_28738397的博客 387

hcaptcha-challenger:基于本地AI模型自动破解验证码的工程实践

验证码作为区分人类与机器的经典安全机制,其核心原理是通过图像识别、行为分析等交互式挑战来阻挡自动化程序。传统绕过方法依赖第三方打码平台或脚本,存在成本高、稳定性差的问题。随着多模态大语言模型和计算机视觉技术的发展,本地化AI求解成为新的技术方向,它通过集成YOLO、ResNet等模型,在本地完成图像语义理解,实现了高隐私、低成本、可进化的验证码自动化解决方案。这种范式尤其适用于需要大规模稳定处理网页交互的场景,如电商数据采集和社交媒体管理。hcaptcha-challenger项目正是这一理念的工程实践,它

weixin_42587866的博客 1028

Spring Security OAuth2之resource_id配置与验证

一、resource_id的作用 Spring Security OAuth2 架构上分为Authorization Server认证服务器和Resource Server资源服务器。我们可以为每一个Resource Server(一个微服务实例)设置一个resourceid。Authorization Server给client第三方客户端授权的时候,可以设置这个client可以访问哪一些Resource Server资源服务,如果没设置,就是对所有的Resource Server都有访问权限。

字母哥博客 8600

基于ESP32的室内空气质量检测系统开发

随着环境污染问题的日益严重,室内空气质量的监测变得越来越重要。室内空气质量的好坏直接影响到人们的健康,尤其是对于在封闭空间长时间待着的人群。为此,基于ESP32的室内空气质量检测系统应运而生。ESP32作为一款集成了Wi-Fi和蓝牙的高性能微控制器,为嵌入式开发提供了良好的平台,适用于构建各种智能硬件设备。本博客将详细介绍如何基于ESP32开发一个室内空气质量检测系统。系统可以实时监测空气中的温度、湿度、二氧化碳浓度、甲醛浓度等指标,并通过Wi-Fi将数据传输到云端或移动设备,方便用户随时查看空气质量情况。

2201_76125393的博客 833

【Spring Cloud Spring Security Oauth2】Spring Security Oauth2 + Redis + Gateway网关 + Mybatis + Mysql 整合

目录一、环境要求二、源码下载地址三、参考文献四、项目预览截图说明五、oauth2.0认证授权项目5.1 POM依赖5.2 yml配置及启动类5.3 认证配置与资源配置5.4 自定义UserDetailsService5.5 security配置5.6 自定义无加密密码验证5.7 druid连接池配置5.8 执行数据库脚本5.9 测试认证授权5.9.1 获取token5.9.2 测试访问授权资源5....

泯灭于众生,高歌于孤夜! 4316

ComfyUI 提示Allocation on device 显存占满的解决方法及秋叶整合包的优化方法

最近在玩ComfyUI的时候,发现一个让人崩溃的问题——VRAM一直占满,最终报错: 简单来说,就是显卡显存溢出了,导致程序无法继续运行。尤其是一些大模型或者复杂工作流,很容易让显存飙升到极限。那怎么办?直接在启动命令后加上 ,例如: 这个参数的作用是啥? 默认情况下,ComfyUI会尽量让模型一直留在显存里,即使有些部分暂时用不到,导致显存迟早被填满。而 可以强制让ComfyUI把数据卸载到常规内存,减少显存占用。如果你的显存真的不够用,还可以再加 参数: 这个参数的意思就是开启低显存模式,进一步优化

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1万+

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Spring Security Oauth2之scope作用域机制使用详解

Scope是 OAuth 2.0 中的一种机制,用于限制应用程序对用户帐户的访问。应用程序可以请求一个或多个范围,然后该信息会在同意屏幕中呈现给用户,并且颁发给应用程序的访问令牌将仅限于授予的范围。OAuth 规范允许授权服务器或用户根据请求修改授予应用程序的范围,尽管在实践中这样做的服务示例并不多。OAuth 没有为范围定义任何特定值,因为它高度依赖于服务的内部架构和需求。GitHub 文档描述 通过作用域,您可以准确指定所需的访问权限类型。 作用域限制 OAuth 令牌的访问权限。 它们不会授予超出用户

jiangjun_dao519的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Spring Security- 自定义 Oauth2 的授权服务器配置

Spring Security OAuth2 授权服务器配置指南 🚀 本文介绍了如何使用 Spring Security 构建自定义 OAuth2 授权服务器,涵盖了核心概念、技术栈准备、数据模型设计和实现流程。内容要点: OAuth2 基础:解释了 OAuth2 的四种授权模式和核心角色(资源拥有者、客户端、授权服务器、资源服务器) 自定义授权服务器的必要性:适用于需要完全控制认证流程、私有化部署或深度集成的场景 技术实现: 采用 Spring Authorization Server 模块 使用 H2

千淘万漉虽辛苦,吹尽狂沙始到金 1万+

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

探索Spring Security OAuth2 Demo:一个安全实践的宝库

探索Spring Security OAuth2 Demo:一个安全实践的宝库 项目简介 是一个开源项目,旨在帮助开发者理解和应用OAuth2协议与Spring Security框架在实际项目中的整合。通过这个项目,你可以看到如何搭建一个完整的OAuth2授权服务器,并实现客户端的认证和授权功能。 技术分析 该项目基于Java和Spring Boot框架构建,结合了Spring Security的...

gitblog_00030的博客 416
上一篇: Demo:第二章:Java实现随机图像生成(人像,汽车,房屋等等)
下一篇: Demo:第四章:Gateway网关
Java程序员廖志伟
Java程序员廖志伟 优质创作者: Java技术领域 优质创作者: Java技术领域 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄8年 2万+粉丝 1902原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java程序员廖志伟

赏我包辣条呗

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值