File tree Expand file tree Collapse file tree
kotlin/io/openfuture/api/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ class ApiAuthorizationFilter(
1717
1818 private val ipV4LoopBack = " 127.0.0.1"
1919 private val ipV6LoopBack = " 0:0:0:0:0:0:0:1"
20- var allowLocalhost = true
2120
2221 override fun init (filterConfig : FilterConfig ? ) {
2322 // Do nothing
@@ -44,14 +43,16 @@ class ApiAuthorizationFilter(
4443 fun isAllowed (request : HttpServletRequest ): Boolean {
4544
4645 val ip = request.remoteAddr
47- if (allowLocalhost && (ipV4LoopBack == ip || ipV6LoopBack == ip)) {
46+ if (properties.allowLocalHost && (ipV4LoopBack == ip || ipV6LoopBack == ip)) {
4847 return true
4948 }
5049
51- val matcher = IpAddressMatcher (properties.cidr)
50+ if (properties.cidr != null ) {
51+ val matcher = IpAddressMatcher (properties.cidr)
5252
53- if (matcher.matches(request.getHeader(" X-Forwarded-For" ))) {
54- return true
53+ if (matcher.matches(request.getHeader(" X-Forwarded-For" ))) {
54+ return true
55+ }
5556 }
5657
5758 return false
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ import javax.validation.constraints.NotEmpty
1111class AuthorizationProperties (
1212 @field:NotEmpty var cookieName : String? = null ,
1313 var expireApi : Long? = 10 ,
14- var cidr : String? = null
14+ var cidr : String? = null ,
15+ var allowLocalHost : Boolean = false
1516)
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ ethereum.event-subscription=${EVENT_SUBSCRIPTION}
2121auth.cookie-name =open_key
2222auth.expire-api =10
2323auth.cidr =${PUBLIC_IP_SUBNET}
24+ auth.allow-local-host =false
2425
2526# WIDGET
2627widget.host =${WIDGET_HOST}
You can’t perform that action at this time.
0 commit comments