Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0089548
test: cover custom Shiro authentication and session behavior
loong10k Nov 4, 2026
9ba0257
fix: enforce configured realm strategies and isolate authentication r…
loong10k Nov 4, 2026
1c04f43
fix: reject malformed realm results and test cached authentication bo…
loong10k Nov 4, 2026
53b701e
Verify the JWT issuer parser isolation fix in Shiro CI
loong10k Nov 18, 2026
dec5b27
Route Shiro credential checks through an atomic retry store
loong10k Nov 18, 2026
29d2e68
Preserve Shiro retry windows with atomic Redis operations
loong10k Nov 18, 2026
6ff2819
Add atomic Shiro retries for fixed-window JCache providers
loong10k Nov 18, 2026
9ebe0ff
Add native Ehcache 3 credential retry storage
loong10k Nov 18, 2026
2275469
Keep Ehcache 2 credential retries atomic across nodes
loong10k Nov 18, 2026
129af84
Preserve native Hazelcast retry window across atomic updates
loong10k Nov 18, 2026
1be9c96
Preserve Redisson retry TTL and idle expiry across clients
loong10k Nov 18, 2026
1716155
Use J2Cache Jedis for atomic credential retry windows
loong10k Nov 18, 2026
dd5e412
Add atomic retry windows for J2Cache Lettuce
loong10k Nov 18, 2026
780c053
Keep J2Cache Memcached retry windows atomic
loong10k Nov 18, 2026
81c1ae0
Bind Spring retry caches to atomic provider operations
loong10k Nov 18, 2026
5ea00c7
Support atomic retry windows with native Hazelcast 3.12
loong10k Nov 18, 2026
1d8045c
Expire stale Memcached retry windows before incrementing
loong10k Nov 18, 2026
3c98f79
Preserve dynamic retry expiry in Spring Data Redis 4
loong10k Nov 18, 2026
c19d053
Bind Spring Boot retry stores to Shiro cache regions
loong10k Nov 18, 2026
a78fa5c
Preserve active Ehcache 2 credential retry windows during cutover
loong10k Nov 18, 2026
944ef42
Preserve active credential retry windows in Hazelcast cutover
loong10k Nov 18, 2026
b2a9e4a
Migrate active credential retry windows in JCache regions
loong10k Nov 18, 2026
632c024
Preserve Spring Redis retry deadlines during exclusive cutover
loong10k Nov 18, 2026
2dca2ca
Verify Spring Redis retry cutover across cluster primaries
loong10k Nov 18, 2026
1f4ae9a
Migrate active J2Cache Redis retry windows from the persisted L2
loong10k Nov 18, 2026
5158e09
Migrate legacy Memcached retry counters with their original deadline
loong10k Nov 18, 2026
28213ab
test: verify J2Cache retry migration across Redis primaries
loong10k Nov 18, 2026
b028150
ci: exercise J2Cache migration on a Redis cluster
loong10k Nov 18, 2026
e391451
test: keep Jedis cluster seeds on loopback in CI
loong10k Nov 18, 2026
53f1a1a
Preserve Redisson retry TTL and idle state during cutover
loong10k Nov 18, 2026
f60225e
Migrate native Ehcache 3 counters during exclusive cutover
loong10k Nov 18, 2026
45b558c
Preserve binary J2Cache legacy keys during Redis cutover
loong10k Nov 18, 2026
a9f94b5
test: cover credential retry store failures
loong10k Nov 18, 2026
89517ea
test: document JCache retry rollback boundary
loong10k Nov 18, 2026
5d30150
Preserve active JCache retry windows during rollback
loong10k Nov 18, 2026
b5d1aee
Skip JCache read-through for missing retry entries during rollback
loong10k Nov 18, 2026
d42f632
Support typed JCache retry window migration and rollback
loong10k Nov 18, 2026
d0bba0f
Support retry migration over authenticated Memcached Meta connections
loong10k Nov 18, 2026
dbd0cf9
ci: exercise authenticated Memcached migration in Shiro verification
loong10k Nov 18, 2026
d928a55
Test binary-only Memcached retry cutover boundary
loong10k Nov 18, 2026
5c10c05
Use the observed Redisson write interval for expiry assertions
loong10k Nov 18, 2026
38146cd
docs: verify warm restart for binary Memcached retry cutover
loong10k Nov 18, 2026
e75b479
test: verify retry migration after Memcached warm restart
loong10k Nov 18, 2026
d8ac321
fix: preserve retry state in typed native Ehcache 3 regions
loong10k Nov 18, 2026
9dd0ecf
test: verify Memcached warm restart across authenticated protocols
loong10k Nov 18, 2026
05cc531
fix: restore legacy counters in native Ehcache 3
loong10k Nov 18, 2026
da7327b
test: let Hazelcast integration members bind ephemeral ports
loong10k Nov 18, 2026
b5cd77a
Verify bounded cutover for renewing Ehcache retry regions
loong10k Nov 18, 2026
228146a
fix: import verified Memcached retry expiry snapshots
loong10k Nov 19, 2026
94e0f54
fix: bind Memcached retry snapshot to the source entry version
loong10k Nov 19, 2026
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
155 changes: 153 additions & 2 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 30
services:
redis:
image: redis:8.4.0
ports:
- 6379/tcp
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 5
memcached:
image: memcached:1.6.45-alpine
ports:
- 11211/tcp
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
Expand All @@ -20,18 +34,155 @@ jobs:
uses: actions/checkout@v7
with:
repository: easy-4-java/jwt-issuer
ref: 6b1a4de65a12a155e98e957ea82e446ef6420b36
ref: c6edbf6a56a0c8ae6409b9fc1b0ef9639c4063d1
path: .ci-dependencies/jwt-issuer
- name: Verify and install JWT issuer
run: mvn -B -ntp -s .github/maven-central-settings.xml -Dmaven.repo.local="${RUNNER_TEMP}/verified-m2" -f .ci-dependencies/jwt-issuer/pom.xml clean install
- name: Verify Shiro extension
run: mvn -B -ntp -s .github/maven-central-settings.xml -Dmaven.repo.local="${RUNNER_TEMP}/verified-m2" clean verify
env:
RETRY_REDIS_CONTAINER: ${{ job.services.redis.id }}
RETRY_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
RETRY_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
shell: bash
run: |
set -euo pipefail
auth_file=$(mktemp "${RUNNER_TEMP}/memcached-auth.XXXXXX")
auth_container=
binary_container=
warm_container=
cleanup() {
if [[ -n "$auth_container" ]]; then
docker rm -f "$auth_container" >/dev/null
fi
if [[ -n "$binary_container" ]]; then
docker rm -f "$binary_container" >/dev/null
fi
if [[ -n "$warm_container" ]]; then
docker rm -f "$warm_container" >/dev/null
fi
rm -f "$auth_file"
}
trap cleanup EXIT
# Local CI fixture only. The container reads this as its non-root user.
printf '%s\n' 'fixture-user:fixture-password' > "$auth_file"
chmod 0644 "$auth_file"
auth_container=$(docker run -d --publish 127.0.0.1::11211/tcp \
--mount "type=bind,src=$auth_file,dst=/memcached-auth,readonly" \
memcached:1.6.45-alpine memcached -U 0 -Y /memcached-auth)
binary_container=$(docker run -d --publish 127.0.0.1::11211/tcp \
memcached:1.6.45-alpine memcached -U 0 -B binary)
warm_container=$(docker run -d --user 0 --publish 127.0.0.1::11211/tcp \
--mount "type=bind,src=$auth_file,dst=/memcached-auth,readonly" \
--tmpfs /state:rw,size=96m memcached:1.6.45-alpine sh -ec '
chown memcache /state
mkdir -p /etc/sasl2
printf "%s\n" "mech_list: plain" >/etc/sasl2/memcached.conf
sed "s/:/@$(hostname):/" /memcached-auth >/state/sasl-auth
chown memcache /state/sasl-auth
chmod 0600 /state/sasl-auth
MEMCACHED_SASL_PWDB=/state/sasl-auth memcached -u memcache -U 0 -m 64 -S -e /state/memory &
child=$!
echo "$child" >/state/source.pid
wait "$child"
# The server requires the clock to advance beyond the saved stop second.
sleep 2
exec memcached -u memcache -U 0 -m 64 -Y /memcached-auth -e /state/memory
')
ready_port() {
local container=$1 binding port
binding=$(docker port "$container" 11211/tcp)
port=${binding##*:}
[[ "$port" =~ ^[0-9]+$ ]] || return 1
for _ in {1..40}; do
if (: < "/dev/tcp/127.0.0.1/$port") 2>/dev/null; then
printf '%s\n' "$port"
return
fi
sleep 0.25
done
docker logs "$container" >&2
return 1
}
auth_port=$(ready_port "$auth_container")
binary_port=$(ready_port "$binary_container")
warm_port=$(ready_port "$warm_container")
mvn -B -ntp -s .github/maven-central-settings.xml -Dmaven.repo.local="${RUNNER_TEMP}/verified-m2" \
-Dshiro.redis.test.container="$RETRY_REDIS_CONTAINER" -Dshiro.redis.test.port="$RETRY_REDIS_PORT" \
-Dshiro.memcached.test.port="$RETRY_MEMCACHED_PORT" -Dshiro.memcached.auth.test.port="$auth_port" \
-Dshiro.memcached.binary.test.port="$binary_port" -Dshiro.memcached.warm.test.port="$warm_port" \
-Dshiro.memcached.warm.test.container="$warm_container" clean verify
python3 - <<'PYTHON'
from pathlib import Path
from xml.etree import ElementTree

reports = Path("shiro-extension-core/target/surefire-reports")
suite = ElementTree.parse(next(reports.glob("TEST-*J2CacheMemcachedCredentialRetryStoreIntegrationTest.xml")))
for name in (
"importsThroughAnAuthenticatedMetaConnectionWithItsOriginalDeadline",
"refusesToImportWhenOnlyTheBinaryProtocolCanReadTheCounter",
"importsAuthoritativeSnapshotWithTheOriginalServerDeadline",
"importsLegacyWindowsAfterSaslSourceWarmRestart",
):
case = suite.find(f'./testcase[@name="{name}"]')
if case is None or any(case.find(status) is not None for status in ("failure", "error", "skipped")):
raise SystemExit(f"Expected an executed, successful Memcached test: {name}")
PYTHON
- name: Verify J2Cache and Redisson retry migration on Redis Cluster
shell: bash
run: |
set -euo pipefail
containers=()
trap 'if (( ${#containers[@]} > 0 )); then docker rm -f "${containers[@]}" >/dev/null; fi' EXIT
nodes=()
for port in 16380 16381 16382; do
container=$(docker run -d --rm --network host redis:8.4.0 redis-server \
--bind 127.0.0.1 --port "$port" --cluster-enabled yes \
--cluster-announce-ip 127.0.0.1 --cluster-config-file nodes.conf \
--save '' --appendonly no)
containers+=("$container")
nodes+=("127.0.0.1:$port")
for attempt in {1..60}; do
if docker exec "$container" redis-cli -p "$port" ping | grep -qx PONG; then
break
fi
if (( attempt == 60 )); then
docker logs "$container"
exit 1
fi
sleep 0.25
done
done
timeout 30s docker exec "${containers[0]}" redis-cli --cluster create "${nodes[@]}" --cluster-replicas 0 --cluster-yes
cluster_nodes=$(IFS=,; printf '%s' "${nodes[*]}")
mvn -B -ntp -s .github/maven-central-settings.xml -Dmaven.repo.local="${RUNNER_TEMP}/verified-m2" \
-pl shiro-extension-core -Dshiro.redis.test.cluster.nodes="$cluster_nodes" \
'-Dtest=J2CacheRedisClusterMigrationTest,RedissonCredentialRetryStoreIntegrationTest#migratesTheLegacyMapEntryWithoutRefreshingItsIdleDeadline+keepsMapExpiryAndImportsPersistentZeroCounts' test
mvn -B -ntp -s .github/maven-central-settings.xml -Dmaven.repo.local="${RUNNER_TEMP}/verified-m2" \
-pl shiro-extension-core -Dshiro.redis.test.cluster.nodes="$cluster_nodes" \
-Dshiro.test.fileEncoding=ISO-8859-1 -Dshiro.redis.test.expectedCharset=ISO-8859-1 \
-Dsurefire.reportNameSuffix=latin1 -Dtest=J2CacheRedisClusterMigrationTest test
python3 - <<'PYTHON'
from pathlib import Path
from xml.etree import ElementTree

report = Path("shiro-extension-core/target/surefire-reports")
for name in ("J2CacheRedisClusterMigrationTest", "J2CacheRedisClusterMigrationTest-latin1", "RedissonCredentialRetryStoreIntegrationTest"):
suite = ElementTree.parse(next(report.glob(f"TEST-*{name}.xml"))).getroot()
if tuple(suite.get(key) for key in ("tests", "failures", "errors", "skipped")) != ("2", "0", "0", "0"):
raise SystemExit(f"Expected two Redis Cluster migration tests without skips in {name}")
PYTHON
- name: Require coverage for modules with existing tests
run: |
test -s .ci-dependencies/jwt-issuer/jwt-issuer-with-jjwt/target/jacoco.exec
test -s .ci-dependencies/jwt-issuer/jwt-issuer-with-jjwt/target/site/jacoco/jacoco.xml
test -s shiro-extension-core/target/jacoco.exec
test -s shiro-extension-core/target/site/jacoco/jacoco.xml
test -s shiro-extension-spring/target/jacoco.exec
test -s shiro-extension-spring/target/site/jacoco/jacoco.xml
test -s shiro-extension-hazelcast3/target/jacoco.exec
test -s shiro-extension-hazelcast3/target/site/jacoco/jacoco.xml
test -s shiro-extension-spring-redis4/target/jacoco.exec
test -s shiro-extension-spring-redis4/target/site/jacoco/jacoco.xml
- uses: actions/upload-artifact@v7
if: always()
with:
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ realm.setCredentialsMatcher(new DefaultCredentialsMatcher());

## 7. Configuration

This is a library: there are no configuration properties or prefixes. Behavior is configured through constructor/bean injection:
Configure behavior through constructors and beans.

| Extension point | Configurable via |
| :--- | :--- |
Expand All @@ -194,6 +194,37 @@ This is a library: there are no configuration properties or prefixes. Behavior i
| Filters (`HttpServletShiroFilter` and friends) | bean properties and the Shiro filter-chain definition |
| i18n messages | bundled `org/apache/shiro/biz/messages*.properties`, `ShiroBizMessageSource` |

### Shared credential retry state in Spring Boot

For a Spring-managed retry matcher with cache name `login`, declare a provider-backed `CredentialRetryStore` bean named `shiro.credential-retry.login`. Spring Boot binds it to `DefaultCredentialsMatcher` and `CredentialsRetryLimitCredentialsMatcher`, including instances held by Spring-managed realms. An explicitly assigned store takes precedence. Matchers without a matching bean keep their Shiro cache configuration. Use the same provider, retry namespace and principal key mapping across the instances that share the window.

For an existing Ehcache 2 retry cache, stop all legacy clients of that region before enabling the shared store. Reuse the same region and principal keys. The first reservation upgrades the stored legacy counter under the key lock, counts the current attempt and keeps the original TTL deadline and the configured time-to-idle policy. Use a strongly consistent region when clustered.

For native Ehcache 3, pause all retry clients, drain writes, and use exactly one migration writer per region. Call `migrateLegacyWindow` for each known principal using the original cache. The region must use creation-only or eternal expiry. A region that accepts both legacy counters and retry windows, such as `Serializable`, stores attempts directly. An `AtomicInteger`-typed region stores a serializable counter subtype holding the window ID and must preserve that subtype. Live entries are replaced in place while retaining the existing deadline.

For legacy regions using a verified finite TTL or TTI that renews on updates or reads, use a bounded drain for cutover. Pause all clients and background jobs that can access the retry region, and wait until in-flight operations finish. From that point, wait at least the longest configured lifetime across the source regions, including any clock margin required by the deployment. Enable the new store on a separate region only after that interval, with its configured creation window. The old region is left intact and its counters expire on their own. This path requires a maintenance pause and explicit acceptance of the new region’s fixed-window policy. Eternal entries, custom policies with unknown upper bounds, and deployments that must retain renewal behavior require a different path.

For rollback, keep retry clients paused and drain outstanding writes before calling `restoreLegacyWindow` for each known principal. The cache must accept `AtomicInteger`. A live retry window becomes a plain legacy counter with its current count and original deadline. Missing, expired, and already restored entries are skipped.

For Hazelcast 5.2+ and 3.12, use the same cutover steps for the dedicated retry IMap. Deploy the retry-store module to every member and reuse the original map and principal keys. The first reservation converts the legacy counter atomically, retaining its remaining TTL and refreshing idle time under the existing policy. For the 3.12 adapter, supply the map's configured max idle explicitly.

For an existing JCache retry region, stop legacy clients and reuse the region and principal keys. The JCache entry processor converts the saved counter and reserves the current attempt in one update. The region must use store-by-value and retain its creation deadline on access and update. A region that accepts both value types, for example with value type `Object`, stores retry windows directly. A region typed as `AtomicInteger` stores a serializable counter subtype holding the window ID. Verify that the provider and its configured serializer retain the subtype and deploy this module to every executing member before cutover. Typed migration was verified on a two-member Hazelcast JCache cluster. For rollback, pause all retry clients, drain outstanding writes, and call `restoreLegacyWindow` for every converted principal in the original region. It restores a plain `AtomicInteger` with the current count and original deadline. It skips missing, expired, and restored entries. Check for any remaining converted entries before resuming legacy clients.

For Spring Data Redis, pause all old and new retry clients and wait for outstanding cache writes to reach Redis before importing. Call the adapter’s `migrateLegacyWindow` for each known string principal with the original cache and the distinct destination namespace used by the new store. The import copies the saved count and absolute Redis expiry using the source cache’s key and value serializers. It leaves source entries intact and skips missing, expired, and occupied destinations. Reconcile the submitted principals before resuming clients and finish all imports during the same cutover. If the new policy uses time-to-idle, it applies on the next reservation.

The J2Cache Jedis and Lettuce adapters also expose `migrateLegacyWindow` for each known string principal during an exclusive cutover. Import reads the saved L2 counter using the channel’s serializer, preserves the Redis deadline for generic keys or the hash region, and creates only absent destination windows. Keep the original provider configuration and use a distinct destination namespace. For legacy keys that use the JVM default charset, run migration with the charset that wrote the source region. Jedis routes the expiry lookup using the original binary key. For non-UTF-8 Lettuce keys, supply a binary scripting connection in addition to the UTF-8 destination connection.

The J2Cache Memcached adapter can import a known principal during the same exclusive cutover. Select the source server using the original key routing. On a trusted source that accepts the Meta Text protocol, pass its address to `migrateLegacyWindow`. For authenticated access, first authenticate a dedicated Meta Text connection, configure a finite socket read timeout, and pass it to `migrateLegacyWindowFromMetaConnection`. The caller manages authentication, transport security, and closure of that connection. It must have no outstanding commands and be used by one reader at a time. The adapter reads the value with its remaining TTL, determines the absolute deadline at server-second precision, retains the original entry, and creates the destination only if it is absent. A binary-only source, including one that requires binary SASL, requires a separate migration path because its get operation does not report the existing TTL. For windows with a verified finite TTL bound, pause and drain all retry clients, then wait for the maximum remaining lifetime across the source nodes before enabling the new store. For persistent windows or unknown TTL bounds, keep using the legacy store until you can obtain an authoritative expiry snapshot. Binary GET returns the counter and CAS, which cannot distinguish a finite window from a persistent one.

During the exclusive cutover, pass a verified count and its original absolute Unix deadline from the same source entry to `migrateLegacyWindowFromSnapshot`. Use zero only for a confirmed persistent entry. Import while clients are paused and writes are drained. Expired snapshots and attempts to overwrite existing destination windows return false.

During the same exclusive cutover, the overload of `migrateLegacyWindowFromSnapshot` that accepts a source client and a nonzero CAS also checks the live entry version and decoded count. It returns false if the source is missing, the version or count changed, the deadline passed, or the destination already has a window. The caller must connect to the original source process with the same routing and record the CAS, count and authoritative deadline together. The binary protocol provides the entry version and value. The deadline still comes from the trusted snapshot.

If the binary-only source already runs with [Memcached warm restart](https://docs.memcached.org/features/restart/) enabled on a retained RAM-backed memory file, it can expose the restored windows to the existing Meta Text importer during the exclusive cutover. Keep clients paused and writes drained. Gracefully stop the source with `SIGUSR1`, wait until the host clock advances beyond the saved stop second, and restart it from the same memory file with compatible slab and CAS settings and an isolated Meta Text listener. Keep the listener authenticated or restricted to trusted local access. Verify that the source actually recovered its items before importing. A loopback Memcached 1.6.45 fixture wrote the legacy counters using binary SASL, then imported the recovered windows over authenticated Meta Text. The finite window retained its exact original deadline, and the persistent window remained without a deadline. A third window that expired during the restart stayed absent. This route requires warm restart to have been enabled before the legacy windows were written.


For a retry cache stored in a Redisson 3.12.5 `RMapCache`, pass the original cache and principal to `migrateLegacyWindow` during the same exclusive cutover. The adapter copies the count, entry lifetime, idle policy and current idle deadline without refreshing the source. It also honors a shorter map-wide expiry. Use a distinct destination namespace on the same Redis deployment.

## 8. Core Usage / API

Selected public API (all classes under `org.apache.shiro.biz`):
Expand Down
Loading