Skip to content

Commit d1cd77d

Browse files
committed
chore: 补充授权模块工程配置
1 parent cbd29ef commit d1cd77d

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17.0.8.1

AGENTS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
5+
This is a Java 17 Maven service for an OAuth2 authorization server. Main code lives in `src/main/java/io/github/opensabre/authorization`, organized by responsibility: `config`, `oauth2`, `service`, `dao`, `entity`, `provider`, `rest`, and `exception`. Runtime configuration is in `src/main/resources/application.yml` and `bootstrap.yml`. SQL initialization scripts are in `src/main/resources/db`. Thymeleaf pages are in `src/main/resources/templates`, and static CSS/images are in `src/main/resources/static/assets`. Tests mirror the main package under `src/test/java`; test configuration is in `src/test/resources/application.yml`.
6+
7+
## Build, Test, and Development Commands
8+
9+
- `mvn test`: runs JUnit 5/Spring Boot tests, using H2 where configured for test database behavior.
10+
- `mvn package`: compiles, tests, and builds the executable JAR under `target/`.
11+
- `mvn spring-boot:run`: starts the service locally. The README expects the app at `http://localhost:8000`.
12+
- `mvn jib:build`: builds and pushes the container image via the configured Jib Maven plugin.
13+
- `mvn -Pnative package`: runs the native profile when GraalVM/native tooling is available.
14+
15+
Before local startup, provision MySQL, RabbitMQ, and Nacos, then apply the DDL/DML scripts from `src/main/resources/db`.
16+
17+
## Coding Style & Naming Conventions
18+
19+
Use Java 17 and the existing Spring Boot style. Keep package names under `io.github.opensabre.authorization`. Use 4-space indentation, constructor or resource injection consistently with surrounding classes, and clear suffixes such as `Controller`, `Service`, `ServiceImpl`, `Mapper`, `Config`, `Provider`, `Po`, `Vo`, `Form`, and `Param`. Prefer descriptive method names and keep OAuth2/security configuration changes localized to `config` or `oauth2`.
20+
21+
## Testing Guidelines
22+
23+
Tests use JUnit 5 with `spring-boot-starter-test`; integration-style tests may use `@SpringBootTest`. Name test classes with the `*Test` suffix and place them in the matching package under `src/test/java`. For persistence or conversion logic, add focused tests near existing examples such as `RegisteredClientMapperTest` and `RegisteredClientConvertTest`. Run `mvn test` before submitting changes.
24+
25+
## Commit & Pull Request Guidelines
26+
27+
Recent history uses short Chinese commit subjects and occasional Conventional Commit prefixes, for example `fix: 修复token有效期问题` and `chore: 添加swagger文档标题`. Prefer `fix:`, `chore:`, `feat:`, or `test:` plus a concise summary. Pull requests should describe the behavior changed, list verification commands, note configuration or database script changes, and link related issues. Include screenshots only for template or static asset UI changes.
28+
29+
## Security & Configuration Tips
30+
31+
Do not commit real client secrets, database passwords, registry credentials, or private keys. Keep environment-specific values in external configuration or deployment secrets, and treat the README sample credentials as local/demo data only.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +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$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');
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.0,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.0}','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.0}','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.0,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.0}','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.0,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.0}','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.0,\"settings.token.access-token-format\":{\"value\":\"self-contained\"},\"settings.token.refresh-token-time-to-live\":3600.0}','N','2024-02-20 00:11:25','2024-02-20 00:11:25','system','system');
8484

0 commit comments

Comments
 (0)