[fix][auth] Generate correct well-known OpenID configuration URL - #15928
Merged
codelipenghui merged 3 commits intoJun 7, 2022
Merged
Conversation
gaoran10
requested review from
BewareMyPower,
codelipenghui,
congbobo184,
hangc0276,
merlimat,
tuteng,
wolfstudy and
zymap
June 4, 2022 04:07
BewareMyPower
requested changes
Jun 4, 2022
BewareMyPower
left a comment
Contributor
There was a problem hiding this comment.
In C++, returning a const object is meaningless. I think you want to make the method const to ensure the internal state doesn't change in the implementation.
…the method `ClientCredentialFlow::initialize`.
BewareMyPower
approved these changes
Jun 6, 2022
Contributor
|
Please apply the following patch to fix the code format. diff --git a/pulsar-client-cpp/lib/auth/AuthOauth2.cc b/pulsar-client-cpp/lib/auth/AuthOauth2.cc
index 4bc5e8c814b2..c7f944da75b1 100644
--- a/pulsar-client-cpp/lib/auth/AuthOauth2.cc
+++ b/pulsar-client-cpp/lib/auth/AuthOauth2.cc
@@ -143,9 +143,7 @@ ClientCredentialFlow::ClientCredentialFlow(ParamMap& params)
audience_(params["audience"]),
scope_(params["scope"]) {}
-std::string ClientCredentialFlow::getTokenEndPoint() const {
- return tokenEndPoint_;
-}
+std::string ClientCredentialFlow::getTokenEndPoint() const { return tokenEndPoint_; }
static size_t curlWriteCallback(void* contents, size_t size, size_t nmemb, void* responseDataPtr) {
((std::string*)responseDataPtr)->append((char*)contents, size * nmemb);
@@ -177,7 +175,7 @@ void ClientCredentialFlow::initialize() {
wellKnownUrl.pop_back();
}
wellKnownUrl.append("/.well-known/openid-configuration");
- curl_easy_setopt(handle, CURLOPT_URL,wellKnownUrl.c_str());
+ curl_easy_setopt(handle, CURLOPT_URL, wellKnownUrl.c_str());
// Write callback
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback); |
codelipenghui
pushed a commit
that referenced
this pull request
Jun 10, 2022
) (cherry picked from commit 304b03e)
codelipenghui
pushed a commit
that referenced
this pull request
Jun 12, 2022
) (cherry picked from commit 304b03e)
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jun 13, 2022
…che#15928) (cherry picked from commit 304b03e) (cherry picked from commit 3dc5f1e)
BewareMyPower
pushed a commit
that referenced
this pull request
Jul 27, 2022
) (cherry picked from commit 304b03e)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, the well-known OpenID configuration URL generated by issuer_url and suffix (/.well-known/openid-configuration), if the issurer_url end with a slash, the well-known OpenID configuration URL will be not correct.
Demo
Making the issuer_url as below could work well.
Modifications
Trim the slash if the issuer_url end with a slash.
Verifying this change
Add a unit test to verify the method
ClientCredentialFlow::initialize.Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation
Check the box below or label this PR directly.
Need to update docs?
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)