Skip to content

Commit 6a0f87c

Browse files
committed
chore: 去除dockerfile,使用jib打包docker镜像
调整client账号dml,去除httpclient5的版本,使用父pom的依赖
1 parent 4e88f88 commit 6a0f87c

6 files changed

Lines changed: 8 additions & 73 deletions

File tree

pom.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
<groupId>io.github.opensabre</groupId>
3838
<artifactId>opensabre-starter-rpc</artifactId>
3939
</dependency>
40-
<dependency>
41-
<groupId>org.apache.httpcomponents.client5</groupId>
42-
<artifactId>httpclient5</artifactId>
43-
<version>5.4.1</version>
44-
</dependency>
4540
<dependency>
4641
<groupId>io.github.opensabre</groupId>
4742
<artifactId>opensabre-starter-cache</artifactId>
@@ -104,21 +99,6 @@
10499
<plugin>
105100
<groupId>com.google.cloud.tools</groupId>
106101
<artifactId>jib-maven-plugin</artifactId>
107-
<configuration>
108-
<pluginExtensions>
109-
<pluginExtension>
110-
<implementation>com.google.cloud.tools.jib.maven.extension.ownership.JibOwnershipExtension</implementation>
111-
<configuration implementation="com.google.cloud.tools.jib.maven.extension.ownership.Configuration">
112-
<rules>
113-
<rule>
114-
<glob>/app/**</glob>
115-
<ownership>1001</ownership>
116-
</rule>
117-
</rules>
118-
</configuration>
119-
</pluginExtension>
120-
</pluginExtensions>
121-
</configuration>
122102
</plugin>
123103
</plugins>
124104
</build>

readme.md

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
启动应用:`mvn spring-boot:run`
2121

22-
docker镜像打包:`mvn docker:build`
22+
docker镜像打包:`mvn jib:build`
2323

2424
应用地址:`http://localhost:8000`
2525

@@ -59,39 +59,6 @@ password: `password`
5959

6060
### 接口测试
6161

62-
#### 密码模式,grant_type=password
63-
64-
用途:可用于用户通过前端应用登陆、使用应用,如app,web等终端
65-
66-
![postman](../../docs/auth/oauth2_password_token_auth.png)
67-
68-
![postman](../../docs/auth/oauth2_password_token.png)
69-
70-
请求报文
71-
72-
```
73-
POST /oauth2/token?scope=read&grant_type=password HTTP/1.1
74-
Host: localhost:8000
75-
Authorization: Basic dGVzdF9jbGllbnQ6dGVzdF9zZWNyZXQ=
76-
Cache-Control: no-cache
77-
Content-Type: application/x-www-form-urlencoded
78-
79-
username=zhoutaoo&password=password
80-
```
81-
响应报文
82-
83-
```
84-
{
85-
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJ6aG91dGFvbyIsInNjb3BlIjpbInJlYWQiXSwib3JnYW5pemF0aW9uIjoiemhvdXRhb28iLCJleHAiOjE1MzE5NzM4MTgsImF1dGhvcml0aWVzIjpbIkFETUlOIiwiSVQiXSwianRpIjoiNTFiODY4ZDEtMGNlMS00ZmI4LTkwMWQtOWM3YmZmYzBhZGJiIiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnQifQ.BlIryRbSL414rDv5EfzZSjpjvWybcX3hEJy3fV8l6Wo",
86-
"token_type": "bearer",
87-
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJ6aG91dGFvbyIsInNjb3BlIjpbInJlYWQiXSwib3JnYW5pemF0aW9uIjoiemhvdXRhb28iLCJhdGkiOiI1MWI4NjhkMS0wY2UxLTRmYjgtOTAxZC05YzdiZmZjMGFkYmIiLCJleHAiOjE1MzQ1MjI2MTgsImF1dGhvcml0aWVzIjpbIkFETUlOIiwiSVQiXSwianRpIjoiMGU2N2Q5MDEtOThlMC00ZTk3LTkwNzgtODllMTBmZTRjOGI2IiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnQifQ.zNtWWG8xxPsjTZKghOjyGNDjnhHqnPvikfqN1uynh3U",
88-
"expires_in": 43199,
89-
"scope": "read",
90-
"organization": "zhoutaoo",
91-
"jti": "51b868d1-0ce1-4fb8-901d-9c7bffc0adbb"
92-
}
93-
```
94-
9562
#### 客户端模式,grant_type=client_credentials
9663

9764
用途:可用于接口开放给第三方商户,商户申请client_id和密码,即可调用授权的接口
@@ -267,14 +234,4 @@ public JwtAccessTokenConverter accessTokenConverter() {
267234
converter.setSigningKey(signingKey);
268235
return converter;
269236
}
270-
```
271-
272-
* jwt对称密钥配置项
273-
274-
```
275-
spring:
276-
security:
277-
oauth2:
278-
jwt:
279-
signingKey: 123456
280237
```

src/main/docker/Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/io/github/opensabre/authorization/config/AuthorizationServerConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
9999
clientAuthentication
100100
.authenticationConverter(deviceClientAuthenticationConverter)
101101
.authenticationProvider(deviceClientAuthenticationProvider)
102+
// .errorResponseHandler(errorResponseHandler)
102103
);
103104
// 未通过身份验证异常时重定向到登录页面授权端点(通过浏览器访问时)
104105
httpSecurity.exceptionHandling((exceptions) -> exceptions.defaultAuthenticationEntryPointFor(

src/main/java/io/github/opensabre/authorization/config/AuthorizationServiceConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public OAuth2TokenGenerator<?> tokenGenerator() {
7676

7777
/**
7878
* 自定义JWT token内容
79+
* 将用户角色放入token中
7980
*
8081
* @return token自定义
8182
*/

src/main/resources/db/os-base-auth-ddl.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ CREATE TABLE oauth2_registered_client
7676
) COMMENT 'client记录表';
7777
CREATE UNIQUE INDEX ux_client_id ON oauth2_registered_client (client_id);
7878

79-
INSERT INTO `oauth2_registered_client` VALUES ('1759610473724018690','test_client2','2024-02-20 00:06:43','$2a$10$At0g9cWs/kb.od3qX/WvRezgfJ5rfZNmWbfWUYHGpu13HLDvrDDVG','2024-12-20 02:06:40','test','client_secret_basic','client_credentials,authorization_code','https://www.baidu.com','https://www.baidu.com','read','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:06:44','2024-02-20 00:06:44','system','system'),
80-
('1759611655041441793','test_client1','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2025-12-20 02:11:21','test','client_secret_basic','client_credentials,authorization_code,refresh_token','http://www.opensabre.cloud:8443/login/oauth2/code/test_client1-client','http://www.opensabre.cloud:8443/login/oauth2/code/test_client1-client','read,openid,profile','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":7200,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system'),
81-
('1759611655041449999','device-message-client','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2024-12-20 02:11:21','设备码授权客户端','none','urn:ietf:params:oauth:grant-type:device_code,refresh_token','','','read,write','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system'),
82-
('1759611655061449999','pkce-message-client','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2024-12-20 02:11:21','PKCE客户端','none','authorization_code,refresh_token','http://127.0.0.1:8000/login/oauth2/code/messaging-client-oidc','http://127.0.0.1:8000/login/oauth2/code/messaging-client-oidc','read,write','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system');
79+
INSERT INTO `oauth2_registered_client` VALUES ('1759610473724018690','test_client2','2024-02-20 00:06:43','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2030-12-20 02:06:40','test','client_secret_basic','client_credentials,authorization_code','https://www.baidu.com','https://www.baidu.com','read','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:06:44','2024-02-20 00:06:44','system','system'),
80+
('1759611655041441793','test_client1','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2030-12-20 02:11:21','test','client_secret_basic','client_credentials,authorization_code,refresh_token','http://localhost:8443/login/oauth2/code/base-gateway-client','http://localhost:8443/login/oauth2/code/base-gateway-client','read,openid,profile','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":7200,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system'),
81+
('1759611655041441794','base-gateway','2025-11-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2030-12-20 02:11:21','opensabre网关','client_secret_basic','client_credentials,authorization_code,refresh_token','http://www.opensabre.cloud:443/login/oauth2/code/base-gateway-client','http://wwww.opensabre.cloud:443/login/oauth2/code/base-gateway-client','read,openid,profile','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":7200,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600}','N','2025-11-20 00:11:25','2025-11-20 00:11:25','system','system'),
82+
('1759611655041449998','device-message-client','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2030-12-20 02:11:21','设备码授权客户端','none','urn:ietf:params:oauth:grant-type:device_code,refresh_token','','','read,write','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system'),
83+
('1759611655061449999','pkce-message-client','2024-02-20 00:11:25','$2a$10$Nq7LumxAsVmEqQY.0cK.eu2sh1elC4ktmgfG37Syl3Opop0zT/4dC','2030-12-20 02:11:21','PKCE客户端','none','authorization_code,refresh_token','http://localhost:8000/login/oauth2/code/messaging-client-oidc','http://localhost:8000/login/oauth2/code/messaging-client-oidc','read,write','{\"settings.client.require-proof-key\":false,\"settings.client.require-authorization-consent\":true}','{\"settings.token.reuse-refresh-tokens\":true,\"settings.token.id-token-signature-algorithm\":\"RS256\",\"settings.token.access-token-time-to-live\":300.000000000,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.000000000}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system');
8384

0 commit comments

Comments
 (0)