Skip to content

Commit

Permalink
fix api_trusted_hosts_only setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Nov 21, 2024
1 parent 7b1b38f commit 3cbde39
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class TrustedHostFilter extends ExceptionMapperBase implements ContainerR

@Override
public ContainerRequest filter(ContainerRequest request) {
if (Settings.getBoolean(SettingCodes.API_TRUSTED_HOSTS_ONLY, Bundle.SETTINGS, DefaultSettings.API_TRUSTED_HOSTS_ONLY)) { // && !WebUtil.isTrustedHost(this.request)) {
if (Settings.getBoolean(SettingCodes.API_TRUSTED_HOSTS_ONLY, Bundle.SETTINGS, DefaultSettings.API_TRUSTED_HOSTS_ONLY) && !WebUtil.isTrustedHost(this.request)) {
Pattern whitelistRegExp = Settings.getRegexp(SettingCodes.API_TRUSTED_HOSTS_ONLY_WHITELIST_PATH_REGEXP, Bundle.SETTINGS,
DefaultSettings.API_TRUSTED_HOSTS_ONLY_WHITELIST_REGEXP);
if (whitelistRegExp != null && !whitelistRegExp.matcher(request.getRequestUri().getPath()).find()) {
if (whitelistRegExp != null || !whitelistRegExp.matcher(request.getRequestUri().getPath()).find()) {
AuthorisationException ex = new AuthorisationException(Messages.getMessage(MessageCodes.HOST_NOT_ALLOWED_OR_UNKNOWN_HOST, WebUtil.getRemoteHost(this.request)));
ex.setErrorCode(AuthorisationExceptionCodes.HOST_NOT_ALLOWED_OR_UNKNOWN_HOST);
throw new WebApplicationException(ex);
Expand Down

0 comments on commit 3cbde39

Please sign in to comment.