/*
 * Copyright (c) 2012-2018 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
package org.eclipse.che.multiuser.keycloak.server.deploy;

import com.google.inject.servlet.ServletModule;
import javax.inject.Singleton;
import org.eclipse.che.commons.logback.filter.IdentityIdLoggerFilter;
import org.eclipse.che.multiuser.keycloak.server.KeycloakAuthenticationFilter;
import org.eclipse.che.multiuser.keycloak.server.KeycloakEnvironmentInitalizationFilter;
import org.eclipse.che.multiuser.keycloak.server.UnavailableResourceInMultiUserFilter;

public class KeycloakServletModule extends ServletModule {
  @Override
  protected void configureServlets() {
    bind(KeycloakAuthenticationFilter.class).in(Singleton.class);

    // Not contains /docs/ (for swagger) and not ends with '/oauth/callback/' or
    // '/keycloak/settings/' or '/system/state'
    filterRegex("^(?!.*(/docs/))(?!.*(/keycloak/settings/?|/oauth/callback/?|/system/state/?)$).*")
        .through(KeycloakAuthenticationFilter.class);
    filterRegex("^(?!.*(/docs/))(?!.*(/keycloak/settings/?|/oauth/callback/?|/system/state/?)$).*")
        .through(KeycloakEnvironmentInitalizationFilter.class);
    filterRegex("^(?!.*(/docs/))(?!.*(/keycloak/settings/?|/api/oauth/callback/?)$).*")
        .through(IdentityIdLoggerFilter.class);

    // Ban change password (POST /user/password) and create a user (POST /user/) methods
    // but not remove user (DELETE /user/{USER_ID}
    filterRegex("^/user(/password/?|/)?$").through(UnavailableResourceInMultiUserFilter.class);

    filterRegex("/profile/.*/attributes").through(UnavailableResourceInMultiUserFilter.class);
  }
}

@@ -1814,16 +1814,17 @@
 rRegex(%22
+%5E
 /profile
@@ -1828,11 +1828,14 @@
 ile/
+(
 .*/
+)?
 attr
@@ -1840,16 +1840,17 @@
 tributes
+$
 %22).throu

Fix binding of UnavailableResourceInMultiUserFilter for ProfileService's methods