-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][auth] Generate correct well-known OpenID configuration URL #15928
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
[fix][auth] Generate correct well-known OpenID configuration URL #15928
Conversation
michaeljmarshall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LTGM
BewareMyPower
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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`.
|
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); |
) (cherry picked from commit 304b03e)
) (cherry picked from commit 304b03e)
…che#15928) (cherry picked from commit 304b03e) (cherry picked from commit 3dc5f1e)
) (cherry picked from commit 304b03e)
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)