3.7 KiB
3.7 KiB
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.*. Treatcom.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 includekri.auth.jwt,kri.auth.apikey,kri.security,kri.swagger,kri.web,kri.web.mdc,kri.http.bypass,kri.redis,kri.scheduling, andkri.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.*.enabledsettings 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. ExternalApiClientmultipart requests generate their own boundary and ignore a caller-suppliedContent-Type. Multipart headers andformFieldvalues use UTF-8, while file bodies preserve the supplied bytes.- Multipart filenames, including non-ASCII names, are sent unchanged in the quoted
filenameparameter as raw UTF-8. No ASCII fallback orfilename*parameter is added; CR/LF rejection and quote/backslash escaping still apply. JsonUtilrequires the consumer's explicitObjectMapper; shared date/time helpers define KST asAsia/Seouland 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.