OAuth2入门

news2024/10/7 12:26:35

1.下载资源

演示代码:

OAuth2-example: 演示OAuth2的认证流程https://gitee.com/lisenaq/oauth2-example

 克隆下载到本地:

 导入项目:

        

client    客户
authorization-server    认证服务
resource-owner     资源所有者
resource-server    资源服务器

流程:
客户向资源所有者申请授权码
资源所有者下发授权码
客户拿到授权码后向认证服务器申请令牌
认证服务器接到申请下方令牌
客户获取令牌后向资源服务器请求数据

 2.必须配置的资源

<dependencies>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
application.yml
spring:
application:
name: OAuth2-client
server:
port: 8080

认证服务器:

pom.xml
<dependencies>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.authzserver </artifactId>
</dependency>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.resourceserver </artifactId>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-web </artifactId>
</dependency>
<dependency>
<groupId> org.projectlombok </groupId>
<artifactId> lombok </artifactId>
<optional> true </optional>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-test </artifactId>
<scope> test </scope>
</dependency>
</dependencies>
application.yml
spring:
application:
name: OAuth2-authorization-server
server:
port: 8081

资源拥有者

 

<dependencies>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.authzserver </artifactId>
</dependency>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.resourceserver </artifactId>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-web </artifactId>
</dependency>
<dependency>
<groupId> org.projectlombok </groupId>
<artifactId> lombok </artifactId>
<optional> true </optional>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-test </artifactId>
<scope> test </scope>
</dependency>
</dependencies>

application.yml

 

spring :
application :
name : OAuth2-resource-owner
server :
port : 8082

资源服务器

 

pom.xml
<dependencies>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.authzserver </artifactId>
</dependency>
<dependency>
<groupId> org.apache.oltu.oauth2 </groupId>
<artifactId> org.apache.oltu.oauth2.resourceserver </artifactId>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-web </artifactId>
</dependency>
<dependency>
<groupId> org.projectlombok </groupId>
<artifactId> lombok </artifactId>
<optional> true </optional>
</dependency>
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-test </artifactId>
<scope> test </scope>
</dependency>
</dependencies>
application.yml
spring :
application :
name : oauth2-resource-server
server :
port : 8083

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/195560.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

儿童台灯哪个品牌更护眼推荐?儿童书桌台灯品牌排行榜

不难发现&#xff0c;近些年我国儿童近视率增长迅速&#xff0c;随着生活条件越来越好&#xff0c;对电子章产品的普及非常广泛&#xff0c;每个家庭的孩子必不可少的就是伏案完成作业&#xff0c;这样的话就需要使用到台灯&#xff0c;选购台灯的时候最好选择适合儿童的专业护…

【算法基础】高精度加法

&#x1f466;个人主页&#xff1a;Weraphael ✍&#x1f3fb;作者简介&#xff1a;目前是C语言学习者 ✈️专栏&#xff1a;【C/C】算法 &#x1f40b; 希望大家多多支持&#xff0c;咱一起进步&#xff01;&#x1f601; 如果文章对你有帮助的话 欢迎 评论&#x1f4ac; 点赞…

一篇五分生信临床模型预测文章代码复现——FIgure 9.列线图构建,ROC分析,DCA分析 (三)

之前讲过临床模型预测的专栏,但那只是基础版本,下面我们以自噬相关基因为例子,模仿一篇五分文章,将图和代码复现出来,学会本专栏课程,可以具备发一篇五分左右文章的水平: 本专栏目录如下: Figure 1:差异表达基因及预后基因筛选(图片仅供参考) Figure 2. 生存分析,…

axios实战学习——使用高德地图api接口数据实现天气查询案例

文章目录&#x1f4cb;前言&#x1f3af;案例介绍&#x1f9e9;关于高德开发平台1️⃣创建应用生成Key2️⃣查看API文档&#x1f9e9;测试接口&#x1f3af;案例编写&#x1f3af;实现效果&#x1f4cb;前言 关于这个Vue axios 获取接口数据的操作&#xff0c;这篇文章就不过…

UniRx之基础入门

什么是Rx 官方ReactiveX简介&#xff1a; An API for asynchronous programming with observable streams。 通过这句话我们可以得到&#xff1a; 1.首先Rx是个编程接口&#xff0c;不同语言提供不同实现。例如JVM语言中的RxJava。 2.使用场景&#xff0c;异步编程中。 3.基…

路由器 内核开发 流程

宽 带上网已经不是什么新鲜事情&#xff0c;人们对相关的网络器件已经不再陌生&#xff0c;比如说常见的路由器。对于一般的网络用户&#xff0c;他们能知道怎样使用路由器来上网、玩游戏等就 已经感到很满足了&#xff0c;通常情况下对路由器的深层技术很少去过问研究&#xf…

Matlab和PCL中的点云滤波

而在PCL中总结了几种需要进行点云滤波处理的情况&#xff0c;这几种情况分别是&#xff1a; (1)点云数据密度不规则需要平滑。 (2)因为遮挡等问题造成离群点需要去除。 (3)大量数据需要进行“下采样”(Downsample)。 (4)噪声数据需要去除。 对应的解决方法是&#xff1a; (1)按…

什么是ITIL中的变更管理

商业环境和客户期望在不断变化&#xff0c;数字化转型已成为各行各业企业成功的关键因素。数字化转型的关键在于利用可用 应对业务挑战和抓住机遇的技术。当你分解它时&#xff0c;数字化转型基本上是信息技术管理更好地消除有问题的领域&#xff0c;并使您的 IT 基础架构能够应…

WebView缓存机制

一 前言 由于H5具备 开发周期短、灵活性好 的特点&#xff0c;所以现在 Android App大多嵌入了 Android Webview 组件进行 Hybrid 开发 但我知道你一定在烦恼 Android Webview 的性能问题&#xff0c;特别突出的是&#xff1a;加载速度慢 & 消耗流量 今天&#xff0c;我将…

Django 模型的继承

Django 模型的继承项目管理模型关联关系模块的包管理模型的继承项目管理 到目前为止&#xff0c;都是属于httprunner中的用例部分&#xff0c;针对核心功能进行的开发工作&#xff0c;要把平台做成一个用户可以使用的程度还需要些额外的功能&#xff0c;比如项目管理&#xff…

13薪| 8k-14k Java开发工程师

"众推职聘”以交付结果为宗旨的全流程化招聘服务平台&#xff01;今日招聘信息↓工作内容1.参与软件项目和产品概要设计&#xff0c;负责详细功能设计、编码实现及相关文档编写&#xff1b;2.根据模块设计完成相应的模块编码及单元测试&#xff1b;3.对用户行为、需求及反…

zeek集群简述

Zeek不是多线程的&#xff0c;因此&#xff0c;一旦达到单处理器内核的限制&#xff0c;当前唯一的选择就是将工作负载分散到多个内核&#xff0c;甚至多个物理计算机上。Zeek的集群部署场景是构建这些大型系统的当前解决方案。Zeek附带的工具和脚本提供了一种结构&#xff0c;…

自注意力和位置编码(比较卷积神经网络、循环神经网络和自注意力)

在自注意力中&#xff0c;查询、键和值都来自同一组输入。 卷积神经网络和自注意力都拥有并行计算的优势&#xff0c;而且自注意力的最大路径长度最短。但是因为其计算复杂度是关于序列长度的二次方&#xff0c;所以在很长的序列中计算会非常慢。 为了使用序列的顺序信息&…

Nostr with NIP-05 Verification Guide

What is a NIPNIPs (Nostr Implementation Possibilities) document what MUST, what SHOULD and what MAY be implemented by Nostr-compatible relay and client software. See a complete list of nips here.NIP-05 提案是针对用户 Nostr 帐户的验证方法&#xff0c;可以将其…

The update is not applicable to your computer

在安装windows CVE-2022-44698补丁的时候出现了报错&#xff0c;"Windows Update Standalone Installer The update is not applicable to your computer" 1.找到漏洞对应的官方文章 CVE-2022-44698 - Security Update Guide - Microsoft - Windows SmartScreen S…

学术科研无从下手?27 条机器学习避坑指南,让你的论文发表少走弯路

内容一览&#xff1a;如果你刚接触机器学习不久&#xff0c;并且未来希望在该领域开展学术研究&#xff0c;那么这份为你量身打造的「避坑指南」可千万不要错过了。 关键词&#xff1a;机器学习 科研规范 学术研究 机器学习学术小白&#xff0c;如何优雅避坑坑、让自己的论文顺…

力扣sql简单篇练习(九)

力扣sql简单篇练习(九) 1 合作过至少三次的演员和导演 1.1 题目内容 1.1.1 基本题目信息 1.1.2 示例输入输出 1.2 示例sql语句 SELECT actor_id,director_id FROM ActorDirector GROUP BY actor_id,director_id HAVING count(timestamp)>31.3 运行截图 2 患某种疾病的患…

结构体内存对齐;内存优化

结构体需要根据数据类型进行内存对齐。 所有数据类型占据空间的大小&#xff0c;一定是它基础类型的倍数。 首先按照最大的数据类型格式来作为最小分割单元。 最大整数倍 struct stu {char gender;unsigned int age; }student1;int main() {printf("sizeof this struct i…

SpringCloud Config分布式配置中心

目录 一、概述 二、Config服务端配置与测试 配置读取规则 三、Config客户端配置与测试 bootstrasp.yml 四、Config客户端之动态刷新 一、概述 官网&#xff1a;Spring Cloud Config 微服务意味着要将单体应用中的业务拆分成一个个子服务&#xff0c;每个服务的粒度相对…

【Java】IDEA调试线上服务

目录IEDA打开线上服务对应的代码&#xff0c;Edit Configuration创建与远程服务的连接复制黄匡生成的参数&#xff0c;添加到服务器启动命令中服务器的服务重新启动&#xff0c;并注意调试端口5005是否被防火墙拦截本地IDEA启动&#xff0c;控制台打印如图即成功代码上加断点&a…