Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: CI

on:
push:
branches: [2.3.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, 3.5.x, 4.0.x, 4.1.x]
branches: [main, test/20261119, 2.3.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, 3.5.x, 4.0.x, 4.1.x]
pull_request:
branches: [2.3.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, 3.5.x, 4.0.x, 4.1.x]
branches: [main, 2.3.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, 3.5.x, 4.0.x, 4.1.x]

permissions:
contents: read

jobs:
build:
uses: easy-4-java/.github/.github/workflows/maven-starter-ci.yml@main
with:
version-line: ${{ ( (github.base_ref || github.ref_name) == 'main' || (github.base_ref || github.ref_name) == 'test/20261119' ) && '2.3.x' || '' }}
secrets: inherit
105 changes: 47 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@

**Spring Boot Starter for security-yiban**

[![Maven Central](https://img.shields.io/maven-central/v/io.github.easy4j/security-yiban-spring-boot-starter)](https://github.com/easy-4-java/security-yiban-spring-boot-starter)
[![Java](https://img.shields.io/badge/Java-17-orange)](#3-requirements-and-compatibility)
[![Java](https://img.shields.io/badge/Java-8-orange)](#3-requirements-and-compatibility)
[![License](https://img.shields.io/badge/license-Apache-2.0-green)](https://www.apache.org/licenses/LICENSE-2.0)

[简体中文](./README.zh-CN.md) | [English](./README.md)

[Positioning](#1-positioning) · [Capabilities](#2-core-capabilities) ·
[Dependency](#5-dependency) · [Quick Start](#6-quick-start) ·
[Configuration](#7-configuration-reference) · [Versions](#9-version-lines-and-compatibility) ·
[Build](#10-build-and-test) · [License](#12-license)
[Dependencies](#5-dependencies) · [Enable](#6-enable-yiban-configuration) ·
[Configuration](#7-configuration-reference) · [Versions](#8-version-lines-and-compatibility) ·
[Build](#9-build-and-test) · [License](#12-license)

</div>

---

> **Current Version**:`1.0.0-SNAPSHOT`<br>
> **JDK Baseline**:`17`<br>
> **JDK Baseline**:`8`<br>
> **Group ID**:`io.github.easy4j`<br>
> **Artifact ID**:`security-yiban-spring-boot-starter`<br>
> **License**:Apache License 2.0<br>
Expand All @@ -36,25 +35,35 @@
| Type | Spring Boot Starter |
| Consumers | Spring Boot applications using security-yiban |
| Core Capabilities | auto-configuration, property binding, ready-to-use beans for security-yiban |
| JDK | `17` |
| Coordinates | `io.github.easy4j:security-yiban-spring-boot-starter:1.0.0-SNAPSHOT` |
| Config Prefix | `security.yiban` |
| JDK | `8` |
| Source POM coordinates | `io.github.easy4j:security-yiban-spring-boot-starter:1.0.0-SNAPSHOT` |
| Config Prefix | `spring.security.yiban` |

## 2. Core Capabilities

| Capability | Status | Description |
|---|:---:|---|
| Auto-configuration | ✅ Stable | Registers security-yiban beans automatically |
| Property Binding | ✅ Stable | Binds `security.yiban.*` to `SecurityYibanAuthcProperties` |
| `Authorize` bean | ✅ Stable | Auto-registered via SecurityYibanAutoConfiguration |
| Auto-configuration | Declared in source | Registers security-yiban beans automatically |
| Property Binding | Declared in source | Binds `spring.security.yiban.authc.*` to `SecurityYibanAuthcProperties` |
| `Authorize` bean | Declared in source | Auto-registered via SecurityYibanAutoConfiguration |

## 3. Requirements and Compatibility

| Dependency | Minimum | Evidence |
|---|---:|---|
| JDK | `17` | `pom.xml` |
| Spring Boot | `2.3.0.RELEASE` | `pom.xml` parent |
| Maven | `3.6+` | Maven Enforcer |
| JDK | `8` | `pom.xml` |
| Spring Boot | `2.3.12.RELEASE` | `pom.xml` parent |
| Maven | `3.0` | Maven Enforcer |

For Boot 2.3 applications using the Boot parent, set `spring-framework.version` to `5.3.39` and
`spring-security.version` to `5.8.14` in the application POM. Security Biz is pinned to the Easy4J
snapshot build `2.7.x.20260630-20261029.080305-2`, which is verified with Boot 2.3.12 and JDK 8
in this starter. Use the Easy4J Maven snapshot settings when building or consuming it.

The build checks the SHA-256 of `YBOpenApi.jar` in the repository's `YBApi_sdk_java.zip`
and includes the SDK classes from the 2015-08-20 archive. It supplies a replacement HTTP transport
with the JVM's certificate trust and hostname verification, bounded timeouts and no redirects.
The starter no longer resolves `cn.yiban.open:java-sdk:1.6.0`.

## 4. Auto-configuration

Expand All @@ -68,65 +77,46 @@ The starter auto-configures the following beans:
| `YibanMatchedAuthenticationFailureHandler` | classpath + property | not created |
| `YibanAuthenticationProvider` | classpath + property | not created |

Auto-configuration registration:
The source declares configuration classes, while the Boot 2.3 discovery file
`META-INF/spring.factories` is absent. Verify configuration discovery and the
live Yiban sign-in flow before using this branch.

- `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports` (Spring Boot 2.7+ / 3.x / 4.x)
- `META-INF/spring.factories` (Spring Boot 2.x legacy)
## 5. Dependencies

## 5. Dependency
The build requires two artifacts that are currently unresolved:

```xml
<dependency>
<groupId>io.github.easy4j</groupId>
<artifactId>security-yiban-spring-boot-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
```
- `cn.yiban.open:java-sdk:1.6.0` for Yiban authorization and user APIs.
- `io.github.easy4j:security-biz-spring-boot-starter:1.0.9-SNAPSHOT` for shared Spring Security components.

No additional easy4j component dependencies.
The [official Yiban Java download](https://open.yiban.cn/wiki/download/oauth_java.7z)
contains a Servlet authorization example. The archive does not contain the Maven
SDK JAR. Resolve both artifacts from a trusted repository and verify the Java 8
build and Yiban integration before using any release coordinates.

## 6. Quick Start
The historical Security Biz `1.0.9` source used earlier organization coordinates. Independent resolution from the configured Aliyun repository found neither `1.0.9-SNAPSHOT` nor the Boot 2.3 maintenance snapshot `2.3.x.20260630-SNAPSHOT` under the Easy4J coordinates. Moving to the maintained line also requires verification of Spring Security and authentication error compatibility.

### 6.1 Add dependency
## 6. Enable Yiban configuration

Add the dependency above to your `pom.xml`.

### 6.2 Configure
For an application that already loads the Yiban configuration:

```yaml
security.yiban:
enabled: true
```

### 6.3 Use the bean

```java
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```

Then inject the auto-configured bean in your code:

```java
@Autowired
private Authorize yibanAuthorize;
spring:
security:
yiban:
enabled: true
```

## 7. Configuration Reference

### 7.1 Config Prefix

`security.yiban`
`spring.security.yiban`

### 7.2 Configuration Items

| Property | Type | Default | Required | Description | Sensitive |
|---|---|---|:---:|---|:---:|
| `security.yiban.enabled` | boolean | `true` | No | Enable the starter | No |
| `spring.security.yiban.enabled` | boolean | `false` | No | Enable the starter | No |
<!-- additional properties below -->

## 8. Version Lines and Compatibility
Expand All @@ -135,20 +125,19 @@ private Authorize yibanAuthorize;
|---|---:|---:|---|:---:|
| `2.3.x` / `2.7.x` | `8+` | 2.3.x / 2.7.x | `1.0.x` | Maintenance |
| `3.0.x` ~ `3.5.x` | `17` | 3.x | `2.0.x` | Maintenance |
| `4.0.x` / `4.1.x` | `17+` | 4.x | `3.0.x` | Active |
| `4.1.x` (`76dfef6`) | `21` | 4.1.2 | `4.1.x.20260630-SNAPSHOT` | Compilation blocked by missing SDK and authentication classes |

## 9. Build and Test

```bash
mvn clean verify
mvn -pl security-yiban-spring-boot-starter -am test
mvn -U clean verify
```

## 10. Troubleshooting

| Symptom | Diagnosis | Resolution |
|---|---|---|
| Bean not created | Check auto-configuration report | Verify `security.yiban.enabled=true` and classpath |
| Bean not created | Check auto-configuration report | Verify `spring.security.yiban.enabled=true` and classpath |
| `ClassNotFoundException` | Missing dependency | Add the required module |
| Version conflict | `mvn dependency:tree` | Use BOM for version alignment |

Expand Down
93 changes: 38 additions & 55 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

**Spring Boot Starter,集成 security-yiban**

[![Maven Central](https://img.shields.io/maven-central/v/io.github.easy4j/security-yiban-spring-boot-starter)](https://github.com/easy-4-java/security-yiban-spring-boot-starter)
[![Java](https://img.shields.io/badge/Java-17-orange)](#3-运行要求与兼容性)
[![Java](https://img.shields.io/badge/Java-8-orange)](#3-运行要求与兼容性)
[![License](https://img.shields.io/badge/license-Apache-2.0-green)](https://www.apache.org/licenses/LICENSE-2.0)

[English](./README.md) | [简体中文](./README.zh-CN.md)

[项目定位](#1-项目定位) · [核心能力](#2-核心能力) ·
[引入依赖](#5-引入依赖) · [快速开始](#6-快速开始) ·
[引入依赖](#5-引入依赖) · [启用配置](#6-启用配置) ·
[配置参考](#7-配置参考) · [版本线](#8-版本线与兼容性) ·
[构建测试](#9-构建与测试) · [许可证](#12-许可证)

Expand All @@ -22,7 +21,7 @@
---

> **当前版本**:`1.0.0-SNAPSHOT`<br>
> **JDK 基线**:`17`<br>
> **JDK 基线**:`8`<br>
> **Group ID**:`io.github.easy4j`<br>
> **Artifact ID**:`security-yiban-spring-boot-starter`<br>
> **许可证**:Apache License 2.0<br>
Expand All @@ -36,25 +35,34 @@
| 类型 | Spring Boot Starter |
| 消费方 | 使用 security-yiban 的 Spring Boot 应用 |
| 核心能力 | 自动装配、属性绑定、开箱即用的 security-yiban Bean |
| JDK | `17` |
| 坐标 | `io.github.easy4j:security-yiban-spring-boot-starter:1.0.0-SNAPSHOT` |
| 配置前缀 | `security.yiban` |
| JDK | `8` |
| 当前源码坐标 | `io.github.easy4j:security-yiban-spring-boot-starter:1.0.0-SNAPSHOT` |
| 配置前缀 | `spring.security.yiban` |

## 2. 核心能力

| 能力 | 状态 | 说明 |
|---|:---:|---|
| 自动装配 | ✅ 稳定 | 自动注册 security-yiban 相关 Bean |
| 属性绑定 | ✅ 稳定 | 绑定 `security.yiban.*` 到 `SecurityYibanAuthcProperties` |
| `Authorize` Bean | ✅ 稳定 | 通过 SecurityYibanAutoConfiguration 自动注册 |
| 自动装配 | 源码已声明 | 自动注册 security-yiban 相关 Bean |
| 属性绑定 | 源码已声明 | 绑定 `spring.security.yiban.authc.*` 到 `SecurityYibanAuthcProperties` |
| `Authorize` Bean | 源码已声明 | 通过 SecurityYibanAutoConfiguration 自动注册 |

## 3. 运行要求与兼容性

| 依赖 | 最低版本 | 证据来源 |
|---|---:|---|
| JDK | `17` | `pom.xml` |
| Spring Boot | `2.3.0.RELEASE` | `pom.xml` parent |
| Maven | `3.6+` | Maven Enforcer |
| JDK | `8` | `pom.xml` |
| Spring Boot | `2.3.12.RELEASE` | `pom.xml` parent |
| Maven | `3.0` | Maven Enforcer |

使用 Boot 父 POM 的 Boot 2.3 应用,请在应用 POM 中将 `spring-framework.version` 设为
`5.3.39`、`spring-security.version` 设为 `5.8.14`。Security Biz 固定使用 Easy4J 已发布的
快照构建 `2.7.x.20260630-20261029.080305-2`,本 Starter 在 JDK 8 与 Boot 2.3.12 上验证其运行兼容性。
构建和消费该构件时需配置 Easy4J Maven 快照仓库。

构建校验仓库内 `YBApi_sdk_java.zip` 中 `YBOpenApi.jar` 的 SHA-256,再打包 2015-08-20
归档中的 SDK 类。HTTP 传输使用 JVM 证书信任库和主机名校验,设定超时并禁用重定向。
Starter 不再解析 `cn.yiban.open:java-sdk:1.6.0`。

## 4. 自动装配

Expand All @@ -68,65 +76,41 @@ Starter 自动装配以下 Bean:
| `YibanMatchedAuthenticationFailureHandler` | classpath + property | 不创建 |
| `YibanAuthenticationProvider` | classpath + property | 不创建 |

自动装配注册:

- `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`(Spring Boot 2.7+ / 3.x / 4.x)
- `META-INF/spring.factories`(Spring Boot 2.x 传统方式)
当前源码包含配置类,但没有 Boot 2.3 自动发现使用的 `META-INF/spring.factories`。自动发现及真实易班登录流程仍待验证。

## 5. 引入依赖

```xml
<dependency>
<groupId>io.github.easy4j</groupId>
<artifactId>security-yiban-spring-boot-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
```
本分支构建仍需解析以下依赖:

无其他 easy4j 组件依赖。
- `cn.yiban.open:java-sdk:1.6.0`,易班授权及用户接口。
- `io.github.easy4j:security-biz-spring-boot-starter:1.0.9-SNAPSHOT`,通用 Spring Security 组件。

## 6. 快速开始
[易班官方下载的 Java 压缩包](https://open.yiban.cn/wiki/download/oauth_java.7z)包含 Servlet 授权示例,未提供上述 Maven SDK JAR。需先从可信来源解析这两个 Maven 制品,并完成 Java 8 构建和联调,再验证可用的发布坐标。

### 6.1 引入依赖
Security Biz 的历史 `1.0.9` 源码使用旧组织坐标。对阿里云私服的独立解析显示,Easy4J 坐标下的 `1.0.9-SNAPSHOT` 和 Boot 2.3 维护版 `2.3.x.20260630-SNAPSHOT` 均未解析到。切换到维护版还需验证 Spring Security 版本及异常响应兼容性。

在 `pom.xml` 中添加上述依赖。
## 6. 启用配置

### 6.2 配置
在已加载 Yiban 配置的应用中使用以下开关:

```yaml
security.yiban:
enabled: true
```

### 6.3 使用 Bean

```java
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```

在业务代码中注入自动装配的 Bean:

```java
@Autowired
private Authorize yibanAuthorize;
spring:
security:
yiban:
enabled: true
```

## 7. 配置参考

### 7.1 配置前缀

`security.yiban`
`spring.security.yiban`

### 7.2 配置项

| 属性 | 类型 | 默认值 | 必填 | 说明 | 敏感 |
|---|---|---|:---:|---|:---:|
| `security.yiban.enabled` | boolean | `true` | 否 | 是否启用 Starter | 否 |
| `spring.security.yiban.enabled` | boolean | `false` | 否 | 是否启用 Starter | 否 |
<!-- 更多属性见下方 -->

## 8. 版本线与兼容性
Expand All @@ -135,20 +119,19 @@ private Authorize yibanAuthorize;
|---|---:|---:|---|:---:|
| `2.3.x` / `2.7.x` | `8+` | 2.3.x / 2.7.x | `1.0.x` | 维护中 |
| `3.0.x` ~ `3.5.x` | `17` | 3.x | `2.0.x` | 维护中 |
| `4.0.x` / `4.1.x` | `17+` | 4.x | `3.0.x` | 活跃开发 |
| `4.1.x`(`76dfef6`) | `21` | 4.1.2 | `4.1.x.20260630-SNAPSHOT` | 缺少 SDK 和认证实现,编译失败 |

## 9. 构建与测试

```bash
mvn clean verify
mvn -pl security-yiban-spring-boot-starter -am test
mvn -U clean verify
```

## 10. 排障

| 症状 | 诊断 | 解决 |
|---|---|---|
| Bean 未创建 | 查看自动装配报告 | 确认 `security.yiban.enabled=true` 与 classpath |
| Bean 未创建 | 查看自动装配报告 | 确认 `spring.security.yiban.enabled=true` 与 classpath |
| `ClassNotFoundException` | 缺少依赖 | 引入对应模块 |
| 版本冲突 | `mvn dependency:tree` | 使用 BOM 统一版本 |

Expand Down
Loading