Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
predic8 committed Mar 14, 2024
1 parent af42041 commit b861a3c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
import static java.util.Map.of;
import static java.util.stream.Stream.ofNullable;

/**
* @description Secure endpoints using API keys combined with role-based access control (RBAC).
* @topic 6. Security
*/
@MCElement(name = "apiKey")
public class ApiKeysInterceptor extends AbstractInterceptor {
private final Logger log = LoggerFactory.getLogger(ApiKeysInterceptor.class);
public class ApiKeyInterceptor extends AbstractInterceptor {
private final Logger log = LoggerFactory.getLogger(ApiKeyInterceptor.class);

public static final String SCOPES = "membrane-scopes";
public static final String TYPE_4XX = "/authorization-denied";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
limitations under the License. */
package com.predic8.membrane.core.lang.spel.functions;

import com.predic8.membrane.core.http.Header;
import com.predic8.membrane.core.interceptor.AbstractInterceptorWithSession;
import com.predic8.membrane.core.lang.spel.ExchangeEvaluationContext;
import org.apache.http.auth.AUTH;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.function.Predicate;

import static com.predic8.membrane.core.http.Header.AUTHORIZATION;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeysInterceptor.SCOPES;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeyInterceptor.SCOPES;
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import static com.predic8.membrane.core.http.MimeType.*;
import static com.predic8.membrane.core.interceptor.Outcome.*;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeysInterceptor.*;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeyInterceptor.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.List.*;
Expand All @@ -36,9 +36,9 @@ public class ApiKeysInterceptorTest {
static ApiKeyFileStore mergeStore;
static ApiKeyHeaderExtractor ahe;
static ApiKeyQueryParamExtractor aqe;
static ApiKeysInterceptor akiWithProp;
static ApiKeysInterceptor akiWithoutProp;
static ApiKeysInterceptor akiWithTwoStores;
static ApiKeyInterceptor akiWithProp;
static ApiKeyInterceptor akiWithoutProp;
static ApiKeyInterceptor akiWithTwoStores;

@BeforeAll
static void setup() {
Expand All @@ -55,16 +55,16 @@ static void setup() {
ahe = new ApiKeyHeaderExtractor();
aqe = new ApiKeyQueryParamExtractor();

akiWithProp = new ApiKeysInterceptor();
akiWithProp = new ApiKeyInterceptor();
akiWithProp.setExtractors(of(ahe));
akiWithProp.setStores(of(store));

akiWithoutProp = new ApiKeysInterceptor();
akiWithoutProp = new ApiKeyInterceptor();
akiWithoutProp.setExtractors(of(ahe));
akiWithoutProp.setRequired(false);
akiWithoutProp.setStores(of(store));

akiWithTwoStores = new ApiKeysInterceptor();
akiWithTwoStores = new ApiKeyInterceptor();
akiWithTwoStores.setStores(of(store, mergeStore));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;

import static com.predic8.membrane.core.interceptor.Outcome.CONTINUE;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeysInterceptor.SCOPES;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeyInterceptor.SCOPES;
import static java.util.List.of;

class ConditionalEvaluationTestContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;
import java.util.List;

import static com.predic8.membrane.core.http.Header.AUTHORIZATION;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeysInterceptor.SCOPES;
import static com.predic8.membrane.core.interceptor.apikey.ApiKeyInterceptor.SCOPES;
import static java.util.List.of;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down

0 comments on commit b861a3c

Please sign in to comment.