Class ApiKeysInterceptor
java.lang.Object
com.predic8.membrane.core.interceptor.AbstractInterceptor
com.predic8.membrane.core.interceptor.apikey.ApiKeysInterceptor
- All Implemented Interfaces:
Interceptor
- Description
- Secures APIs by validating keys stored in either files or proxies.xml. Keys can be received from clients via HTTP headers or URL query parameters. Additional permission checks are possible through scope validation - scopes are loaded into an Exchange property and can be checked using the "hasScope()" SpEL function.
- Topic
- 6. Security
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.predic8.membrane.core.interceptor.Interceptor
Interceptor.Flow -
Field Summary
FieldsFields inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
name, router -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhandleRequest(Exchange exc) voidinit()Called after parsing is complete and this has been added to the object tree (whose root is Router).booleanvoidsetExtractors(List<ApiKeyExtractor> extractors) voidsetRequired(boolean required) voidsetStores(List<ApiKeyStore> stores) Methods inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
getDisplayName, getFlow, getHelpId, getMessage, getRouter, getRule, handleAbort, handleResponse, init, setDisplayName, setFlow
-
Field Details
-
SCOPES
- See Also:
-
TYPE_4XX
- See Also:
-
TITLE_4XX
- See Also:
-
-
Constructor Details
-
ApiKeysInterceptor
public ApiKeysInterceptor()
-
-
Method Details
-
getShortDescription
- Specified by:
getShortDescriptionin interfaceInterceptor- Overrides:
getShortDescriptionin classAbstractInterceptor
-
getLongDescription
- Specified by:
getLongDescriptionin interfaceInterceptor- Overrides:
getLongDescriptionin classAbstractInterceptor
-
init
public void init()Description copied from class:AbstractInterceptorCalled after parsing is complete and this has been added to the object tree (whose root is Router).- Overrides:
initin classAbstractInterceptor
-
handleRequest
- Specified by:
handleRequestin interfaceInterceptor- Overrides:
handleRequestin classAbstractInterceptor
-
getScopes
- Throws:
UnauthorizedApiKeyException
-
getKey
-
setRequired
public void setRequired(boolean required) - Default
- true
- Description
- Controls whether API key validation is enforced or optional. Optional will still load scopes and make them available for checking through SpEL function "hasScope()".
- Example
- false
-
isRequired
public boolean isRequired() -
setStores
- Description
- API key stores to validate keys against
-
getStores
-
setExtractors
- Default
(Using default header "X-Api-Key") - Description
- Extractors that define where and how to extract API keys from requests
-
getExtractors
-