260806_02_ENH: multipart 데이터 ascii -> utf-8로 변경 중

This commit is contained in:
2026-08-06 11:57:21 +09:00
parent 0d9f1ff196
commit 0816878e60
9 changed files with 439 additions and 218 deletions

35
.agent/consumer.md Normal file
View File

@@ -0,0 +1,35 @@
## KriCommon Consumer Contract
### Dependency and API Boundary
- Consume KriCommon as `com.kri.common:starter:<approved-version>` using the consumer repository's established Gradle dependency and version-management conventions.
- Import service-facing APIs from `com.kri.common.feature.*`. Treat `com.kri.common.runtime.*` as internal and do not bind application code to it unless no public API exists and the exception is explicitly documented.
- Include the matching Spring starter for any optional Web, Security, JPA, Redis, AOP, or Swagger integration the service enables; KriCommon intentionally declares many integrations as compile-only.
- Prefer the shared feature or an approved extension point over duplicating authentication, HTTP, error, enum, Excel, Redis, JSON, date/time, JPA, or utility behavior locally.
### Configuration and Overrides
- KriCommon configuration uses only `kri.*`. Established groups include `kri.auth.jwt`, `kri.auth.apikey`, `kri.security`, `kri.swagger`, `kri.web`, `kri.web.mdc`, `kri.http.bypass`, `kri.redis`, `kri.scheduling`, and `kri.error.expose`.
- Read the version-matched README and configuration-property classes before setting a property; do not infer a property name or default from an older service.
- Supply production JWT secrets, API keys, credentials, allowlists, and service URLs through the consumer's approved secret and configuration system. Never rely on library example or default secrets in production.
- Preserve consumer override points. KriCommon's default security chain is created only when the consumer does not provide one, and overridable beans should remain explicit.
- Adding a path to API-key allowed paths scopes where API-key authentication is attempted; it does not make the path public or grant authorization.
### Major Optional Capabilities
- JWT and API-key authentication integrate with Spring Security. API-key JPA preload requires Spring Data JPA; a consumer-provided claims provider can be used without JPA.
- Common Web may register error handling, tracing/MDC, request-user resolution, enum conversion, and CORS behavior. Check for overlap before defining consumer-local equivalents.
- Swagger support requires springdoc and defines the shared Bearer/API-key schemes and grouped paths.
- Redis and scheduling are opt-in through their `kri.*.enabled` settings and matching runtime dependencies.
- HTTP bypass targets are server-configured. Never accept an arbitrary full target URL from a frontend; retain allowed-path checks and do not forward hop-by-hop headers.
- The external API client returns response bodies as documented, while bypass responses preserve raw bytes and target `Content-Type`.
- `ExternalApiClient` multipart requests generate their own boundary and ignore a caller-supplied `Content-Type`. Multipart boundaries and part headers use US-ASCII, `formField` values use UTF-8, and file bodies preserve the supplied bytes.
- ASCII multipart filenames are sent unchanged in `filename`. Non-ASCII filenames use a collision-free ASCII `filename` fallback plus the original name in UTF-8 percent-encoded `filename*`; spaces are encoded as `%20`, not `+`.
- `JsonUtil` requires the consumer's explicit `ObjectMapper`; shared date/time helpers define KST as `Asia/Seoul` and also expose UTC semantics.
### Upgrade and Verification
- Review KriCommon release notes, README changes, configuration defaults, auto-configuration conditions, and affected public APIs before upgrading.
- Commit dependency-lock or resolved-version changes according to the consumer repository's policy.
- Run the consumer's focused compile and tests after an upgrade, including application-context startup tests when auto-configuration or security behavior is affected.
- Do not modify KriCommon or another consumer repository unless it is explicitly included in the approved task scope.

15
.agent/profile.yml Normal file
View File

@@ -0,0 +1,15 @@
schema_version: 1
project:
id: kri-common
name: KriCommon
type: library
layer: backend
legacy: false
stack:
- java-springboot
shared_contracts:
provides:
- kri-common

41
.agent/project.md Normal file
View File

@@ -0,0 +1,41 @@
## KriCommon Repository Rules
### Repository Role and Package Boundaries
- This repository is the Java 17 Spring Boot starter/library `com.kri.common:starter:<commonVer>` built with Gradle `java-library` and `maven-publish`.
- `build.gradle` variable `commonVer` is the version source. Version changes and publication require separate explicit approval.
- Treat types under `com.kri.common.feature`, `kri.*` configuration properties, auto-configuration behavior, optional endpoints, Maven coordinates, and documented defaults as public contracts.
- Put stable service-facing APIs under `com.kri.common.feature`. Keep implementations under `com.kri.common.runtime` and composition under `com.kri.common.autoconfigure`; consumers should not depend on runtime internals.
- Register consumer-active auto-configurations in `src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`.
### Dependency and Auto-Configuration Safety
- Many Spring integrations are intentionally `compileOnly`. Do not assume Spring Web, Security, JPA, Redis, AOP, or springdoc is present in every consumer.
- Guard optional integrations with the appropriate classpath, bean, missing-bean, and property conditions. A consumer-provided bean must remain able to override a default where that is the established contract.
- Do not introduce configuration prefixes outside `kri.*`.
- Do not make an optional starter mandatory without an approved compatibility review and migration plan.
- Never hard-code real secrets, credentials, service URLs, or API keys. Examples must use obvious placeholders or local-only values.
- Do not log or expose raw API keys, bearer tokens, credentials, or unrestricted target URLs.
### Feature Invariants
- Preserve the default security chain's consumer override point and the established order of API-key and JWT filters.
- Path restrictions for API-key authentication scope authentication attempts; they do not grant authorization or replace `kri.security.public-paths`.
- Keep bypass target base URLs server-side, enforce configured allowed paths, and exclude hop-by-hop headers. Preserve response bytes and target `Content-Type`.
- `JsonUtil` requires an explicit `ObjectMapper`; do not introduce hidden global mapper state.
- Preserve `Asia/Seoul` and UTC semantics in shared date/time APIs.
- Keep public enum, JPA, Excel, Redis, HTTP, authentication, web, cache, and utility behavior compatible unless a breaking change is explicitly approved.
### Documentation and Verification
- `AGENTS.md` and `CLAUDE.md` are harness-generated outputs. Never edit either file directly.
- Edit `.agent/project.md` when KriCommon's repository workflow, build, maintenance, or verification rules change.
- Edit `.agent/consumer.md` in the same task when a public API, configuration property, default, auto-configuration condition, endpoint, extension point, dependency requirement, security behavior, or other consumer-facing contract changes.
- A source-code change does not update harness documents automatically. The Agent making a consumer-facing change is responsible for updating `.agent/consumer.md` and the relevant human documentation before completion.
- After an approved harness-source change, run `D:\_____Dev\_________AgentHarnessBase\scripts\agent-harness.cmd compose --project kri-common`, followed by `D:\_____Dev\_________AgentHarnessBase\scripts\agent-harness.cmd verify --project kri-common`.
- If composition cannot be run, leave the authoritative `.agent` source corrected, report that the generated output is stale, and do not patch `AGENTS.md` manually.
- Update `README.md`, `.agent/consumer.md`, configuration metadata, examples, and tests as applicable when public behavior changes.
- Verify property names against their `@ConfigurationProperties` classes and ensure examples import public `com.kri.common.feature.*` APIs unless internals are intentionally documented.
- On Windows, run `.\gradlew.bat compileJava` for relevant source changes. Use additional focused tests and checks when present.
- For auto-configuration changes, verify import registration and all classpath, bean, and property conditions.
- Do not run publish tasks or edit consumer repositories without separate explicit approval. Publishing additionally requires configured Gitea credentials and performs a remote version check.