Skip to content

Commit

Permalink
CAMEL-20503: camel-http OAuth2 support for caching / refreshing tokens
Browse files Browse the repository at this point in the history
- added caching oauth2 tokens for http component, and configuration parameters for caching
  • Loading branch information
kulagaIA committed Nov 11, 2024
1 parent fe4c0f3 commit 1c53621
Show file tree
Hide file tree
Showing 18 changed files with 740 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"optionsEnabled": { "index": 24, "kind": "parameter", "displayName": "Options Enabled", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Specifies whether to enable HTTP OPTIONS for this Servlet consumer. By default OPTIONS is turned off." },
"traceEnabled": { "index": 25, "kind": "parameter", "displayName": "Trace Enabled", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Specifies whether to enable HTTP TRACE for this Servlet consumer. By default TRACE is turned off." },
"bridgeEndpoint": { "index": 26, "kind": "parameter", "displayName": "Bridge Endpoint", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the option is true, HttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back." },
"lazyStartProducer": { "index": 27, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }
"lazyStartProducer": { "index": 27, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
"oauth2CachedTokensDefaultExpirySeconds": { "index": 28, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Default Expiry Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 3600, "description": "Default expiration time for cached OAuth2 tokens, in seconds. Used if token response does not contain 'expires_in' field." },
"oauth2CachedTokensExpirationMarginSeconds": { "index": 29, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Expiration Margin Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 5, "description": "Amount of time which is deducted from OAuth2 tokens expiry time to compensate for the time it takes OAuth2 Token Endpoint to send the token over http, in seconds. Set this parameter to high value if you OAuth2 Token Endpoint answers slowly or you tokens expire quickly. If you set this parameter to too small value, you can get 4xx http errors because camel will think that the received token is still valid, while in reality the token is expired for the Authentication server." },
"oauth2CacheTokens": { "index": 30, "kind": "parameter", "displayName": "Oauth2 Cache Tokens", "group": "security", "label": "producer,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to cache OAuth2 client tokens." }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@
"authMethodPriority": { "index": 46, "kind": "parameter", "displayName": "Auth Method Priority", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "Basic", "Digest", "NTLM" ], "deprecated": false, "autowired": false, "secret": false, "description": "Which authentication method to prioritize to use, either as Basic, Digest or NTLM." },
"authPassword": { "index": 47, "kind": "parameter", "displayName": "Auth Password", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Authentication password" },
"authUsername": { "index": 48, "kind": "parameter", "displayName": "Auth Username", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Authentication username" },
"oauth2ClientId": { "index": 49, "kind": "parameter", "displayName": "Oauth2 Client Id", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client id" },
"oauth2ClientSecret": { "index": 50, "kind": "parameter", "displayName": "Oauth2 Client Secret", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client secret" },
"oauth2Scope": { "index": 51, "kind": "parameter", "displayName": "Oauth2 Scope", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 52, "kind": "parameter", "displayName": "Oauth2 Token Endpoint", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 Token endpoint" },
"sslContextParameters": { "index": 53, "kind": "parameter", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need." },
"x509HostnameVerifier": { "index": 54, "kind": "parameter", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier" }
"oauth2CachedTokensDefaultExpirySeconds": { "index": 49, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Default Expiry Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 3600, "description": "Default expiration time for cached OAuth2 tokens, in seconds. Used if token response does not contain 'expires_in' field." },
"oauth2CachedTokensExpirationMarginSeconds": { "index": 50, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Expiration Margin Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 5, "description": "Amount of time which is deducted from OAuth2 tokens expiry time to compensate for the time it takes OAuth2 Token Endpoint to send the token over http, in seconds. Set this parameter to high value if you OAuth2 Token Endpoint answers slowly or you tokens expire quickly. If you set this parameter to too small value, you can get 4xx http errors because camel will think that the received token is still valid, while in reality the token is expired for the Authentication server." },
"oauth2CacheTokens": { "index": 51, "kind": "parameter", "displayName": "Oauth2 Cache Tokens", "group": "security", "label": "producer,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to cache OAuth2 client tokens." },
"oauth2ClientId": { "index": 52, "kind": "parameter", "displayName": "Oauth2 Client Id", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client id" },
"oauth2ClientSecret": { "index": 53, "kind": "parameter", "displayName": "Oauth2 Client Secret", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client secret" },
"oauth2Scope": { "index": 54, "kind": "parameter", "displayName": "Oauth2 Scope", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 55, "kind": "parameter", "displayName": "Oauth2 Token Endpoint", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 Token endpoint" },
"sslContextParameters": { "index": 56, "kind": "parameter", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need." },
"x509HostnameVerifier": { "index": 57, "kind": "parameter", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@
"authMethodPriority": { "index": 46, "kind": "parameter", "displayName": "Auth Method Priority", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "Basic", "Digest", "NTLM" ], "deprecated": false, "autowired": false, "secret": false, "description": "Which authentication method to prioritize to use, either as Basic, Digest or NTLM." },
"authPassword": { "index": 47, "kind": "parameter", "displayName": "Auth Password", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Authentication password" },
"authUsername": { "index": 48, "kind": "parameter", "displayName": "Auth Username", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Authentication username" },
"oauth2ClientId": { "index": 49, "kind": "parameter", "displayName": "Oauth2 Client Id", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client id" },
"oauth2ClientSecret": { "index": 50, "kind": "parameter", "displayName": "Oauth2 Client Secret", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client secret" },
"oauth2Scope": { "index": 51, "kind": "parameter", "displayName": "Oauth2 Scope", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 52, "kind": "parameter", "displayName": "Oauth2 Token Endpoint", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 Token endpoint" },
"sslContextParameters": { "index": 53, "kind": "parameter", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need." },
"x509HostnameVerifier": { "index": 54, "kind": "parameter", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier" }
"oauth2CachedTokensDefaultExpirySeconds": { "index": 49, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Default Expiry Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 3600, "description": "Default expiration time for cached OAuth2 tokens, in seconds. Used if token response does not contain 'expires_in' field." },
"oauth2CachedTokensExpirationMarginSeconds": { "index": 50, "kind": "parameter", "displayName": "Oauth2 Cached Tokens Expiration Margin Seconds", "group": "security", "label": "producer,security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 5, "description": "Amount of time which is deducted from OAuth2 tokens expiry time to compensate for the time it takes OAuth2 Token Endpoint to send the token over http, in seconds. Set this parameter to high value if you OAuth2 Token Endpoint answers slowly or you tokens expire quickly. If you set this parameter to too small value, you can get 4xx http errors because camel will think that the received token is still valid, while in reality the token is expired for the Authentication server." },
"oauth2CacheTokens": { "index": 51, "kind": "parameter", "displayName": "Oauth2 Cache Tokens", "group": "security", "label": "producer,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to cache OAuth2 client tokens." },
"oauth2ClientId": { "index": 52, "kind": "parameter", "displayName": "Oauth2 Client Id", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client id" },
"oauth2ClientSecret": { "index": 53, "kind": "parameter", "displayName": "Oauth2 Client Secret", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth2 client secret" },
"oauth2Scope": { "index": 54, "kind": "parameter", "displayName": "Oauth2 Scope", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 55, "kind": "parameter", "displayName": "Oauth2 Token Endpoint", "group": "security", "label": "producer,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth2 Token endpoint" },
"sslContextParameters": { "index": 56, "kind": "parameter", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need." },
"x509HostnameVerifier": { "index": 57, "kind": "parameter", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier" }
}
}
Loading

0 comments on commit 1c53621

Please sign in to comment.