Skip to content
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

[ISSUE #3621 Fix Passwords containing special characters are not supported (such as character "+") #3656

Closed
wants to merge 3 commits into from

Conversation

syapollo
Copy link
Contributor

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

for #3621

Brief changelog

encode the passowrd and password can not be null

Verifying this change

I simulated some special characters and they can pass normally

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@CLAassistant
Copy link

CLAassistant commented Aug 21, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ syapollo
❌ 宋裕


宋裕 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -41,45 +43,45 @@
* @since 1.2.0
*/
public class SecurityProxy {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change the indent .
Please use nacos code style to reformat code.

detail see soruce code style/CodeStyle.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry
I have modified and re-uploaded

@KomachiSion
Copy link
Collaborator

KomachiSion commented Aug 21, 2020

@syapollo Please check your commit author is your github id.

Otherwise the CLA can't pass.

You can search how to change the username and email of git by search engine.

@syapollo
Copy link
Contributor Author

@syapollo Please check your commit author is your github id.

Otherwise the CLA will can't pass.

You can search how to change the username and email of git by search engine.

I send mail to opensource@alibaba-inc.com today

@KomachiSion
Copy link
Collaborator

@syapollo Please check your commit author is your github id.
Otherwise the CLA will can't pass.
You can search how to change the username and email of git by search engine.

I send mail to opensource@alibaba-inc.com today

No need to send email.

I found you submit commit with user 宋裕 and your github id is syapollo
So github can't link this user rightly.

I suggest that you change the git username and email. Then re-commit your change with syapollo. In this case, you can click CLA link Contributor License Agreement and sign CLA directly.

Copy link
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CLA of @syapollo is ok. The next think need to do is to remove the old commit of 宋裕.

Thanks.


if (StringUtils.isNotBlank(username)) {
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it do when password = ""?

If my password is empty string, the params will be skipped

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For security reasons, I think there is a username parameter in the actual scenario, so there should be no empty password
In another case, if there is no username parameter, there is no need to configure a password

Copy link
Contributor Author

@syapollo syapollo Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

···
public boolean login(String server) throws UnsupportedEncodingException {
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
Map<String, String> params = new HashMap<String, String>(2);
Map<String, String> bodyMap = new HashMap<String, String>(2);
params.put("username", username);
bodyMap.put("password", URLEncoder.encode(password, "utf-8"));
String url = "http://" + server + contextPath + LOGIN_URL;
if (server.contains(Constants.HTTP_PREFIX)) {
url = server + contextPath + LOGIN_URL;
}
try {
HttpRestResult restResult = nacosRestTemplate
.postForm(url, Header.EMPTY, Query.newInstance().initParams(params), bodyMap, String.class);
if (!restResult.ok()) {
SECURITY_LOGGER.error("login failed: {}", JacksonUtils.toJson(restResult));
return false;
}
JsonNode obj = JacksonUtils.toObj(restResult.getData());
if (obj.has(Constants.ACCESS_TOKEN)) {
accessToken = obj.get(Constants.ACCESS_TOKEN).asText();
tokenTtl = obj.get(Constants.TOKEN_TTL).asInt();
tokenRefreshWindow = tokenTtl / 10;
}
} catch (Exception e) {
SECURITY_LOGGER.error("[SecurityProxy] login http request failed"
+ " url: {}, params: {}, bodyMap: {}, errorMsg: {}", url, params, bodyMap, e.getMessage());
return false;
}
}
return true;
}

···

Why does this function return true at the end, is this a bug?

I actually tested it. Without configuring the user password parameter, I skipped the authentication, but succeeded.

@syapollo
Copy link
Contributor Author

@syapollo Please check your commit author is your github id.
Otherwise the CLA will can't pass.
You can search how to change the username and email of git by search engine.

I send mail to opensource@alibaba-inc.com today

No need to send email.

I found you submit commit with user 宋裕 and your github id is syapollo
So github can't link this user rightly.

I suggest that you change the git username and email. Then re-commit your change with syapollo. In this case, you can click CLA link Contributor License Agreement and sign CLA directly.

Thank you for your patience, is it all right now

@KomachiSion
Copy link
Collaborator

KomachiSion commented Aug 21, 2020

@syapollo The syapollo user's CLA has been ok. And the implementation

@syapollo Please check your commit author is your github id.
Otherwise the CLA will can't pass.
You can search how to change the username and email of git by search engine.

I send mail to opensource@alibaba-inc.com today

No need to send email.
I found you submit commit with user 宋裕 and your github id is syapollo
So github can't link this user rightly.
I suggest that you change the git username and email. Then re-commit your change with syapollo. In this case, you can click CLA link Contributor License Agreement and sign CLA directly.

Thank you for your patience, is it all right now

Not yet.

✅ syapollo
❌ 宋裕

The next thing need to do is to remove the old commit of 宋裕.

And have a look the newest review comment.

@KomachiSion
Copy link
Collaborator

@syapollo I have other suggestions . You can close this PR and re-checkout one branch from develop branch. And do these change in new branch.

Then commit with syapollo and submit by new PR.

@syapollo
Copy link
Contributor Author

@syapollo I have other suggestions . You can close this PR and re-checkout one branch from develop branch. And do these change in new branch.

Then commit with syapollo and submit by new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants