Giter Club home page Giter Club logo

tieba's Introduction

简介

spring-boot-seed-project 是一个基于Spring Boot & MyBatis-plus 的种子项目,通过代码生成快速构建RESTful API项目。 项目结构

特征&提供

  • 基于Mybatis-plus的代码生成器根据表名生成对应的Model、Mapper、MapperXML、 Service、ServiceImpl、Controller等基础代码
  • 最佳实践的项目结构、配置文件、精简的POM
  • 统一响应结果封装及生成工具
  • 统一异常处理
  • 使用Spring Security框架实现jwt认证
  • 使用Druid Spring Boot Starter 集成Druid数据库连接池与监控
  • 集成MyBatis-plus,实现单表业务零SQL  

快速开始

  1. 克隆项目
  2. test包内的代码生成器CodeGenerator进行配置,主要是JDBC,因为要根据表名来生成代码
  3. 输入表名,运行CodeGenerator.main()方法,生成基础代码
  4. 根据业务在基础代码上进行扩展
  5. 对开发环境配置文件application-dev.yml进行配置,启动项目.  

开发建议

  • 开发规范建议遵循阿里巴巴Java开发手册(最新版下载)
  • 不需要jwt认证可以直接删除security包和pom.xml文件里的spring-boot-starter-security依赖
  • 使用jwt认证需要实现security/JwtUserDetailService接口, 然后删除JwtUserDetailServiceDefaultImpl这个bean类 (实现可参考security/JwtUserDetailServiceDefaultImpl类)
  • jwt认证获取token代码例子:
@RestController
@RequestMapping("/test/user")
public class UserController {

    @Autowired
    private TokenProvider tokenProvider;
    @Autowired
    private AuthenticationManagerBuilder authenticationManagerBuilder;

    @PostMapping("get-token")
    public Result<Object> getToken(@RequestParam String username, @RequestParam String password) {
        UsernamePasswordAuthenticationToken authenticationToken =
                new UsernamePasswordAuthenticationToken(username, password);
        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
        SecurityContextHolder.getContext().setAuthentication(authentication);
        Map<String, Object> claims = new HashMap<>();
        claims.put("auth", "admin");
        String accessToken = tokenProvider.createAccessToken(username, claims);
        String refreshToken = tokenProvider.createRefreshToken(username, claims);
        Map<String, Object> response = new HashMap<>();
        response.put("accessToken", accessToken);
        response.put("refreshToken", refreshToken);
        return Result.data(response);
    }

}

tieba's People

Contributors

ahayujie avatar

Watchers

James Cloos avatar  avatar

tieba's Issues

同学,您这个项目引入了70个开源组件,存在16个漏洞,辛苦升级一下

检测到 AhaYujie/tieba 一共引入了70个开源组件,存在16个漏洞

漏洞标题:Vmware VMware Spring Security 权限许可和访问控制问题漏洞
缺陷组件:org.springframework.security:[email protected]
漏洞编号:CVE-2021-22112
漏洞描述:Vmware VMware Spring Security是美国威睿(Vmware)公司的一套为基于Spring的应用程序提供说明性安全保护的安全框架。
VMware Spring Security 中存在权限许可和访问控制问题漏洞。该漏洞源于攻击者可以通过Spring Security的多个SecurityContext更改绕过限制,以提升其权限。以下产品及版本受到影响:Spring Security 5.4.0 至 5.4.3 版本, Spring Security 5.3.0.RELEASE 至 5.3.7.RELEASE 版本, Spring Security 5.2.0.RELEASE 至 5.2.8.RELEASE 版本。
影响范围:(∞, 5.2.9.RELEASE)
最小修复版本:5.2.9.RELEASE
缺陷组件引入路径:online.ahayujie:[email protected]>org.springframework.boot:[email protected]>org.springframework.security:[email protected]>org.springframework.security:[email protected]

另外还有16个漏洞,详细报告:https://mofeisec.com/jr?p=i6de3e

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.