Skip to content

Commit 3ea3ff1

Browse files
authored
[improve][client] Implement tls_client_auth for AuthOauth2 (#575)
1 parent 7d1002a commit 3ea3ff1

4 files changed

Lines changed: 673 additions & 111 deletions

File tree

include/pulsar/Authentication.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,22 @@ typedef std::shared_ptr<CachedToken> CachedTokenPtr;
515515
* Passed in parameter would be like:
516516
* ```
517517
* "type": "client_credentials",
518+
* "tokenEndpointAuthMethod": "client_secret_post",
518519
* "issuer_url": "https://accounts.google.com",
519520
* "client_id": "d9ZyX97q1ef8Cr81WHVC4hFQ64vSlDK3",
520521
* "client_secret": "on1uJ...k6F6R",
521522
* "audience": "https://broker.example.com"
522523
* ```
524+
*
525+
* For `tokenEndpointAuthMethod = "tls_client_auth"`:
526+
* ```
527+
* "type": "client_credentials",
528+
* "tokenEndpointAuthMethod": "tls_client_auth",
529+
* "issuer_url": "https://accounts.google.com",
530+
* "client_id": "d9ZyX97q1ef8Cr81WHVC4hFQ64vSlDK3",
531+
* "tls_cert_file": "/path/to/cert.pem",
532+
* "tls_key_file": "/path/to/key.pem"
533+
* ```
523534
* If passed in as std::string, it should be in Json format.
524535
*/
525536
class PULSAR_PUBLIC AuthOauth2 : public Authentication {
@@ -530,7 +541,14 @@ class PULSAR_PUBLIC AuthOauth2 : public Authentication {
530541
/**
531542
* Create an AuthOauth2 with a ParamMap
532543
*
533-
* The required parameter keys are “issuer_url”, “private_key”, and “audience”
544+
* For `tokenEndpointAuthMethod = "client_secret_post"` (default), the required parameter
545+
* keys are “issuer_url”, “private_key”, and “audience”.
546+
* Optional keys: `scope`, `tls_cert_file`, `tls_key_file`.
547+
*
548+
* For `tokenEndpointAuthMethod = "tls_client_auth"`, the required parameter keys are
549+
* `issuer_url`, `tls_cert_file`, and `tls_key_file`.
550+
* Optional keys: `client_id`, `audience`, `scope`. If `client_id` is omitted, the client
551+
* uses `pulsar-client`.
534552
*
535553
* @param parameters the key-value to create OAuth 2.0 client credentials
536554
* @see http://pulsar.apache.org/docs/en/security-oauth2/#client-credentials

0 commit comments

Comments
 (0)