-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
宋裕 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 { | |||
|
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.
Do not change the indent .
Please use nacos code style to reformat code.
detail see soruce code style/CodeStyle.md
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.
sorry
I have modified and re-uploaded
@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. |
I send mail to opensource@alibaba-inc.com today |
No need to send email. I found you submit commit with user I suggest that you change the git username and email. Then re-commit your change with |
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.
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)) { |
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.
What does it do when password = ""?
If my password is empty string, the params will be skipped
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.
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
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.
···
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.
Thank you for your patience, is it all right now |
@syapollo The
Not yet.
The next thing need to do is to remove the old commit of 宋裕. And have a look the newest review comment. |
@syapollo I have other suggestions . You can close this PR and re-checkout one branch from Then commit with |
@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. |
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:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.