Skip to content

Commit

Permalink
Adjust readme, add rate limiting event listener, remove unused proper…
Browse files Browse the repository at this point in the history
…ty (#76)
  • Loading branch information
skjolber authored Feb 19, 2024
1 parent a17206c commit 08fb12c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
1 change: 0 additions & 1 deletion jwt-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ entur:
time-to-live: 36000 #seconds
rate-limit: # per tenant
enabled: true
bucket-size: 10
refill-rate: 0.1 # per second
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public JwkSourceMap getJwkSourceMap(Map<String, JwtTenantProperties> tenants, Jw
throw new IllegalArgumentException("Invalid location " + tenantJwkConfiguration.getLocation() + " for " + entry.getKey());
}

JwkSetSourceEventListener eventListener = new JwkSetSourceEventListener(entry.getKey());

int connectTimeout = jwkConfiguration.getConnectTimeout();
int readTimeout = jwkConfiguration.getReadTimeout();

Expand All @@ -70,13 +72,11 @@ public JwkSourceMap getJwkSourceMap(Map<String, JwtTenantProperties> tenants, Jw

int millisecondsPerToken = (int) (secondsPerToken * 1000); // note quantization, ms precision is sufficient

builder.rateLimited(millisecondsPerToken);
builder.rateLimited(millisecondsPerToken, eventListener);
} else {
builder.rateLimited(false);
}

JwkSetSourceEventListener eventListener = new JwkSetSourceEventListener(entry.getKey());

JwkCacheProperties cache = jwkConfiguration.getCache();
if (cache != null && cache.isEnabled()) {
builder.cache(cache.getTimeToLive() * 1000, cache.getRefreshTimeout() * 1000, eventListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ public class JwkRateLimitProperties {

protected boolean enabled = true;

protected long bucketSize = 10;

/** tokens per second */
protected double refillRate = 0.1d;

public long getBucketSize() {
return bucketSize;
}

public void setBucketSize(long bucketSize) {
this.bucketSize = bucketSize;
}

public double getRefillRate() {
return refillRate;
}
Expand Down

0 comments on commit 08fb12c

Please sign in to comment.