Giter VIP home page Giter VIP logo

auth-daiguangze-spring-boot-starter's Introduction

快速开始

  1. 克隆本仓库
https://github.com/HandsomeZe/whitelist-daiguangze-spring-boot-starter.git
  1. 使用maven install

使用IDEA中 maven 可视化工具即可

  1. 在使用这个starter的项目中引入依赖
<dependency>
    <groupId>cn.ze.tool</groupId>
    <artifactId>whitelist-daiguangze-springboot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
  1. 在springboot启动类上添加包扫描路径
@SpringBootApplication
@ComponentScan(basePackages = {"cn.ze.tool.middleware.*"})
public class ApiTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiTestApplication.class, args);
    }

}
  1. 在application.yml中配置白名单用户
# 白名单用户 简单用法
cn:
  ze:
    tool:
      whitelist:
        users: aaa,111,daiguangze
  1. 在需要的controller上添加 @ DoWhiteList 注解
    @DoWhiteList(key = "userId", returnJson = "{\"code\":\"1111\",\"info\":\"非白名单可访问用户拦截!\"}")
    @RequestMapping(path = "/api/queryUserInfo", method = RequestMethod.GET)
    public UserInfo queryUserInfo(@RequestParam String userId) {
        return "hello";
    }

当传入的userID为配置的users中之外的人员时,返回returnJson

auth-daiguangze-spring-boot-starter's People

Contributors

handsomeze avatar

Watchers

 avatar

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.