-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
246 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
*******************************************************************************/ | ||
package org.cloudfoundry.identity.uaa.zone; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.dao.EmptyResultDataAccessException; | ||
import org.springframework.web.filter.OncePerRequestFilter; | ||
|
||
|
@@ -22,23 +21,19 @@ | |
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* This filter ensures that all requests are targeting a specific identity zone | ||
* by hostname. If the hostname doesn't match an identity zone, a 404 error is | ||
* sent. | ||
* | ||
* @author [email protected] | ||
* @author [email protected] | ||
* | ||
*/ | ||
public class IdentityZoneResolvingFilter extends OncePerRequestFilter { | ||
|
||
private IdentityZoneProvisioning dao; | ||
private Set<String> internalHostnames = new HashSet<>(); | ||
private Set<String> defaultZoneHostnames = new HashSet<>(); | ||
|
||
@Override | ||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) | ||
|
@@ -67,10 +62,10 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse | |
} | ||
|
||
private String getSubdomain(String hostname) { | ||
if (internalHostnames.contains(hostname)) { | ||
if (defaultZoneHostnames.contains(hostname)) { | ||
return ""; | ||
} | ||
for (String internalHostname : internalHostnames) { | ||
for (String internalHostname : defaultZoneHostnames) { | ||
if (hostname.endsWith("." + internalHostname)) { | ||
return hostname.substring(0, hostname.length() - internalHostname.length() - 1); | ||
} | ||
|
@@ -82,12 +77,17 @@ public void setIdentityZoneProvisioning(IdentityZoneProvisioning dao) { | |
this.dao = dao; | ||
} | ||
|
||
@Value("${internalHostnames:localhost}") | ||
public void setInternalHostnames(String hostnames) { | ||
this.internalHostnames.addAll(Arrays.asList(hostnames.split("[ ,]+"))); | ||
public void setAdditionalInternalHostnames(Set<String> hostnames) { | ||
if (hostnames!=null) { | ||
this.defaultZoneHostnames.addAll(hostnames); | ||
} | ||
} | ||
|
||
public void setDefaultInternalHostnames(Set<String> hostnames) { | ||
this.defaultZoneHostnames.addAll(hostnames); | ||
} | ||
|
||
public void setInternalHostnames(Set<String> hostnames) { | ||
this.internalHostnames.addAll(Collections.unmodifiableSet(hostnames)); | ||
public Set<String> getDefaultZoneHostnames() { | ||
return defaultZoneHostnames; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=2.2.5 | ||
version=2.2.6 |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.