Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alvachien
spring-auth-server-demo
提交
5c78b9c2
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,发现更多精彩内容 >>
提交
5c78b9c2
编写于
12月 25, 2022
作者:
alvachien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update resource server and readme
上级
3af759d1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
49 addition
and
23 deletion
+49
-23
readme.md
readme.md
+14
-2
resource-server-demo/pom.xml
resource-server-demo/pom.xml
+8
-2
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/config/ResourceServerConfig.java
...chien/resourceserverdemo/config/ResourceServerConfig.java
+8
-3
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/controller/ProtectedController.java
...en/resourceserverdemo/controller/ProtectedController.java
+0
-1
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/controller/PublicController.java
...chien/resourceserverdemo/controller/PublicController.java
+3
-5
resource-server-demo/src/main/resources/application.properties
...rce-server-demo/src/main/resources/application.properties
+0
-10
resource-server-demo/src/main/resources/application.yml
resource-server-demo/src/main/resources/application.yml
+16
-0
未找到文件。
readme.md
浏览文件 @
5c78b9c2
...
...
@@ -4,7 +4,7 @@ It's a demo project for spring-auth-server.
This project consist of following three sub-projects.
##
spring-
auth-server-demo
## auth-server-demo
Auth. server, including identity management.
...
...
@@ -39,8 +39,19 @@ Dependencies:
-
SQL Server 2019;
-
Spring Auth Server;
## idp-server-demo
## spring-resource-server-demo
Identity server demo.
Dependencies:
-
Java 17;
-
Spring Boot 3.0;
-
Spring Boot JPA;
-
Spring Boot Web;
-
SQL Server 2019;
-
Spring Auth Server;
## resource-server-demo
Resource server.
...
...
@@ -57,6 +68,7 @@ Dependencies:
-
SQL Server 2019;
-
Resource Server;
## angular-client-demo
An angular client which consume that resources.
...
...
resource-server-demo/pom.xml
浏览文件 @
5c78b9c2
...
...
@@ -35,10 +35,16 @@
</dependency>
<dependency>
<groupId>
org.postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<groupId>
com.microsoft.sqlserver
</groupId>
<artifactId>
mssql-jdbc
</artifactId>
<version>
11.2.1.jre17
</version>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-test
</artifactId>
...
...
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/config/ResourceServerConfig.java
浏览文件 @
5c78b9c2
package
com.poc.alvachien.resourceserverdemo.config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.web.SecurityFilterChain
;
@EnableWebSecurity
@Configuration
(
proxyBeanMethods
=
false
)
public
class
ResourceServerConfig
{
@Bean
SecurityFilterChain
securityFilterChain
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
requestMatchers
(
"/api/protected/**"
).
authenticated
()
.
requestMatchers
(
"/"
).
permitAll
();
.
securityMatcher
(
"/api/protected/**"
)
.
authorizeHttpRequests
()
.
requestMatchers
(
"/api/protected/**"
).
hasAuthority
(
"SCOPE_message.read"
)
.
and
()
.
oauth2ResourceServer
()
.
jwt
();
return
http
.
build
();
}
}
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/controller/ProtectedController.java
浏览文件 @
5c78b9c2
...
...
@@ -3,7 +3,6 @@ package com.poc.alvachien.resourceserverdemo.controller;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RequestParam
;
@RestController
...
...
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/controller/
NonProtected
Controller.java
→
resource-server-demo/src/main/java/com/poc/alvachien/resourceserverdemo/controller/
Public
Controller.java
浏览文件 @
5c78b9c2
...
...
@@ -3,14 +3,12 @@ package com.poc.alvachien.resourceserverdemo.controller;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RequestParam
;
@RestController
@RequestMapping
(
"/api/
NonProtected
"
)
public
class
NonProtected
Controller
{
@RequestMapping
(
"/api/
Public
"
)
public
class
Public
Controller
{
@GetMapping
(
"/sayhi"
)
public
String
sayhi
()
{
return
"Say hi from
Non-Protected
"
;
return
"Say hi from
Public
"
;
}
}
resource-server-demo/src/main/resources/application.properties
已删除
100644 → 0
浏览文件 @
3af759d1
server.port
:
9500
spring.security.oauth2.resourceserver.jwt.issuer-uri
=
http://localhost:9600
spring.jpa.hibernate.ddl-auto
=
update
spring.datasource.url
=
jdbc:sqlserver://localhost;encrypt=true;database=authresource;integratedSecurity=true;trustServerCertificate=true
#spring.datasource.username=springuser
#spring.datasource.password=ThePassword
spring.datasource.driver-class-name
=
com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql
:
true
resource-server-demo/src/main/resources/application.yml
0 → 100644
浏览文件 @
5c78b9c2
server
:
port
:
8090
logging
:
level
:
root
:
INFO
org.springframework.web
:
INFO
org.springframework.security
:
INFO
org.springframework.security.oauth2
:
INFO
spring
:
security
:
oauth2
:
resourceserver
:
jwt
:
issuer-uri
:
http://localhost:9000
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录