Giter Site home page Giter Site logo

cube3power / spring-restful-authorization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scienjus/spring-restful-authorization

0.0 1.0 0.0 1.08 MB

这个 Demo 用于演示如何在 RESTful 下使用自定义 Token 保持客户端登录状态,依靠 Spring 的拦截器和解析器完成权限验证及登录用户注入,并使用 Redis 存储 Token。

Java 100.00%

spring-restful-authorization's Introduction

###简介

关于Demo的介绍可以参考RESTful登录设计(基于Spring及Redis的Token鉴权)

###演示方式

  1. 下载该项目并修改application.properties文件,将MySQL和Redis的信息修改为自己的配置
  2. 打开init.sql文件,将其中的sql语句在MySQL中运行
  3. 通过mvn spring-boot:run启动项目,如果日志输出Started Application in 8.112 seconds (JVM running for 14.491)说明启动成功
  4. 浏览器打开localhost:8080,可以看到swagger-ui的主页
  5. 演示登录:在该页面打开POST tokens/,在username项输入admin、password项输入password,点击Try it out!,查看返回结果得到userId和token
  6. 演示退出登录:在该页面打开DELETE tokens/,在authorization中填写用userId和token以"_"拼接得到的字符串,点击Try it out!,如果返回码为200则成功。重复一次操作,返回码将变为401

###可能会遇到的问题:

java.lang.ClassNotFoundException: org.jboss.jandex.IndexView

原因是缺少org.jboss:jandex:1.1.0Final依赖,可能需要您手动在pom.xml中依赖中添加以下内容:

<dependency>
    <groupId>org.jboss</groupId>
    <artifactId>jandex</artifactId>
    <version>1.1.0.Final</version>
</dependency>

感谢@yrain的反馈!

###其他

如果这个Demo的功能刚好可以满足你的需求,在这里推荐我根据其封装的库:Spring Authorization Manager,希望能帮助你完成API服务端的身份验证功能。

spring-restful-authorization's People

Contributors

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