# SpringBootSecurityDemo **Repository Path**: dezhe/spring-boot-security-demo ## Basic Information - **Project Name**: SpringBootSecurityDemo - **Description**: 基于spring security权限做的一个小demo - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-14 - **Last Updated**: 2021-06-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SpringBootSecurityDemo #### 介绍 基于spring security权限做的一个小demo,并且结合OAuth2协议进行第三方认证 **一、第一步(选择其中一种,授权码最安全推荐)** 1. 授权码模式: http://url:port/oauth/authorize?client_id=自定义的客户端id&client_secret=客户端密码&response_type=code 2. 简化模式: http://url:port/oauth/authorize?client_id=自定义的客户端id&client_secret=客户端密码&response_type=token 3. 密码模式: http://url:port/oauth/token?client_id=自定义的客户端id&client_secret=客户端密码&grant_type=password&username=zhang&password=123 4. 客户端模式: http://url:port/oauth/token?client_id=自定义的客户端id&client_secret=客户端密码&grant_type=client_credentials **二、第二步** - 将返回的授权码添加在 http://url:port/oauth/token?client_id=自定义的客户端id&client_secret=客户端密码&grant_type=authorization_code&code=返回的code码 ``` 获取token { "access_token": "bb2e012f-cab7-4146-9fad-1898d9354bc1", //有效token,只能使用一次,多次无效 "token_type": "bearer", //token类型 "refresh_token": "62cfd543-b8f8-48ae-8bc8-8eba963cfb12", //刷新token "expires_in": 7199, //token过期时间 "scope": "all" //作用范围 } ``` **三、第三步** - 将有效的token放在请求头中,并进行访问资源: ``` key value Authorization bearer bb2e012f-cab7-4146-9fad-1898d9354bc1 ``` 备注:http://url:port/oauth/check_token?token=bb2e012f-cab7-4146-9fad-1898d9354bc1 这个是用来检查当前token的信息、访问权限等。 1. 这里是列表文本