提交 b79952a5 编写于 作者: alvachien's avatar alvachien

Add new codes

上级 5c78b9c2
# 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.
......
......@@ -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();
}
}
......@@ -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.
先完成此消息的编辑!
想要评论请 注册