6 |
7 |
8 |
39 |
40 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/configstore/ConfigurationStoreException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.configstore;
21 |
22 | /**
23 | *
24 | * @author paolo.venturi
25 | */
26 | public class ConfigurationStoreException extends RuntimeException {
27 |
28 | public ConfigurationStoreException(Throwable cause) {
29 | super(cause);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/ServiceUpResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.api;
21 |
22 | import javax.ws.rs.GET;
23 | import javax.ws.rs.Path;
24 |
25 | /**
26 | * Access to proxy cache
27 | *
28 | * @author enrico.olivelli
29 | */
30 | @Path("/up")
31 | public class ServiceUpResource {
32 |
33 | @GET
34 | public String ok() {
35 | return "ok";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/core/RequestFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.core;
21 |
22 | /**
23 | * Modify a request, for instance a filter can add/drop headers.
24 | */
25 | public interface RequestFilter {
26 |
27 | /**
28 | * Apply modifications to the given request.
29 | *
30 | * @param request
31 | */
32 | void apply(ProxyRequest request);
33 | }
34 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/response/SimpleResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diennea S.r.l. - Copyright 2022, all rights reserved
3 | */
4 | package org.carapaceproxy.api.response;
5 |
6 | import io.netty.handler.codec.http.HttpResponseStatus;
7 | import javax.ws.rs.core.Response;
8 | import lombok.Getter;
9 | import lombok.NoArgsConstructor;
10 |
11 | /**
12 | * Simple REST response
13 | *
14 | * @author paolo.venturi
15 | */
16 | @Getter
17 | @NoArgsConstructor
18 | public class SimpleResponse {
19 |
20 | private String message;
21 |
22 | protected SimpleResponse(String message) {
23 | this.message = message;
24 | }
25 |
26 | public static Response ok() {
27 | return Response.status(Response.Status.OK).build();
28 | }
29 |
30 | public static Response created() {
31 | return Response.status(Response.Status.CREATED).build();
32 | }
33 |
34 | public static Response error(Throwable error) {
35 | while (error.getCause() != null) {
36 | error = error.getCause();
37 | }
38 | return Response.status(HttpResponseStatus.UNPROCESSABLE_ENTITY.code())
39 | .entity(new SimpleResponse(error.getMessage()))
40 | .build();
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/carapace-server/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ${project.basedir}/../licenseheader.txt
17 | none
18 | JDK_17
19 |
20 |
21 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/config/ConfigurationNotValidException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.config;
21 |
22 | /**
23 | * Configuration is not valid
24 | */
25 | public class ConfigurationNotValidException extends Exception {
26 |
27 | public ConfigurationNotValidException(String message) {
28 | super(message);
29 | }
30 |
31 | public ConfigurationNotValidException(Throwable cause) {
32 | super(cause);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/components/RequestFilters.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Request filters
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/carapace-server/src/main/resources/conf/cluster.properties:
--------------------------------------------------------------------------------
1 | # example cluster configuration
2 | config.type=database
3 | mode=cluster
4 |
5 | # connection string to ZooKeeper
6 | zkAddress=localhost:2181
7 |
8 | # identity of this node, it must be unique, it default to local hostname
9 | #peer.id=myserver
10 |
11 | # HerdDB embedded server configuration
12 | # Use different ports in case of running a test cluster on a single machine
13 | # db.bookie.allowLoopback=true
14 | #db.server.port=7000
15 | #db.server.bookkeeper.port=3181
16 | #db.server.bookkeeper.ensemble.size=1
17 | #db.server.bookkeeper.write.quorum.size=1
18 | #db.server.bookkeeper.ack.quorum.size=1
19 |
20 | # this is where the DB will be store (HerdDB + WAL on BookKeeper)
21 | db.server.base.dir=dbdata
22 |
23 | # API
24 | http.admin.enabled=true
25 | http.admin.port=8001
26 | http.admin.host=localhost
27 | https.admin.port=4001
28 | https.admin.sslcertfile=conf/localhost.p12
29 | https.admin.sslcertfilepassword=testproxy
30 | #admin.advertised.host=localhost #to customize the hostname shown for Admin/API/peers urls
31 |
32 | admin.accesslog.path=admin.access.log
33 | admin.accesslog.format.timezone=GMT
34 | #number of days after wich rotated log files will be deleted
35 | admin.accesslog.retention.days=90
36 |
37 | # AWS Credentials
38 | #aws.accesskey=
39 | #aws.secretkey=
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/client/EndpointNotAvailableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.client;
21 |
22 | /**
23 | * The request endpoint is currently not available
24 | *
25 | * @author enrico.olivelli
26 | */
27 | public class EndpointNotAvailableException extends Exception {
28 |
29 | public EndpointNotAvailableException(Throwable cause) {
30 | super(cause);
31 | }
32 |
33 | public EndpointNotAvailableException(String message, Throwable cause) {
34 | super(message, cause);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/certificates/DynamicCertificatesManagerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.certificates;
21 |
22 | /**
23 | *
24 | * @author paolo.venturi
25 | */
26 | public final class DynamicCertificatesManagerException extends RuntimeException {
27 |
28 | public DynamicCertificatesManagerException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 |
32 | public DynamicCertificatesManagerException(String message) {
33 | super(message);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/client/ConnectionsManagerStats.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.client;
21 |
22 | import java.util.Map;
23 | import org.carapaceproxy.EndpointStats;
24 | import org.carapaceproxy.core.EndpointKey;
25 |
26 | /**
27 | * Stats
28 | *
29 | * @author enrico.olivelli
30 | */
31 | public interface ConnectionsManagerStats {
32 |
33 | public Map getEndpoints();
34 |
35 | public default EndpointStats getEndpointStats(EndpointKey key) {
36 | return getEndpoints().get(key);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/SecureRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | *
24 | * Matcher for Secure request (HTTPS)
25 | *
26 | * @author paolo.venturi
27 | */
28 | public class SecureRequestMatcher implements RequestMatcher {
29 |
30 | @Override
31 | public boolean matches(MatchingContext context) {
32 | return context.isSecure();
33 | }
34 |
35 | @Override
36 | public String getDescription() {
37 | return "secure request";
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/user/UserRealm.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.user;
21 |
22 | import java.util.Collection;
23 | import org.carapaceproxy.configstore.ConfigurationStore;
24 | import org.carapaceproxy.server.config.ConfigurationNotValidException;
25 |
26 | /**
27 | *
28 | * @author matteo.minardi
29 | */
30 | public interface UserRealm {
31 |
32 | public void configure(ConfigurationStore properties) throws ConfigurationNotValidException;
33 |
34 | public Collection listUsers();
35 |
36 | public String login(String username, String password);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/RequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | * Generic criteria to apply a route to a request
24 | */
25 | public interface RequestMatcher {
26 |
27 | /**
28 | * Checks request appliance to defined criteria.
29 | * @param context over the request appliance is checked.
30 | * @return
31 | */
32 | boolean matches(MatchingContext context);
33 |
34 | /**
35 | * @return description of the matcher (used by UI).
36 | */
37 | String getDescription();
38 | }
39 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/MatchingContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | * Context used to check matching conditions over a request.
24 | *
25 | * @author paolo.venturi
26 | */
27 | public interface MatchingContext {
28 |
29 | /**
30 | *
31 | * @param name it's expected to be lowercase.
32 | * @return property value or empty string whether not exists.
33 | */
34 | String getProperty(String name);
35 |
36 | /**
37 | *
38 | * @return true whether HTTPS is used.
39 | */
40 | boolean isSecure();
41 | }
42 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/MatchAllRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | * Matcher to all request
24 | *
25 | * @author paolo.venturi
26 | */
27 | public class MatchAllRequestMatcher implements RequestMatcher {
28 |
29 | @Override
30 | public boolean matches(MatchingContext context) {
31 | return true;
32 | }
33 |
34 | @Override
35 | public String getDescription() {
36 | return "all requests";
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return "MatchAll";
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/config/BackendSelector.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.config;
21 |
22 | import java.util.List;
23 | import org.carapaceproxy.server.mapper.EndpointMapper;
24 |
25 | /**
26 | * Chooses the backend which can serve the request
27 | */
28 | public interface BackendSelector {
29 |
30 | List selectBackends(String userId, String sessionId, String director);
31 |
32 | /**
33 | * Functional interface that models a factory for selectors given the mapper they should be applied to.
34 | */
35 | @FunctionalInterface
36 | interface SelectorFactory {
37 |
38 | BackendSelector build(EndpointMapper endpointMapper);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/config/ConfigurationChangeInProgressException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.config;
21 |
22 | /**
23 | * Cannot change configuration concurrently with another configuration change
24 | */
25 | public class ConfigurationChangeInProgressException extends Exception {
26 |
27 | public ConfigurationChangeInProgressException(String message) {
28 | super(message);
29 | }
30 |
31 | public ConfigurationChangeInProgressException(Throwable cause) {
32 | super(cause);
33 | }
34 |
35 | public ConfigurationChangeInProgressException() {
36 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/filters/BasicRequestFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.filters;
21 |
22 | import org.carapaceproxy.core.ProxyRequest;
23 | import org.carapaceproxy.core.RequestFilter;
24 | import org.carapaceproxy.server.mapper.requestmatcher.RequestMatcher;
25 |
26 | /**
27 | *
28 | * Root class for all RequestFilters
29 | *
30 | * @author paolo.venturi
31 | */
32 | public abstract class BasicRequestFilter implements RequestFilter {
33 |
34 | private final RequestMatcher matcher;
35 |
36 | public BasicRequestFilter(RequestMatcher matcher) {
37 | this.matcher = matcher;
38 | }
39 |
40 | boolean checkRequestMatching(ProxyRequest request) {
41 | return matcher.matches(request);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/NotRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | * Matcher for composing NOT expressions with another matcher.
24 | *
25 | * @author paolo.venturi
26 | */
27 | public class NotRequestMatcher implements RequestMatcher {
28 |
29 | private final RequestMatcher matcher;
30 |
31 | public NotRequestMatcher(RequestMatcher matcher) {
32 | this.matcher = matcher;
33 | }
34 |
35 | @Override
36 | public boolean matches(MatchingContext context) {
37 | return !matcher.matches(context);
38 | }
39 |
40 | @Override
41 | public String getDescription() {
42 | return "not " + matcher.getDescription();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/config/RequestFilterConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.config;
21 |
22 | import java.util.Map;
23 |
24 | /**
25 | * Configuration for a TLS Certificate
26 | *
27 | * @author enrico.olivelli
28 | */
29 | public class RequestFilterConfiguration {
30 |
31 | private final String type;
32 | private final Map filterConfig;
33 |
34 | public RequestFilterConfiguration(String type, Map filterConfig) {
35 | this.type = type;
36 | this.filterConfig = filterConfig;
37 | }
38 |
39 | public String getType() {
40 | return type;
41 | }
42 |
43 | public Map getFilterConfig() {
44 | return filterConfig;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/MetricsResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.api;
21 |
22 | import javax.servlet.ServletContext;
23 | import javax.ws.rs.GET;
24 | import javax.ws.rs.Path;
25 | import javax.ws.rs.Produces;
26 | import org.carapaceproxy.core.HttpProxyServer;
27 |
28 | /**
29 | * Access the metrics API
30 | *
31 | * @author paolo.venturi
32 | */
33 | @Path("/metrics")
34 | @Produces("application/json")
35 | public class MetricsResource {
36 |
37 | @javax.ws.rs.core.Context
38 | ServletContext context;
39 |
40 | @GET
41 | @Path("url")
42 | @Produces("text/plain")
43 | public String getPath() {
44 | HttpProxyServer server = (HttpProxyServer) context.getAttribute("server");
45 | return server.getMetricsUrl();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/CustomHeader.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper;
21 |
22 | import lombok.Data;
23 |
24 | /**
25 | *
26 | * Custom Header to add/set/remove in HttpResponses
27 | *
28 | * @author paolo.venturi
29 | */
30 | @Data
31 | public final class CustomHeader {
32 |
33 | public static enum HeaderMode {
34 | ADD, // to append the header
35 | SET, // to set the header as the only one
36 | REMOVE; // to remove the header
37 |
38 | @Override
39 | public String toString() {
40 | return super.toString().toLowerCase();
41 | }
42 | }
43 |
44 | private final String id;
45 | private final String name;
46 | private final String value;
47 | private final HeaderMode mode;
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/EqualsRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | /**
23 | * Matcher for composing EQUALS expressions give a property-key and the expected value.
24 | *
25 | * @author paolo.venturi
26 | */
27 | public class EqualsRequestMatcher implements RequestMatcher {
28 |
29 | private final String name;
30 | private final String value;
31 |
32 | public EqualsRequestMatcher(String key, String value) {
33 | this.name = key.toLowerCase();
34 | this.value = value;
35 | }
36 |
37 | @Override
38 | public boolean matches(MatchingContext context) {
39 | return context.getProperty(name).equals(value);
40 | }
41 |
42 | public String getDescription() {
43 | return name + " = " + value;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/carapace-server/src/test/java/org/carapaceproxy/server/certificates/Route53ClientTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Diennea S.r.l. under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Diennea S.r.l. licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | */
20 | package org.carapaceproxy.server.certificates;
21 |
22 | /**
23 | * Class for testing real AWS Route53 calls.
24 | *
25 | * @author paolo.venturi
26 | */
27 | public class Route53ClientTest {
28 |
29 | //@Test
30 | public void testCRUD() throws InterruptedException {
31 | Route53Client r53Client = new Route53Client(
32 | null, null
33 | );
34 |
35 | System.out.println("RES: " + r53Client.createDnsChallengeForDomain("*.testcara.tld", "digest"));
36 |
37 | System.out.println("RES: " + r53Client.isDnsChallengeForDomainAvailable("*.testcara.tld", "digest"));
38 |
39 | System.out.println("RES: " + r53Client.deleteDnsChallengeForDomain("*.testcara.tld", "digest"));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "carapace-ui",
3 | "version": "1.0.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build && rm -rf ui && mv dist ui",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "@fortawesome/fontawesome-svg-core": "6.1.1",
12 | "@fortawesome/free-regular-svg-icons": "6.1.1",
13 | "@fortawesome/free-solid-svg-icons": "6.1.1",
14 | "@fortawesome/vue-fontawesome": "2.0.6",
15 | "ansi-regex": "6.0.1",
16 | "bootstrap": "4.5.3",
17 | "bootstrap-vue": "^2.21.2",
18 | "jquery": "^3.6.0",
19 | "moment": "2.29.4",
20 | "popper.js": "^1.16.1",
21 | "serialize-javascript": "6.0.2",
22 | "vue": "^2.6.14",
23 | "vue-router": "3.5.3"
24 | },
25 | "devDependencies": {
26 | "@babel/core": "^7.12.16",
27 | "@babel/eslint-parser": "^7.12.16",
28 | "@vue/cli-plugin-babel": "~5.0.0",
29 | "@vue/cli-plugin-eslint": "~5.0.0",
30 | "@vue/cli-service": "~5.0.0",
31 | "eslint": "^8.0.0",
32 | "eslint-plugin-vue": "^9.27.0",
33 | "sass": "^1.77.8",
34 | "sass-loader": "^16.0.1",
35 | "vue-template-compiler": "^2.6.14",
36 | "webpack": "^5.94.0",
37 | "yarn-audit-fix": "^10.0.9",
38 | "yarn-deduplicate": "^6.0.2"
39 | },
40 | "postcss": {
41 | "plugins": {
42 | "autoprefixer": {}
43 | }
44 | },
45 | "browserslist": [
46 | "> 1%",
47 | "last 2 versions",
48 | "not ie <= 8"
49 | ]
50 | }
51 |
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to Diennea S.r.l. under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. Diennea S.r.l. licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | for service in carapace-server/target/carapace-server-*/bin/service;
21 | do
22 | if [ -f "$service" ]; then
23 | # stop if running
24 | $service server stop
25 | fi
26 | done
27 |
28 | # Carapace version
29 | CARAPACE_V=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout -Dmaven.wagon.http.ssl.insecure=true)
30 |
31 | mvn clean install -DskipTests -Pproduction
32 | cd carapace-server/target || exit
33 | unzip ./*.zip
34 | cd "carapace-server-${CARAPACE_V}" || exit
35 | ./bin/service server start
36 |
37 | timeout 22 sh -c "until nc -z \$0 \$1; do sleep 1; done" localhost 8001
38 |
39 | # apply dynamic configuration
40 | curl -X POST --data-binary @conf/server.dynamic.properties http://localhost:8001/api/config/apply --user admin:admin -H "Content-Type: text/plain"
41 |
42 | tail -f server.service.log
43 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/response/FormValidationResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diennea S.r.l. - Copyright 2022, all rights reserved
3 | */
4 | package org.carapaceproxy.api.response;
5 |
6 | import io.netty.handler.codec.http.HttpResponseStatus;
7 | import javax.ws.rs.core.Response;
8 | import lombok.Getter;
9 | import lombok.NoArgsConstructor;
10 |
11 | /**
12 | * Form validation REST response
13 | *
14 | * @author paolo.venturi
15 | */
16 | @Getter
17 | @NoArgsConstructor
18 | public class FormValidationResponse extends SimpleResponse {
19 |
20 | public static final String ERROR_FIELD_REQUIRED = "Value required";
21 | public static final String ERROR_FIELD_INVALID = "Value invalid";
22 | public static final String ERROR_FIELD_DUPLICATED = "Value already used";
23 |
24 | private String field;
25 |
26 | private FormValidationResponse(String field, String message) {
27 | super (message);
28 | this.field = field;
29 | }
30 |
31 | public static Response fieldRequired(String field) {
32 | return fieldError(field, ERROR_FIELD_REQUIRED);
33 | }
34 |
35 | public static Response fieldInvalid(String field) {
36 | return fieldError(field, ERROR_FIELD_INVALID);
37 | }
38 |
39 | public static Response fieldError(String field, String message) {
40 | return Response.status(HttpResponseStatus.UNPROCESSABLE_ENTITY.code())
41 | .entity(new FormValidationResponse(field, message))
42 | .build();
43 | }
44 |
45 | public static Response fieldConflict(String field) {
46 | return Response.status(Response.Status.CONFLICT)
47 | .entity(new FormValidationResponse(field, ERROR_FIELD_DUPLICATED))
48 | .build();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Carapaceproxy
2 | A Distributed Java Reverse Proxy
3 |
4 | ## For Developers
5 | Start Carapace by running `./run.sh` script. This just launch the server, the ui and load a ready to use dynamic configuration.
6 | Server will start at `http://localhost:8001/ui/#/` and `https://localhost:4001/ui/#/` with no authentication required.
7 |
8 | To launch/update the ui only, run `./carapace-ui/deploy.sh`
9 |
10 | To bundle the project into a .zip archive for a standalone installation run `mvn clean install -DskipTests -Pproduction`. You'll find the generated zip in `carapace-server/target/carapace-server-X.Y.Z-SNAPSHOT.zip`
11 |
12 | ## For Admins
13 | To install Carapace, just unzip the carapace.zip archive and then run `./bin/service server start [custom-server.properties]` (default server.properties is loaded).
14 | The server will start at `hostname:port` as defined in the server.properties file loaded.
15 |
16 | ## Docker
17 |
18 | You can build carapace docker image by running:
19 | ```
20 | mvn clean install -DskipTests -Pproduction
21 | docker/build.sh
22 | ```
23 | Then you can run the container and the admin interface will be listening on 0.0.0.0:8001
24 | ```
25 | docker run -p 8001:8001 carapace/carapace-server:latest
26 | ```
27 | You can also pass system properties using docker option `-e` with the prefix `CARAPACE`:
28 |
29 | ```
30 | docker run -p 8001:8001 -e CARAPACE_mode=cluster -e CARAPACE_zkAddress=localhost:2181 carapace/carapace-server:latest
31 | ```
32 |
33 | ### Docker start a simple cluster with 1 node
34 |
35 | You can run a simple 1-node cluster using the docker-compose.yml file.
36 | This starts a Carapace node (with embedded bookkeeper and herddb) and Zookeeper.
37 | The replication factor of bookkeeper in this case will be set to 1.
38 |
39 | ```
40 | docker compose up -d
41 | ```
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/core/UriCleanerHandler.java:
--------------------------------------------------------------------------------
1 | package org.carapaceproxy.core;
2 |
3 | import static reactor.netty.NettyPipeline.H2OrHttp11Codec;
4 | import static reactor.netty.NettyPipeline.HttpTrafficHandler;
5 | import io.netty.channel.Channel;
6 | import io.netty.channel.ChannelHandlerContext;
7 | import io.netty.channel.ChannelInboundHandlerAdapter;
8 | import io.netty.handler.codec.http.HttpRequest;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | public class UriCleanerHandler extends ChannelInboundHandlerAdapter {
13 | public static final UriCleanerHandler INSTANCE = new UriCleanerHandler();
14 | private final Logger logger = LoggerFactory.getLogger(UriCleanerHandler.class);
15 |
16 | private UriCleanerHandler() {
17 | super();
18 | }
19 |
20 | public void addToPipeline(final Channel channel) {
21 | if (channel.pipeline().get(HttpTrafficHandler) != null) {
22 | channel.pipeline().addBefore(HttpTrafficHandler, "uriEncoder", this);
23 | }
24 | if (channel.pipeline().get(H2OrHttp11Codec) != null) {
25 | channel.pipeline().addAfter(H2OrHttp11Codec, "uriEncoder", this);
26 | }
27 | logger.debug("Unsupported pipeline structure: {}; skipping...", channel.pipeline().toString());
28 | }
29 |
30 | @Override
31 | public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
32 | if (msg instanceof final HttpRequest request) {
33 | request.setUri(request.uri()
34 | .replaceAll("\\[", "%5B")
35 | .replaceAll("]", "%5D")
36 | );
37 | }
38 | ctx.fireChannelRead(msg);
39 | }
40 |
41 | @Override
42 | public boolean isSharable() {
43 | return true;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/app.scss:
--------------------------------------------------------------------------------
1 | @import "./variables.scss";
2 |
3 | /* Bootstrap colors overriding */
4 | $theme-colors: (
5 | primary: $primary,
6 | secondary: $primary-dark
7 | );
8 |
9 | @import "./../node_modules/bootstrap/scss/bootstrap";
10 |
11 | /* Custom Scrollbar*/
12 | ::-webkit-scrollbar {
13 | height: 0.5rem;
14 | width: 0.25rem;
15 | background-color: $white;
16 | }
17 |
18 | ::-webkit-scrollbar-track {
19 | box-shadow: inset 0 0 6px $shadow;
20 | background-color: $white;
21 | }
22 |
23 | ::-webkit-scrollbar-thumb {
24 | box-shadow: inset 0 0 6px $shadow;
25 | background-color: $primary;
26 | }
27 |
28 | /* Other Styles */
29 | .status-box {
30 | display: inline-block;
31 | padding: 0.5rem;
32 | margin: 0.3em auto;
33 | border-radius: 3px;
34 | font-size: 0.95rem;
35 |
36 | &.status-box_warning {
37 | background-color: $warning;
38 | border-left: 5px solid $warning-dark;
39 | }
40 |
41 | &.status-box_error {
42 | background-color: $error;
43 | border-left: 5px solid $error-dark;
44 | }
45 | }
46 |
47 | * {
48 | font-family: "Exo 2", sans-serif;
49 | -webkit-font-smoothing: antialiased;
50 | -moz-osx-font-smoothing: grayscale;
51 | }
52 |
53 |
54 | .badge-status {
55 | font-size: 13px;
56 | border-radius: 2px;
57 | text-transform: uppercase;
58 | font-weight: bold;
59 | text-align: center;
60 | padding: 0.5rem;
61 |
62 | &.success {
63 | color: $white;
64 | background-color: $success;
65 | }
66 |
67 | &.warning {
68 | background-color: $warning;
69 | }
70 |
71 | &.error {
72 | color: $white;
73 | background-color: $error;
74 | }
75 |
76 | &.info {
77 | color: $white;
78 | background-color: $info;
79 | }
80 | }
--------------------------------------------------------------------------------
/carapace-server/src/test/resources/ia.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIIEvzCCAqcCAQAwYTELMAkGA1UEBhMCWFgxDjAMBgNVBAgMBUl0YWx5MQ4wDAYD
3 | VQQHDAVJdGFseTEOMAwGA1UECgwFSXRhbHkxDjAMBgNVBAsMBUl0YWx5MRIwEAYD
4 | VQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC6
5 | dAMJd4NkQPkgJ4JH5ayutlgbcRTKoL9H2FDrdXEyBQNVtvVDSzQRKcThD9n3nBrl
6 | yHKQKZBjlDR6W0KXITbe5Zvu419QKVGFWXH2lF9/2Uwa7x+GZybEwTfONoqNXiPY
7 | vn1dJx9ZA1PzzAD+LXJyn8y2sp5G+iDksgPg8DxQwDi+l7ZpIz1w9TT+lsynhp5n
8 | 3z0Gjmg4rGH9+M88HTM9+dPI9MBklnoNc857COck76w6+GhWHH1mZTwClyjMg4px
9 | pNDeO/vpAxW9SbtRv5r1wTD1DB4Tn6FXw1V1Hao+n7pVPaw/X1eqazE7xHWyiSxY
10 | +NhRzHMgcW92jIIGd8weVET1QLjrJcIsRjEOL45/iSt8pspKrR/efJVXzUrFCHch
11 | qfh6PB5FZqlHEf4EmDe2cpAXgV1xBMjKs6DVZcd37EeLfdeoGm0Mloae1uDkQwID
12 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ICATE REQUEST-----
29 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/components/Peers.vue:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
46 |
47 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/UserRealmResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.api;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Collection;
24 | import javax.servlet.ServletContext;
25 | import javax.ws.rs.GET;
26 | import javax.ws.rs.Path;
27 | import javax.ws.rs.Produces;
28 | import org.carapaceproxy.core.HttpProxyServer;
29 | import org.carapaceproxy.user.UserRealm;
30 |
31 | /**
32 | * Access the users API
33 | *
34 | * @author matteo.minardi
35 | */
36 | @Path("/users")
37 | @Produces("application/json")
38 | public class UserRealmResource {
39 |
40 | @javax.ws.rs.core.Context
41 | ServletContext context;
42 |
43 | @Path("/all")
44 | @GET
45 | public Collection getAll() {
46 | HttpProxyServer server = (HttpProxyServer) context.getAttribute("server");
47 | UserRealm userRealm = server.getRealm();
48 | if (userRealm == null) {
49 | return new ArrayList<>();
50 | }
51 | return userRealm.listUsers();
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/EndpointStats.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy;
21 |
22 | import java.util.concurrent.atomic.AtomicInteger;
23 | import java.util.concurrent.atomic.AtomicLong;
24 | import org.carapaceproxy.core.EndpointKey;
25 |
26 | /**
27 | * Stats about an endpoint
28 | *
29 | * @author enrico.olivelli
30 | */
31 | public class EndpointStats {
32 |
33 | private final EndpointKey key;
34 | private final AtomicInteger totalRequests = new AtomicInteger();
35 | private final AtomicLong lastActivity = new AtomicLong();
36 |
37 | public EndpointStats(final EndpointKey key) {
38 | this.key = key;
39 | }
40 |
41 | public String toString() {
42 | return "EndpointStats(key=" + this.key + ", totalRequests=" + this.totalRequests + ", lastActivity=" + this.lastActivity + ")";
43 | }
44 |
45 | public AtomicInteger getTotalRequests() {
46 | return this.totalRequests;
47 | }
48 |
49 | public AtomicLong getLastActivity() {
50 | return this.lastActivity;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/user/SimpleUserRealm.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.user;
21 |
22 | import java.util.Arrays;
23 | import java.util.Collection;
24 | import java.util.Collections;
25 | import org.carapaceproxy.configstore.ConfigurationStore;
26 | import org.carapaceproxy.server.config.ConfigurationNotValidException;
27 |
28 | /**
29 | * Simple implementation of an {@link UserRealm} that has only one user and it's
30 | * always authorized.
31 | *
32 | * @author matteo.minardi
33 | */
34 | public class SimpleUserRealm implements UserRealm {
35 |
36 | public static final String USERNAME = "admin";
37 |
38 | @Override
39 | public void configure(ConfigurationStore properties) throws ConfigurationNotValidException {
40 | }
41 |
42 | @Override
43 | public Collection listUsers() {
44 | return Collections.unmodifiableCollection(Arrays.asList(USERNAME));
45 | }
46 |
47 | @Override
48 | public String login(String username, String password) {
49 | return USERNAME;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/filters/XForwardedForRequestFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.filters;
21 |
22 | import java.net.InetSocketAddress;
23 | import org.carapaceproxy.core.ProxyRequest;
24 | import org.carapaceproxy.server.mapper.requestmatcher.RequestMatcher;
25 |
26 | /**
27 | * Add a X-Forwarded-For Header
28 | */
29 | @Deprecated
30 | public class XForwardedForRequestFilter extends BasicRequestFilter {
31 |
32 | @Deprecated
33 | public static final String TYPE = "add-x-forwarded-for";
34 |
35 | public XForwardedForRequestFilter(RequestMatcher matcher) {
36 | super(matcher);
37 | }
38 |
39 | @Override
40 | public void apply(ProxyRequest request) {
41 | if (!checkRequestMatching(request)) {
42 | return;
43 | }
44 | request.getRequestHeaders().remove("X-Forwarded-For");
45 | InetSocketAddress address = request.getRemoteAddress();
46 | request.getRequestHeaders().add("X-Forwarded-For", address.getAddress().getHostAddress());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/carapace-server/src/test/resources/localhost.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIIE4TCCAskCAQAwgYExCzAJBgNVBAYTAklUMRIwEAYDVQQIDAlsb2NhbGhvc3Qx
3 | EjAQBgNVBAcMCWxvY2FsaG9zdDEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0
4 | ZDESMBAGA1UEAwwJbG9jYWxob3N0MRgwFgYJKoZIhvcNAQkBFglsb2NhbGhvc3Qw
5 | ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDYgH5Q00H62+FWcG9qp11y
6 | UrNCNL/C9kn5Lf7J6tpclnqFY8NeARyBe3GtqbHNtmT07K+XA/V9JH2Wku+5T7Ro
7 | hZjBoCcbT5SD8wr3coAv089xRJiAc5/Q12kCS1hSfTg55INCqwzuAjBF2aO8/uAm
8 | B9HkmtZTxHdUKmhK+UH7Vzr9EaIOWi/LOqG1LVA0faS7hKsgjEJ77mJka0sF66nL
9 | EcyNY3Md5EFAkxFG2bKbnLadNXeBcJz7/jCyOvTIRIHGPK2kiKnq7yWvOjEaLqn5
10 | 1GVS4mZqUD/AUVXAoPxFBNsG0F3Tjq6u6ffFgiOM3ue5ACwiinvoacOHKraWjVvM
11 | fLQoS+DSTdz+2xXXoBhqFyvcFSUBqOcLmJ1fCIr5vtte8N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xRJn92hmMnyh3SI0Q0dtl2xrU0Lxa15D0Z84
28 | 0zCzoDg=
29 | -----END CERTIFICATE REQUEST-----
30 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/config/DirectorConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.config;
21 |
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | /**
26 | * A director is a group of backends
27 | *
28 | * @author enrico.olivelli
29 | */
30 | public class DirectorConfiguration {
31 |
32 | private final String id;
33 | private final List backends = new ArrayList<>();
34 |
35 | public static final String DEFAULT = "*";
36 |
37 | public static final String ALL_BACKENDS = "*";
38 |
39 | public DirectorConfiguration(String id) {
40 | this.id = id;
41 | }
42 |
43 | public DirectorConfiguration addBackend(String id) {
44 | if (!backends.contains(id)) {
45 | backends.add(id);
46 | }
47 | return this;
48 | }
49 |
50 | public String getId() {
51 | return id;
52 | }
53 |
54 | public List getBackends() {
55 | // no copy for efficiency, at runtime this bean is immutable
56 | return backends;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/client/ConnectionsManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.client;
21 |
22 | import org.carapaceproxy.core.EndpointKey;
23 | import org.carapaceproxy.core.RuntimeServerConfiguration;
24 |
25 | /**
26 | * Handles connection to all the endpoints
27 | *
28 | * @author enrico.olivelli
29 | */
30 | public interface ConnectionsManager extends AutoCloseable {
31 |
32 | /**
33 | * Obtain a connection to the requested endpoint. Connections are pooled, so
34 | * the returned object MUST be returned to the pool
35 | *
36 | * @param key
37 | * @return
38 | * @throws org.carapaceproxy.client.EndpointNotAvailableException
39 | */
40 | EndpointConnection getConnection(EndpointKey key) throws EndpointNotAvailableException;
41 |
42 | void start();
43 |
44 | @Override
45 | void close();
46 |
47 | ConnectionsManagerStats getStats();
48 |
49 | /**
50 | * Apply new configuration an runtime
51 | *
52 | * @param configuration
53 | */
54 | void applyNewConfiguration(RuntimeServerConfiguration configuration);
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/AndRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | import java.util.List;
23 | import java.util.stream.Collectors;
24 |
25 | /**
26 | *
27 | * Matcher for composing AND expressions with other matchers.
28 | *
29 | * @author paolo.venturi
30 | */
31 | public class AndRequestMatcher implements RequestMatcher {
32 |
33 | private final List matchers;
34 |
35 | public AndRequestMatcher(List matchers) {
36 | this.matchers = matchers;
37 | }
38 |
39 | @Override
40 | public boolean matches(MatchingContext context) {
41 | for (RequestMatcher matcher : matchers) {
42 | if (!matcher.matches(context)) {
43 | return false;
44 | }
45 | }
46 | return true;
47 | }
48 |
49 | @Override
50 | public String getDescription() {
51 | return matchers.stream()
52 | .map(RequestMatcher::getDescription)
53 | .collect(Collectors.joining(" and "));
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/core/ForwardedStrategy.java:
--------------------------------------------------------------------------------
1 | package org.carapaceproxy.core;
2 |
3 | import static org.carapaceproxy.core.ForwardedStrategies.StaticStrategies;
4 | import com.google.common.net.HttpHeaders;
5 | import io.netty.handler.codec.http.HttpRequest;
6 | import java.util.Set;
7 | import java.util.function.BiFunction;
8 | import org.carapaceproxy.configstore.ConfigurationStore;
9 | import org.carapaceproxy.core.ForwardedStrategies.IfTrusted;
10 | import reactor.netty.http.server.ConnectionInfo;
11 |
12 | public sealed interface ForwardedStrategy extends BiFunction permits StaticStrategies, IfTrusted {
13 |
14 | /**
15 | * Choose a strategy to handle {@value HttpHeaders#X_FORWARDED_FOR} header given and optional set of trusted IPs.
16 | *
17 | * @param name the name of the strategy from the {@link ConfigurationStore config}
18 | * @param trustedIps an optional set of trusted IPs from the {@link ConfigurationStore config}
19 | * @return the appropriate strategy object
20 | */
21 | static ForwardedStrategy of(final String name, final Set trustedIps) {
22 | if (StaticStrategies.DROP.name().equals(name)) {
23 | return ForwardedStrategies.drop();
24 | }
25 | if (StaticStrategies.PRESERVE.name().equals(name)) {
26 | return ForwardedStrategies.preserve();
27 | }
28 | if (StaticStrategies.REWRITE.name().equals(name)) {
29 | return ForwardedStrategies.rewrite();
30 | }
31 | if (IfTrusted.NAME.equals(name)) {
32 | return ForwardedStrategies.ifTrusted(trustedIps);
33 | }
34 | throw new IllegalArgumentException("Unexpected forwarded strategy: " + name);
35 | }
36 |
37 | /**
38 | * Get a name for the strategy.
39 | *
40 | * @return the name
41 | * @see Enum#name()
42 | */
43 | String name();
44 | }
45 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/components/Routes.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Routes
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/carapace-server/src/test/resources/ia.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIFOzCCAyMCAQEwDQYJKoZIhvcNAQELBQAwZjELMAkGA1UEBhMCSVQxDjAMBgNV
3 | BAgMBUl0YWx5MRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1
4 | bHQgQ29tcGFueSBMdGQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xODA1MjgxNDM4
5 | MjlaFw0yMDA1MjcxNDM4MjlaMGExCzAJBgNVBAYTAlhYMQ4wDAYDVQQIDAVJdGFs
6 | eTEOMAwGA1UEBwwFSXRhbHkxDjAMBgNVBAoMBUl0YWx5MQ4wDAYDVQQLDAVJdGFs
7 | eTESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
8 | CgKCAgEAunQDCXeDZED5ICeCR+WsrrZYG3EUyqC/R9hQ63VxMgUDVbb1Q0s0ESnE
9 | 4Q/Z95wa5chykCmQY5Q0eltClyE23uWb7uNfUClRhVlx9pRff9lMGu8fhmcmxME3
10 | zjaKjV4j2L59XScfWQNT88wA/i1ycp/MtrKeRvog5LID4PA8UMA4vpe2a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9xqnKFS4zHpdXjjMFYrsHB
27 | egiDkXVXzk7HyIIeQ06wr9VT9CDOjtT2bXQHyul6j8OFr5miUNJ0XEqNQxhTDwiA
28 | Yj4XdOYd/Iqg+VgRtEkJGu7aMcxx8Ikckr4uUsB90hKvhSYjpmXiZWjb+hy1Rqeh
29 | +1QXFtAV1ROSL6kmH5hF8+F+p/YOvXvwI7YwRvfE6gqM6qGLOFB/iu7aiqtP+T0=
30 | -----END CERTIFICATE-----
31 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import App from "./App.vue";
3 | import router from "./router";
4 | import "./app.scss";
5 | import { toBooleanSymbol } from "./lib/formatter";
6 | import { formatTimestamp } from "./lib/formatter";
7 | import BootstrapVue from "bootstrap-vue";
8 | import "bootstrap/dist/css/bootstrap.css";
9 | import "bootstrap-vue/dist/bootstrap-vue.css";
10 |
11 | // Icons
12 | import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
13 | import { library } from "@fortawesome/fontawesome-svg-core";
14 | import {
15 | faAngleRight,
16 | faArchive,
17 | faBolt,
18 | faChartBar,
19 | faCircleInfo,
20 | faCrosshairs,
21 | faDatabase,
22 | faDoorOpen,
23 | faFileSignature,
24 | faFilter,
25 | faHeading,
26 | faHome,
27 | faInfo,
28 | faMapSigns,
29 | faNetworkWired,
30 | faServer,
31 | faSlidersH,
32 | faUsers
33 | } from "@fortawesome/free-solid-svg-icons";
34 | library.add(faAngleRight);
35 | library.add(faArchive);
36 | library.add(faBolt);
37 | library.add(faChartBar);
38 | library.add(faCircleInfo);
39 | library.add(faCrosshairs);
40 | library.add(faDatabase);
41 | library.add(faDoorOpen);
42 | library.add(faFileSignature);
43 | library.add(faFilter);
44 | library.add(faHeading);
45 | library.add(faHome);
46 | library.add(faInfo);
47 | library.add(faMapSigns);
48 | library.add(faNetworkWired);
49 | library.add(faServer);
50 | library.add(faSlidersH);
51 | library.add(faUsers);
52 |
53 | Vue.component("font-awesome-icon", FontAwesomeIcon);
54 |
55 | // Boostrap Vue
56 | Vue.use(BootstrapVue);
57 |
58 | Vue.config.productionTip = false;
59 |
60 | // Filters
61 | Vue.filter("symbolFormat", value => {
62 | return toBooleanSymbol(value);
63 | });
64 | Vue.filter("dateFormat", value => {
65 | if (!value || value <= 0) {
66 | return "";
67 | }
68 | return formatTimestamp(value);
69 | });
70 |
71 | new Vue({
72 | router: router,
73 | render: h => h(App)
74 | }).$mount("#app");
75 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/ForceHeadersAPIRequestsFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.api;
21 |
22 | import java.io.IOException;
23 | import javax.servlet.Filter;
24 | import javax.servlet.FilterChain;
25 | import javax.servlet.FilterConfig;
26 | import javax.servlet.ServletException;
27 | import javax.servlet.ServletRequest;
28 | import javax.servlet.ServletResponse;
29 | import javax.servlet.http.HttpServletResponse;
30 |
31 | /**
32 | * No cache API responses
33 | *
34 | * @author enrico.olivelli
35 | */
36 | public class ForceHeadersAPIRequestsFilter implements Filter {
37 |
38 | @Override
39 | public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
40 | throws IOException, ServletException {
41 | HttpServletResponse resp = (HttpServletResponse) response;
42 | resp.setHeader("Cache-Control", "no-cache");
43 | resp.setHeader("Access-Control-Allow-Origin", "*");
44 | chain.doFilter(request, response);
45 | }
46 |
47 | @Override
48 | public void init(FilterConfig filterConfig) throws ServletException {
49 | }
50 |
51 | @Override
52 | public void destroy() {
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/carapace-server/src/main/resources/bin/java-utils.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to Diennea S.r.l. under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. Diennea S.r.l. licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | if [ $# -lt 1 ];
21 | then
22 | echo "USAGE: $0 [-daemon] SERVICETYPE [jvmargs]"
23 | exit 1
24 | fi
25 |
26 |
27 | if [ -z "$BASE_DIR" ];
28 | then
29 | BASE_DIR="`dirname \"$0\"`"
30 | BASE_DIR="`( cd \"$BASE_DIR/..\" && pwd )`"
31 | fi
32 |
33 | cd $BASE_DIR
34 | . $BASE_DIR/bin/setenv.sh
35 |
36 |
37 | CLASSPATH=
38 |
39 | for file in $BASE_DIR/lib/*.jar;
40 | do
41 | CLASSPATH=$CLASSPATH:$file
42 | done
43 |
44 | for file in $BASE_DIR/extra/*.jar;
45 | do
46 | CLASSPATH=$CLASSPATH:$file
47 | done
48 |
49 |
50 | if [ -z "$JAVA_OPTS" ]; then
51 | JAVA_OPTS=""
52 | fi
53 |
54 | JAVA="$JAVA_HOME/bin/java"
55 |
56 | while [ $# -gt 0 ]; do
57 | COMMAND=$1
58 | case $COMMAND in
59 | -daemon)
60 | DAEMON_MODE="true"
61 | shift
62 | ;;
63 | *)
64 | break
65 | ;;
66 | esac
67 | done
68 |
69 | SERVICE=$1
70 | shift
71 |
72 | if [ "x$DAEMON_MODE" = "xtrue" ]; then
73 | CONSOLE_OUTPUT_FILE=$SERVICE.service.log
74 | nohup $JAVA -cp $CLASSPATH $JAVA_OPTS "$@" >> "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
75 | RETVAL=$?
76 | else
77 | exec $JAVA -cp $CLASSPATH $JAVA_OPTS "$@"
78 | RETVAL=$?
79 | fi
80 |
--------------------------------------------------------------------------------
/carapace-server/src/test/resources/localhost.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIFgDCCA2gCCQCYkuRWgRtpszANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMC
3 | SVQxEjAQBgNVBAgMCWxvY2FsaG9zdDESMBAGA1UEBwwJbG9jYWxob3N0MRwwGgYD
4 | VQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMRIwEAYDVQQDDAlsb2NhbGhvc3QxGDAW
5 | BgkqhkiG9w0BCQEWCWxvY2FsaG9zdDAeFw0xNzA4MjgwOTU0MzRaFw0yNzA4MjYw
6 | OTU0MzRaMIGBMQswCQYDVQQGEwJJVDESMBAGA1UECAwJbG9jYWxob3N0MRIwEAYD
7 | VQQHDAlsb2NhbGhvc3QxHDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBMdGQxEjAQ
8 | BgNVBAMMCWxvY2FsaG9zdDEYMBYGCSqGSIb3DQEJARYJbG9jYWxob3N0MIICIjAN
9 | BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2IB+UNNB+tvhVnBvaqddclKzQjS/
10 | wvZJ+S3+yeraXJZ6hWPDXgEcgXtxramxzbZk9OyvlwP1fSR9lpLvuU+0aIWYwaAn
11 | G0+Ug/MK93KAL9PPcUSYgHOf0NdpAktYUn04OeSDQqsM7gIwRdmjvP7gJgfR5JrW
12 | U8R3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ng0fGwhL4svPzMBkRSMoxxVTngw1Z//rHCQ6QLus82vI02SKBOFRw3Ely4WLYQPg
29 | esjuD86K1RevfJmJCFI6096eDXieFNBbbUwZHN9BlV9SP/gX+phmtQb4Wx0k0BZd
30 | p+N2CwBOgZRrouBU3C+xHThurgAUpsSft6TMeu8WwnCItB2wcKFwZz0COcPEFEgx
31 | GrqZOd5vWBHUBSTTWPpuT4sH2wI=
32 | -----END CERTIFICATE-----
33 |
--------------------------------------------------------------------------------
/carapace-server/src/test/resources/ca.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIFojCCA4qgAwIBAgIJAI6iDlWsvtPwMA0GCSqGSIb3DQEBCwUAMGYxCzAJBgNV
3 | BAYTAklUMQ4wDAYDVQQIDAVJdGFseTEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRww
4 | GgYDVQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMRIwEAYDVQQDDAlsb2NhbGhvc3Qw
5 | HhcNMTgwNTI4MTQzODAyWhcNMjMwNTI4MTQzODAyWjBmMQswCQYDVQQGEwJJVDEO
6 | MAwGA1UECAwFSXRhbHkxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwT
7 | RGVmYXVsdCBDb21wYW55IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkq
8 | hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArtftMM+DLoHfX1eABbSkewi9c75WNuyf
9 | o+STbryC68/hMIuKB0UmrxlX+E0yN6SVvwBk+VXwtorGYatmHkDmL4Lo33z/5aqT
10 | LUpQaI77aa05IeKUOy2QZlP0jN4yXiwP+Xjkwt+Y7x3MxNMl/6Dg1dB9UGNesHdO
11 | Jbzz66kEg3HN7ZceWpP4kE2OtsUY5PtZu2STJKzaR3deTzSsiux/Cux+EbRMkf+e
12 | o44NC5y1Gmt5pxpfuOy7RmBJGNXkreoJ50RRiIkTsh9Us/xwP37KjkCqHWkxN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p79lhdNuf1YKXW5dEFIxS8HdySh
29 | nmVWEeGTpBA/ynVo0od+Pbx6MdOdV0RWDI0z9hvZlZLi2xcEeRwk04DnKhESxPzo
30 | 152WsQxZ5rzcyRX27HEzM2Pm8kQiySDgIwq2vUlCJpdqgC1LKd2QqcsQJobjv6JZ
31 | LQwmnl+p52nJTcnFX0TgVHU9wqd4OsaUlzDoiwHiRr+xM0XuWcfPbF14a8Rw4Ybu
32 | epcUTH+d
33 | -----END CERTIFICATE-----
34 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/core/OcspSslHandler.java:
--------------------------------------------------------------------------------
1 | package org.carapaceproxy.core;
2 |
3 | import io.netty.handler.ssl.ReferenceCountedOpenSslEngine;
4 | import io.netty.handler.ssl.SslContext;
5 | import io.netty.handler.ssl.SslHandler;
6 | import io.netty.util.AttributeKey;
7 | import java.io.IOException;
8 | import java.security.cert.Certificate;
9 | import java.util.function.Consumer;
10 | import org.carapaceproxy.server.certificates.ocsp.OcspStaplingManager;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | public class OcspSslHandler implements Consumer {
15 | private static final Logger LOG = LoggerFactory.getLogger(OcspSslHandler.class);
16 | private static final AttributeKey ATTRIBUTE = AttributeKey.valueOf(Listeners.OCSP_CERTIFICATE_CHAIN);
17 |
18 | private final SslContext sslContext;
19 | private final OcspStaplingManager ocspStaplingManager;
20 |
21 | public OcspSslHandler(final SslContext sslContext, final OcspStaplingManager ocspStaplingManager1) {
22 | this.sslContext = sslContext;
23 | this.ocspStaplingManager = ocspStaplingManager1;
24 | }
25 |
26 | @Override
27 | public void accept(final SslHandler sslHandler) {
28 | final Certificate cert = sslContext.attributes().attr(ATTRIBUTE).get();
29 | if (cert == null) {
30 | LOG.error("Cannot set OCSP response without the certificate");
31 | return;
32 | }
33 | if (!(sslHandler.engine() instanceof ReferenceCountedOpenSslEngine engine)) {
34 | LOG.error("Unexpected SSL handler type: {}", sslHandler.engine());
35 | return;
36 | }
37 | try {
38 | final byte[] ocspResponse = ocspStaplingManager.getOcspResponseForCertificate(cert);
39 | if (ocspResponse == null) {
40 | LOG.error("No OCSP response for certificate: {}", cert);
41 | return;
42 | }
43 | engine.setOcspResponse(ocspResponse);
44 | } catch (IOException ex) {
45 | LOG.error("Error setting OCSP response.", ex);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/server/mapper/requestmatcher/OrRequestMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.server.mapper.requestmatcher;
21 |
22 | import java.util.List;
23 | import java.util.stream.Collectors;
24 |
25 | /**
26 | *
27 | * Matcher for composing OR expressions with other matchers.
28 | *
29 | * @author paolo.venturi
30 | */
31 | public class OrRequestMatcher implements RequestMatcher {
32 |
33 | private final List matchers;
34 | private final boolean wrap;
35 |
36 | public OrRequestMatcher(List matchers, boolean wrap) {
37 | this.matchers = matchers;
38 | this.wrap = wrap;
39 | }
40 |
41 | @Override
42 | public boolean matches(MatchingContext context) {
43 | for (RequestMatcher matcher : matchers) {
44 | if (matcher.matches(context)) {
45 | return true;
46 | }
47 | }
48 | return false;
49 | }
50 |
51 | @Override
52 | public String getDescription() {
53 | String desc = wrap ? "(" : "";
54 | desc += matchers.stream()
55 | .map(RequestMatcher::getDescription)
56 | .collect(Collectors.joining(" or "));
57 | desc += wrap ? ")" : "";
58 |
59 | return desc;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/carapace-server/src/main/java/org/carapaceproxy/api/ApplicationConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to Diennea S.r.l. under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. Diennea S.r.l. licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 |
19 | */
20 | package org.carapaceproxy.api;
21 |
22 | import java.util.Set;
23 | import javax.ws.rs.ApplicationPath;
24 | import javax.ws.rs.core.Application;
25 |
26 | /**
27 | * Configuration of the REST API
28 | *
29 | * @author enrico.olivelli
30 | */
31 | @ApplicationPath("api")
32 | public class ApplicationConfig extends Application {
33 |
34 | @Override
35 | public Set> getClasses() {
36 | Set> resources = new java.util.HashSet<>();
37 | resources.add(CacheResource.class);
38 | resources.add(ServiceUpResource.class);
39 | resources.add(BackendsResource.class);
40 | resources.add(ConnectionPoolsResource.class);
41 | resources.add(RoutesResource.class);
42 | resources.add(ActionsResource.class);
43 | resources.add(DirectorsResource.class);
44 | resources.add(ConfigResource.class);
45 | resources.add(ListenersResource.class);
46 | resources.add(CertificatesResource.class);
47 | resources.add(RequestFiltersResource.class);
48 | resources.add(UserRealmResource.class);
49 | resources.add(MetricsResource.class);
50 | resources.add(ClusterResource.class);
51 | resources.add(HeadersResource.class);
52 | return resources;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/carapace-ui/src/main/webapp/src/components/Listeners.vue:
--------------------------------------------------------------------------------
1 |
2 |