Skip to content

Support the base64 encoded credentials for OAuth2 authentication #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

BewareMyPower
Copy link
Contributor

Fixes apache/pulsar-client-python#101

Motivation

Currently the private_key field of the JSON passed to AuthOauth2 only represents the path to the file, we need to support passing the base64 encoded JSON string.

Modifications

  • Add the util methods encode and decode in namespace pulsar::base64 for base64 serialization.
  • Support the following URL representations for private_key:
    1. file:///path/to/key/file
    2. data:application/json;base64,xxxx
  • Add Oauth2Test and set up the test environment for it independently with a Docker compose file.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@BewareMyPower BewareMyPower self-assigned this Apr 13, 2023
@BewareMyPower BewareMyPower added this to the 3.2.0 milestone Apr 13, 2023
@BewareMyPower BewareMyPower added the enhancement New feature or request label Apr 13, 2023
@BewareMyPower BewareMyPower marked this pull request as draft April 13, 2023 09:44
@BewareMyPower BewareMyPower force-pushed the bewaremypower/oauth-url branch from 0e78632 to 3a8c6ba Compare April 13, 2023 11:14
@BewareMyPower BewareMyPower marked this pull request as ready for review April 13, 2023 11:14
@BewareMyPower BewareMyPower force-pushed the bewaremypower/oauth-url branch from 3a8c6ba to 17c4d25 Compare April 14, 2023 07:54
@shibd
Copy link
Member

shibd commented Apr 14, 2023

Support the following URL representations for private_key:

  • file:///path/to/key/file
  • data:application/json;base64,xxxx

Nothing to do with this PR. Do we support this format?

image

@BewareMyPower
Copy link
Contributor Author

@shibd You're right. I think we need to support this format.

@shibd
Copy link
Member

shibd commented Apr 14, 2023

@shibd You're right. I think we need to support this format.

It seems simple, can you include it in this PR?

@BewareMyPower BewareMyPower marked this pull request as draft April 14, 2023 10:46
@BewareMyPower
Copy link
Contributor Author

@shibd Thanks for your suggestions. I'm working on simplifying all test scripts into the run-unit-tests.sh currently. It would also support configuring CMAKE_BUILD_DIRECTORY if the cmake build directory is not the project root directory.

Fixes apache/pulsar-client-python#101

### Motivation

Currently the `private_key` field of the JSON passed to `AuthOauth2`
only represents the path to the file, we need to support passing the
base64 encoded JSON string.

### Modifications

- Add the util methods `encode` and `decode` in namespace
  `pulsar::base64` for base64 serialization. Then add `Base64Test.cc`
  for it.
- Support the following URL representations for `private_key`:
  1. `file:///path/to/key/file`
  2. `data:application/json;base64,xxxx`
- Add `Oauth2Test` and set up the test environment for it independently
  with a Docker compose file.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/oauth-url branch from 2d9ddde to 8f03fa5 Compare April 14, 2023 16:26
@BewareMyPower BewareMyPower marked this pull request as ready for review April 14, 2023 16:29
@BewareMyPower BewareMyPower merged commit d2cfabd into apache:main Apr 17, 2023
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this pull request May 23, 2023
### Modifications

Add tests to verify the changes of
apache/pulsar-client-cpp#249 work for the Python
client.

Add docs to describe valid JSON fields used to create an
`AuthenticationOauth2` instance.
merlimat pushed a commit to apache/pulsar-client-python that referenced this pull request May 23, 2023
### Modifications

Add tests to verify the changes of
apache/pulsar-client-cpp#249 work for the Python
client.

Add docs to describe valid JSON fields used to create an
`AuthenticationOauth2` instance.
@BewareMyPower BewareMyPower deleted the bewaremypower/oauth-url branch May 30, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] OAuth key file base64 support
2 participants