-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support single-host mode on the multi-user server (#14335)
Support single-host mode on the multi-user server. Note that this depends changes in the che-jwtproxy component. * Add a distinction between service name and path base in the external server exposer to be able to correctly expose a service through a proxy * the async authentication in loader.js doesn't truncate the path anymore so that it can correctly locate /jwt/auth even in single-host mode * enhance the jwt proxy configuration with the ability use custom uri prefixes for the redirects on auth failure - this can be used to pass in the information about the external path the proxy is available on even if hidden behind a path rewriting ingress * Make sure pathname doesn't contain duplicated slashes when constructing the auth request. * Made the cookie path server-strategy sensitive
- Loading branch information
Showing
23 changed files
with
347 additions
and
88 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
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
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
63 changes: 63 additions & 0 deletions
63
...se/che/workspace/infrastructure/kubernetes/server/secure/jwtproxy/CookiePathStrategy.java
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.workspace.infrastructure.kubernetes.server.secure.jwtproxy; | ||
|
||
import static java.lang.String.format; | ||
import static org.eclipse.che.workspace.infrastructure.kubernetes.server.external.DefaultHostExternalServiceExposureStrategy.DEFAULT_HOST_STRATEGY; | ||
import static org.eclipse.che.workspace.infrastructure.kubernetes.server.external.MultiHostExternalServiceExposureStrategy.MULTI_HOST_STRATEGY; | ||
import static org.eclipse.che.workspace.infrastructure.kubernetes.server.external.SingleHostExternalServiceExposureStrategy.SINGLE_HOST_STRATEGY; | ||
|
||
import io.fabric8.kubernetes.api.model.ServicePort; | ||
import java.util.function.BiFunction; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.workspace.infrastructure.kubernetes.server.external.IngressServiceExposureStrategyProvider; | ||
|
||
/** | ||
* The cookie path for the access token cookie is server-strategy dependent. This class represents | ||
* the different strategies for getting the cookie path. | ||
* | ||
* <p>Note that instead of going with full-blown strategy pattern and different implementations of | ||
* some interface and a provider for the currently active strategy (as is done for example with | ||
* {@link | ||
* org.eclipse.che.workspace.infrastructure.kubernetes.server.external.ExternalServiceExposureStrategy}), | ||
* this class merely internally uses different functions for different service exposure strategies. | ||
* This is done because the full-blown stragegy pattern implementation felt like over-engineering | ||
* when compared with the simplicity of the functions. | ||
*/ | ||
@Singleton | ||
public class CookiePathStrategy { | ||
|
||
private final BiFunction<String, ServicePort, String> getCookiePath; | ||
|
||
@Inject | ||
public CookiePathStrategy( | ||
@Named(IngressServiceExposureStrategyProvider.STRATEGY_PROPERTY) String serverStrategy) { | ||
switch (serverStrategy) { | ||
case MULTI_HOST_STRATEGY: | ||
getCookiePath = (__, ___) -> "/"; | ||
break; | ||
case SINGLE_HOST_STRATEGY: | ||
case DEFAULT_HOST_STRATEGY: | ||
getCookiePath = (serviceName, __) -> serviceName; | ||
break; | ||
default: | ||
throw new IllegalArgumentException( | ||
format("Unsupported server strategy: %s", serverStrategy)); | ||
} | ||
} | ||
|
||
public String get(String serviceName, ServicePort port) { | ||
return getCookiePath.apply(serviceName, port); | ||
} | ||
} |
Oops, something went wrong.