Coder Social home page Coder Social logo

token-authentication-example's Introduction

token-authentication-example

使用token做鉴权的例子

如何运行这个例子

  • 安装MySQL,导入resources下的token_demo.sql,创建数据库表结构,在application.properties中配置数据库账号密码。
  • 安装redis。redis官方没有提供window版本,好在微软为我们提供了window下的版本: window版redis下载
  • 运行TokenApplication.java类来启动项目,默认端口为9001,如果有端口冲突或者希望修改端口可以到配置文件application.properties下修改server.port的值即可。
  • 成功启动后浏览器打开http://localhost:9001/swagger-ui.html,便可以看到swagger API展示界面,进行API调试。

实现效果

用户登录成功后后台会返回一个token给调用者,同时我们自定义了@AuthToken注解,被该注解标注的api进行请求的时候都需要进行token效验,效验通过才可以正常访问。同时token具有生命周期,在用户持续一段时间不进行操作的话,token则会过期。

token-authentication-example's People

Contributors

vzardlloo avatar

Watchers

 avatar  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.