Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alvachien
spring-auth-server-demo
提交
b79952a5
S
spring-auth-server-demo
项目概览
alvachien
/
spring-auth-server-demo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-auth-server-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b79952a5
编写于
12月 28, 2022
作者:
alvachien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new codes
上级
5c78b9c2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
20 deletion
+99
-20
readme.md
readme.md
+92
-16
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/config/ResourceServerConfig.java
...chien/resourceserverdemo/config/ResourceServerConfig.java
+6
-3
resource-server-demo/src/main/resources/application.yml
resource-server-demo/src/main/resources/application.yml
+1
-1
未找到文件。
readme.md
浏览文件 @
b79952a5
# spring-auth-server-demo
It's a demo project for spring-auth-server.
It's a demo project for learning spring-auth-server.
This project consists of four sub-projects which described below.
## How to run this demo?
### Run with Docker (Postgres)
How to run this demo? Follows the steps below:
-
Ensure Docker is running;
-
Create the Docker storage
```
PowerShell
docker volume create idp_local
```
-
Create DB instance in Docker
```
PowerShell
docker run -d --platform linux/amd64 -e POSTGRES_HOST_AUTH_METHOD=trust -v idp_local:/var/lib/postgresql/data --name postgres-idp-db -p 5432:5432 -d postgres:12-alpine
```
-
Start the Auth. Server
```
PowerShell
cd .\auth-server-demo\ && mvn install && mvn spring-boot:run
```
-
Start the IDP. Server
```
PowerShell
cd .\idp-server-demo\ && mvn install && mvn spring-boot:run
```
-
Start the Resource Server
```
PowerShell
cd .\resource-server-demo\ && mvn install && mvn spring-boot:run
```
-
Todo: start the angular
```
PowerShell
cd .\angular-client-demo\ && npm run start
```
### Run without Docker (SQL Server Express)
Ensure the SQL Server (express) is running.
-
Start the Auth. Server
```
PowerShell
cd .\auth-server-demo\ && mvn install && mvn spring-boot:run
```
-
Start the IDP. Server
```
PowerShell
cd .\idp-server-demo\ && mvn install && mvn spring-boot:run
```
-
Start the Resource Server
```
PowerShell
cd .\resource-server-demo\ && mvn install && mvn spring-boot:run
```
-
Todo: start the angular
```
PowerShell
cd .\angular-client-demo\ && npm run start
```
## Mapping table of ports
|Port|Application|
|--|----|
|9000|Auth. server|
|8080|IDP server|
|8090|Resource server|
|TBD|Angular client|
This project consist of following three sub-projects.
## auth-server-demo
Auth. server, including identity management.
Auth. server is a project built on Spring Authorization Server, which only focus on creating token and validating tokens.
This project embeds the learnings through the following documents:
-
[
How-to: Implement core services with JPA
](
https://docs.spring.io/spring-authorization-server/docs/current/reference/html/guides/how-to-jpa.html
)
...
...
@@ -26,7 +107,6 @@ This article adds the JPA implementations to client/authorization/authorization-
-
[
Spring Boot + Spring Security + Thymeleaf
](
https://www.jianshu.com/p/dcf227d53ab5
)
-
[
Source repository
](
https://github.com/Smith-Cruise/Spring-Boot-Security-Thymeleaf-Demo
)
To be read?
-
[
Spring Security ACL
](
https://www.jianshu.com/p/b971b4e6ec16
)
...
...
@@ -36,39 +116,35 @@ Dependencies:
-
Spring Boot 3.0;
-
Spring Boot JPA;
-
Spring Boot Web;
-
SQL Server 2019
;
-
Postgres 12
;
-
Spring Auth Server;
## idp-server-demo
Identity server demo.
Identity Provider Server. This server will handle the user management, role assignment, etc.
Dependencies:
-
Java 17;
-
Spring Boot 3.0;
-
Spring Boot JPA;
-
Spring Boot Web;
-
SQL Server 2019
;
-
Spring
Auth Server
;
-
Postgres 12
;
-
Spring
Security OAuth2 Client
;
## resource-server-demo
Resource server.
Related documents:
-
[
Spring Boot Resource Server
](
https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/index.html
)
-
[
Resource Server samples
](
https://github.com/spring-projects/spring-security-samples/tree/main/servlet/spring-boot/java/oauth2/resource-server
)
## resource-server-demo
Resource server is a server which exposing the API for usages.
Dependencies:
-
Java 17;
-
Spring Boot 3.0;
-
Spring Boot JPA;
-
Spring Boot Web;
-
SQL Server 2019
;
-
Postgres 12
;
-
Resource Server;
## angular-client-demo
An angular client which consume that resources.
...
...
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/config/ResourceServerConfig.java
浏览文件 @
b79952a5
...
...
@@ -16,9 +16,12 @@ public class ResourceServerConfig {
.
securityMatcher
(
"/api/protected/**"
)
.
authorizeHttpRequests
()
.
requestMatchers
(
"/api/protected/**"
).
hasAuthority
(
"SCOPE_message.read"
)
.
and
()
.
oauth2ResourceServer
()
.
jwt
();
.
requestMatchers
(
"/api/public/**"
).
permitAll
()
.
and
()
.
oauth2ResourceServer
()
.
jwt
()
;
return
http
.
build
();
}
}
resource-server-demo/src/main/resources/application.yml
浏览文件 @
b79952a5
...
...
@@ -13,4 +13,4 @@ spring:
oauth2
:
resourceserver
:
jwt
:
issuer-uri
:
http://localhost:9000
\ No newline at end of file
issuer-uri
:
http://localhost:9000
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录