Skip to content

Commit

Permalink
Support for Method level @ratelimiting annoation #250
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcGiffing committed Mar 11, 2024
1 parent 74780e8 commit 0860e0c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.giffing.bucket4j.spring.boot.starter.examples.ehcache;

import com.giffing.bucket4j.spring.boot.starter.general.tests.filter.method.MethodTestSuite;
import com.giffing.bucket4j.spring.boot.starter.general.tests.filter.servlet.ServletTestSuite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectClasses({
ServletTestSuite.class,
MethodTestSuite.class,
})
public class EhcacheGeneralSuiteTest {
}
47 changes: 26 additions & 21 deletions src/main/doc/plantuml/post_execution_condition.plantuml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
@startuml

== First Request - 1 Token available ==

User -> Bucket4jFilter: webRequest
box "Webserver" #LightBlue
participant Bucket4jFilter
participant SpringSecurityFilter

Bucket4jFilter -> Bucket4jFilter : check remaining tokens
Bucket4jFilter -> SpringSecurityFilter : tokens available proceed
SpringSecurityFilter -> SpringSecurityFilter : authenticate
SpringSecurityFilter -> Bucket4jFilter : authentication Failed 401
Bucket4jFilter -> Bucket4jFilter : if response status 401 consume token
Bucket4jFilter -> User : response 401
end box
User -> Bucket4jFilter: request

box "Webserver" #f5e4e4

Bucket4jFilter -> Bucket4jFilter : estimate_remaining_tokens
participant Bucket4jFilter
participant SpringSecurityFilter
alt 1 token available

note right of Bucket4jFilter: There is one token available. \nThe request will not be aborted
Bucket4jFilter -> SpringSecurityFilter : request
SpringSecurityFilter -> SpringSecurityFilter : authenticate
SpringSecurityFilter -> Bucket4jFilter : response(401)
alt HTTP Response Status == 401
note right of Bucket4jFilter: The token will only be consumed\n if the HTTP Status is 401\n
Bucket4jFilter -> Bucket4jFilter : consume_token
end
Bucket4jFilter -> User : response(401)

else 0 token available
note right of Bucket4jFilter: The token was consumed \nbecause of the HTTP Response Status 401
Bucket4jFilter -> Bucket4jFilter : reject request
Bucket4jFilter -> User : response\n(429 Too Many Requests)
end


== Second Request - 0 Token available ==


User -> Bucket4jFilter: webRequest
box "Webserver" #LightBlue
participant Bucket4jFilter
participant SpringSecurityFilter

Bucket4jFilter -> Bucket4jFilter : check remaining tokens -> no token available
Bucket4jFilter -> User : reject request 429
end box


@enduml
Binary file modified src/main/doc/plantuml/post_execution_condition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0860e0c

Please sign in to comment.