当前位置: 首页 > news >正文

Spring Authorization Server 认证服务器搭建

Spring Authorization Server实现了oauth2和oidc,最近有了解相关技术的需求,所以就尝试着进行了基本的环境搭建和技术测试,目前只测试了授权码模式,做一个记录,后续需要用时方便查找和参考。

1. 版本要求

Spring Authorization Server 版本:1.3.1
JDK 版本:17
Spring Boot 版本:3.3.2

2. pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.3.2</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.zxkj</groupId><artifactId>auth-server</artifactId><version>0.0.1-SNAPSHOT</version><name>auth-server</name><description>Demo project for Spring Boot</description><url/>    <properties><java.version>17</java.version></properties><dependencies><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><scope>test</scope></dependency><!--Spring Authorization Server--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-oauth2-authorization-server</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

3. 安全配置文件

package com.zxkj.authserver;import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
import com.nimbusds.jose.jwk.source.ImmutableJWKSet;
import com.nimbusds.jose.jwk.source.JWKSource;
import com.nimbusds.jose.proc.SecurityContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenti
http://www.lryc.cn/news/427778.html

相关文章:

  • 秋招突击——8/15——知识补充——垃圾回收机制
  • 【iOS】UITableViewCell的重用问题解决方法
  • 开发一个微信小程序商城需要哪些技术栈
  • 望繁信科技荣膺上海市浦东新区博士后创新实践基地称号
  • Nginx--代理与负载均衡(扩展nginx配置7层协议及4层协议方法、会话保持)
  • Ubuntu20.4 系统安装后无wifi图标
  • 牛客网SQL进阶135 :每个6/7级用户活跃情况
  • SQLite3使用接口写入二进制文件
  • 在复杂的数据库架构中,如何优化 SQL 查询以提高性能和减少资源消耗?
  • 【HarmonyOS】端云一体化初始化项目
  • LLM之KG:利用大语言模型(LLM)对文本语料提取概念和概念之间的语义关系进而实现自动构建知识图谱
  • Spring Security 6如何使用?
  • PyTorch深度学习快速入门教程--学习笔记
  • SQLALchemy 分组过滤、子查询
  • 华为od(D卷) 环中最长子串/字符成环找偶数LOX
  • 机器学习--常见算法总结
  • QT 网络聊天室简易版
  • Linux_Shell三剑客grep,awk,sed-08
  • uniapp实现足球数据分析平台移动端H5
  • Redis5优化-Redis
  • Element UI【详解】el-scrollbar 滚动条组件
  • 【精选】基于Python大型购物商城系统(京东购物商城,淘宝购物商城,拼多多购物商城爬虫系统)
  • QT翻金币小游戏(含音频图片文件资源)
  • Linux配置JDK8环境变量
  • Fiddle抓手机app的包
  • Oracle+ASM+High冗余详解及空间计算
  • 如何为 Nextcloud 配置自动数据库备份 - 应用程序
  • child_process.spawn简介
  • 整理给测试人看的千页面试题
  • Linux 内核中的并发与竞争