Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for property replacements (from system properties and e…
…nvironment variables) in policy configurations, endpoints, and endpoint properties
- Loading branch information
1 parent
4bde983
commit 0eff881
Showing
13 changed files
with
503 additions
and
1 deletion.
There are no files selected for viewing
150 changes: 150 additions & 0 deletions
150
distro/data/src/main/resources/data/basic-settings.apiman.json
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,150 @@ | ||
{ | ||
"Metadata" : { | ||
"exportedOn" : 1449850746726, | ||
"apimanVersion" : "1.2.0-SNAPSHOT" | ||
}, | ||
"Users" : [ { | ||
"username" : "admin", | ||
"fullName" : "admin", | ||
"email" : "", | ||
"joinedOn" : 1449850499639, | ||
"admin" : false | ||
} ], | ||
"Gateways" : [ ], | ||
"Plugins" : [ ], | ||
"Roles" : [ { | ||
"id" : "ClientAppDeveloper", | ||
"name" : "Client App Developer", | ||
"description" : "Users responsible for creating and managing client apps should be granted this role within an Organization.", | ||
"createdBy" : "admin", | ||
"createdOn" : 1449850701029, | ||
"permissions" : [ "clientAdmin", "clientView", "clientEdit" ] | ||
}, { | ||
"id" : "OrganizationOwner", | ||
"name" : "Organization Owner", | ||
"description" : "Automatically granted to the user who creates an Organization. Grants all privileges.", | ||
"createdBy" : "admin", | ||
"createdOn" : 1449850685799, | ||
"autoGrant" : true, | ||
"permissions" : [ "orgAdmin", "clientAdmin", "planView", "apiView", "clientView", "apiAdmin", "clientEdit", "planEdit", "apiEdit", "orgEdit", "orgView", "planAdmin" ] | ||
}, { | ||
"id" : "APIDeveloper", | ||
"name" : "API Developer", | ||
"description" : "Users responsible for creating and managing APIs should be granted this role within an Organization.", | ||
"createdBy" : "admin", | ||
"createdOn" : 1449850717969, | ||
"permissions" : [ "planView", "apiView", "apiAdmin", "planEdit", "apiEdit", "planAdmin" ] | ||
} ], | ||
"PolicyDefinitions" : [ { | ||
"id" : "RateLimitingPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.RateLimitingPolicy", | ||
"name" : "Rate Limiting Policy", | ||
"description" : "Enforces rate configurable request rate limits on an API. This ensures that consumers can't overload an API with too many requests.", | ||
"icon" : "tachometer", | ||
"templates" : [ { | ||
"template" : "Consumers are limited to @{limit} requests per @{granularity} per @{period}." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "QuotaPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.QuotaPolicy", | ||
"name" : "Quota Policy", | ||
"description" : "Provides a way to limit the total number of requests that can be sent to an API.", | ||
"icon" : "exchange", | ||
"templates" : [ { | ||
"template" : "Consumers cannot exceed their quota of @{limit} requests per @{granularity} per @{period}." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "IgnoredResourcesPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.IgnoredResourcesPolicy", | ||
"name" : "Ignored Resources Policy", | ||
"description" : "Requests satisfying the provided regular expression will be ignored.", | ||
"icon" : "eye-slash", | ||
"templates" : [ { | ||
"template" : "Requests matching any of the @{pathsToIgnore.size()} regular expressions provided will receive a 404 error code." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "IPWhitelistPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.IPWhitelistPolicy", | ||
"name" : "IP Whitelist Policy", | ||
"description" : "Only requests that originate from a specified set of valid IP addresses will be allowed through.", | ||
"icon" : "thumbs-up", | ||
"templates" : [ { | ||
"template" : "Only requests that originate from the set of @{ipList.size()} configured IP address(es) will be allowed to invoke the managed API." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "TransferQuotaPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.TransferQuotaPolicy", | ||
"name" : "Transfer Quota Policy", | ||
"description" : "Provides a way to limit the total number of bytes that can be transferred from (or to) an API.", | ||
"icon" : "download", | ||
"templates" : [ { | ||
"template" : "Consumers are limited to transferring @{limit} bytes per @{granularity} per @{period}." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "IPBlacklistPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.IPBlacklistPolicy", | ||
"name" : "IP Blacklist Policy", | ||
"description" : "Requests that originate from a specified set of valid IP addresses will be denied access.", | ||
"icon" : "thumbs-down", | ||
"templates" : [ { | ||
"template" : "Requests that originate from the set of @{ipList.size()} configured IP address(es) will be denied access to the managed API." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "URLRewritingPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.URLRewritingPolicy", | ||
"name" : "URL Rewriting Policy", | ||
"description" : "Responses from the back-end API will be modified by fixing up any incorrect URLs found with modified ones. This is useful because apiman works through an API Gateway.", | ||
"icon" : "pencil-square", | ||
"templates" : [ { | ||
"template" : "Responses will be modified by finding all text matching regular expression '@{fromRegex}' with '@{toReplacement}'." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "CachingPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.CachingPolicy", | ||
"name" : "Caching Policy", | ||
"description" : "Allows caching of API responses in the Gateway to reduce overall traffic to the back-end API.", | ||
"icon" : "hdd-o", | ||
"templates" : [ { | ||
"template" : "API responses will be cached for @{ttl} seconds." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "BASICAuthenticationPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.BasicAuthenticationPolicy", | ||
"name" : "BASIC Authentication Policy", | ||
"description" : "Enables HTTP BASIC Authentication on an API. Some configuration required.", | ||
"icon" : "lock", | ||
"templates" : [ { | ||
"template" : "Access to the API is protected by BASIC Authentication through the '@{realm}' authentication realm. @if{forwardIdentityHttpHeader != null}Successfully authenticated requests will forward the authenticated identity to the back end API via the '@{forwardIdentityHttpHeader}' custom HTTP header.@end{}" | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
}, { | ||
"id" : "AuthorizationPolicy", | ||
"policyImpl" : "class:io.apiman.gateway.engine.policies.AuthorizationPolicy", | ||
"name" : "Authorization Policy", | ||
"description" : "Enables fine grained authorization to API resources based on authenticated user roles.", | ||
"icon" : "users", | ||
"templates" : [ { | ||
"template" : "Appropriate authorization roles are required. There are @{rules.size()} authorization rules defined." | ||
} ], | ||
"formType" : "Default", | ||
"deleted" : false | ||
} ], | ||
"Orgs" : [ ] | ||
} |
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
40 changes: 40 additions & 0 deletions
40
gateway/engine/core/src/main/java/io/apiman/gateway/engine/util/ApimanStrLookup.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,40 @@ | ||
/* | ||
* Copyright 2015 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.apiman.gateway.engine.util; | ||
|
||
import org.apache.commons.lang.text.StrLookup; | ||
|
||
/** | ||
* A simple string lookup class that supports system properties and environment | ||
* variables. | ||
* | ||
* @author eric.wittmann@redhat.com | ||
*/ | ||
public class ApimanStrLookup extends StrLookup { | ||
|
||
/** | ||
* @see org.apache.commons.lang.text.StrLookup#lookup(java.lang.String) | ||
*/ | ||
@Override | ||
public String lookup(String key) { | ||
String replacement = System.getProperty(key); | ||
if (replacement == null) { | ||
System.getenv(key); | ||
} | ||
return replacement; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
gateway/test/src/test/java/io/apiman/gateway/test/SimpleEchoReplacementTest.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,36 @@ | ||
/* | ||
* Copyright 2014 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.apiman.gateway.test; | ||
|
||
import io.apiman.gateway.test.junit.GatewayRestTestPlan; | ||
import io.apiman.gateway.test.junit.GatewayRestTestSystemProperties; | ||
import io.apiman.gateway.test.junit.GatewayRestTester; | ||
|
||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @author eric.wittmann@redhat.com | ||
*/ | ||
@RunWith(GatewayRestTester.class) | ||
@GatewayRestTestPlan("test-plans/simple/simple-echo-replacement-testPlan.xml") | ||
@GatewayRestTestSystemProperties({ | ||
"SimpleEchoReplacementTest-path", "echo-replacement", | ||
"SimpleEchoReplacementTest-field-1", "FIELD-1-VALUE", | ||
"SimpleEchoReplacementTest-field-2", "FIELD-2-VALUE" | ||
}) | ||
public class SimpleEchoReplacementTest { | ||
|
||
} |
Oops, something went wrong.