-
Notifications
You must be signed in to change notification settings - Fork 49
ENHANCE: Support binary protocol authentication #995
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
Conversation
jhpark816
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.
๋ฆฌ๋ทฐ ์๋ฃ
| complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line))); | ||
| throw new AuthException(line); | ||
| } | ||
| resetInput(); |
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.
resetInput() ํธ์ถ์ด ํ์ํ ์ด์ ๋ฅผ ๊ฐ๋จํ ์ค๋ช ํด ์ฃผ์ธ์.
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.
resetInput()์ ์๋ ์ฉ๋๋ ํ ๋ฒ์ ๋ชจ๋ ํจํท์ ์ฝ์ง ์๋ ์ฐ์ฐ, ์์๋ก๋ mget ์ฐ์ฐ์ ์๋ต์ ์ฝ๊ธฐ ์ํด ํธ์ถํ๋ ์ฉ๋์
๋๋ค.
mget๊ณผ ๊ฐ์ ์ฐ์ฐ์ ์๋ต์ <header><body> ํํ์ ํจํท์ด N๊ฐ๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
์ด๋ฌํ ์๋ต์ ์ฝ์ ๋์๋ 24 ๋ฐ์ดํธ ๊ธธ์ด์ header๋ฅผ ๋จผ์ ์ฝ๊ณ , header์ ๋ช
์๋ body ๊ธธ์ด๋งํผ ์ฝ์ ํ์๋ ๊ทธ ๋ค์ 24 ๋ฐ์ดํธ ๊ธธ์ด์ header๋ฅผ ์ฝ๋ ๊ณผ์ ์ผ๋ก ๋์๊ฐ๋๋ค.
์ด ๋ resetInput()์ ํธ์ถํด์ฃผ๋ฉด ๊ธฐ์กด์ ํจํท์ ์ฝ์๋ ์ ๋ณด๋ฅผ ๋ฒ๋ฆฌ๋ ์ญํ ์ ํฉ๋๋ค.
Ascii ์ปค๋งจ๋๋ก ๋น์ ํ๋ฉด, handleLine()๊ณผ handleRead()๋ฅผ ๋ฒ๊ฐ์๊ฐ๋ฉฐ ํธ์ถํ์ฌ mget ์๋ต์ ์ฝ๊ธฐ ์ํด setReadType()์ ํธ์ถํ๋ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค.
์์ ๊ฐ์ resetInput()์ ๊ตฌํ๊ณผ ์ฉ๋๋ฅผ ๊ณ ๋ คํ๋ฉด auth ์ฐ์ฐ์์๋ ํธ์ถํ ํ์๋ ์์ง๋ง, ๋ค๋ฅธ ์ฐ์ฐ์ ์ค๋ฒ๋ก๋๋ finishedPayload() ๋ฉ์๋์์ ํธ์ถ๋๋ ๊ฒ์ ๊ทธ๋๋ก ์ฌ์ฉํ์ต๋๋ค.
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.
resetInput() ํธ์ถ์ ์ ๊ฑฐํฉ์๋ค.
์ค๋ฒ๋ก๋๋ decodePayload() ๋ฉ์๋๋ฅผ ๊ฐ์ง๋ค๊ณ resetInput() ํธ์ถํ๋ ๊ฒ์ด ์๋๊ธฐ ๋๋ฌธ์
๋๋ค.
์ฐธ๊ณ ๋ก, ๋ค๋ฅธ ์ฐ์ฐ์์๋ ์๋ ๋ฉ์๋๋ฅผ overrideํ์ฌ ์๋ต ์ฒ๋ฆฌ๋ฅผ ๊ตฌํํ์์ต๋๋ค.
- getStatusForErrorCode()
- decodePayload()
auth ์ฒ๋ฆฌ์์๋ ๊ธฐ์กด ํ์ ๋ฐ๋ผ ์์ ๋ฉ์๋๋ฅผ overrideํ์ฌ ๊ตฌํํ๋ฉด ์ข๊ฒ ์ง๋ง,
๊ทธ๊ฒ ์ ๋ง์ง ์์์, finishedPayload ๋ฉ์๋๋ฅผ overriderํ ๊ฒ์ผ๋ก ์๊ฐํ์ต๋๋ค.
| if (isInternal) { | ||
| throw new AuthException(line); | ||
| } | ||
| } |
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.
์ถ๊ฐ ์ฝ๋ฉํธ์
๋๋ค.
SASLBaseOperation๊ณผ ์ผ๊ด๋๊ฒ ๊ตฌํ ํ๋ค๋ฉด, ์๋์ ๊ฐ์์ผ ํ์ง ์๋ ์ง?
} else if (isInternal && errorCode == UNKNOWN_COMMAND) {
complete(SASL_NOT_SUPPORTED);
} else {
String line = new String(pl);
complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line)));
throw new AuthException(line);
}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.
SASLBaseOperation์ ์ฒ๋ฆฌ๋ ์๋ฐํ ๋ฐ์ง๋ฉด Ascii ํ๋กํ ์ฝ์ ๋์์ ๊ทธ๋๋ก ๊ฐ์ ธ์ฌ ์ ์์๋ ๋ถ๋ถ์ ๋๋ค.
Ascii ํ๋กํ ์ฝ์ ๊ฒฝ์ฐ handleLine() ํธ์ถ๊ณผ handleError() ํธ์ถ์ CLIENT_ERROR | SERVER_ERROR | ERROR ์ ๋์ฌ๋ฅผ ๊ฐ๊ณ ์๋์ง ์ฌ๋ถ์ ๋ฐ๋ผ ๋ถ๊ธฐ๊ฐ ๋ฉ๋๋ค.
์ฆ, handleLine() ๋ด์์๋ ์ ๋๋ก CLIENT_ERROR | SERVER_ERROR | ERROR ์ ๋์ฌ๊ฐ ๋ถ์ง ์๋๋ค๋ ์ ์ด ๋ณด์ฅ๋ฉ๋๋ค.
๋ฐ๋๋ก handleError() ๋ด์์๋ ํญ์ CLIENT_ERROR | SERVER_ERROR | ERROR ์ ๋์ฌ๊ฐ ๋ถ๋๋ค๋ ์ ์ด ๋ณด์ฅ๋ฉ๋๋ค.
Binary ํ๋กํ ์ฝ์์๋ ์์ ๊ฐ์ด ์๋ฌ์ธ์ง ์๋์ง ๊ตฌ๋ถ์ ์๊ณ , finishedPayload() ๋ฉ์๋๊ฐ ํธ์ถ๋ฉ๋๋ค.
๋ฐ๋ผ์ finishedPayload() ๋ฉ์๋๋ฅผ ์ค๋ฒ๋ผ์ด๋ํ๊ฒ ๋๋ค๋ฉด, finishedPayload() ๋ฉ์๋์์ Ascii์ handleLine()์ ํด๋นํ๋ ๋ก์ง๊ณผ handleError()์ ํด๋นํ๋ ๋ก์ง์ ๋ชจ๋ ๋ฃ์ด์ผ ํฉ๋๋ค.
SASLBaseOperation์ ๊ฒฝ์ฐ handleError() ์ฒ๋ฆฌ๋ฅผ ํ๊ธฐ ์ํด์๋ CLIENT_ERROR | SERVER_ERROR | ERROR๋ก ๋ถ๋ฅ๋๋ ๋ชจ๋ ์๋ฌ ์ฝ๋์ ํด๋นํ๋ ๊ฒฝ์ฐ์ ๋ํ ๋ถ๊ธฐ ์ฒ๋ฆฌ๋ฅผ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค.
SASLMechsOperation์ ๊ฒฝ์ฐ unknown command ์๋ฌ์ ํํ์ฌ Ascii ํ๋กํ ์ฝ๊ณผ ๋์ผํ ๋์์ ํ๋๋ก ํ์์ผ๋ฉฐ, ๊ทธ ์ธ์ CLIENT_ERROR | SERVER_ERROR | ERROR๋ก ๋ถ๋ฅ๋๋ ๋ชจ๋ ์๋ฌ ์ฝ๋๋ AuthException์ ์ ํ์ํค๊ฒ ๋ฉ๋๋ค.
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.
์ง๋ ๋ฒ์ ์๊ธฐํ ๋๋ก,
Ascii Protocol์์ CLIENT_ERROR | SERVER_ERROR | ERROR ์ค๋ฅ์ผ ๊ฒฝ์ฐ
ํ์ฌ ์ฐ๊ฒฐ์ ๋จ์ garbage data๋ฅผ ์ ๊ฑฐํ๊ธฐ ์ํด immediate reconnect ํฉ๋๋ค.
Binary Protocol์ ๋ค๋ฆ
๋๋ค.
Binary์์๋ ์์ํ์ง ์์ ์๋ต์ด ์ฌ ๊ฒฝ์ฐ SERVER_ERROR ์ค๋ฅ๋ก ์ฒ๋ฆฌํ๋ ๋ฐ์.
๊ทธ ์ด์ ๋ฅผ ์ฝ๋๋ฅผ ํตํด ํ์ธํด ๋ณด๋ฉด ์ข๊ฒ ์ง๋ง,
ํ์ธํด ๋ณด์ง ์์ ์ํ๋ผ๋ฉด ๊ธฐ์กด ์ฝ๋๋ฅผ ๊ทธ๋๋ก ์ ์งํ์๊ณ ํ์ต๋๋ค.
sasl mech ์ฐ์ฐ์ด ์ธ๋ถ์์ ์์ฒญ๋ ์ ์์ผ๋ฏ๋ก,
internal ๊ฒฝ์ฐ๊ฐ ์๋๋ฉด, ์๋์ ๊ฐ์ด ๊ธฐ์กด ์ฝ๋๋ฅผ ์ ์งํ๋ ๊ฒ์ด ๋์ ๊ฒ ๊ฐ์ต๋๋ค.
} else if (isInternal) {
if (errorCode == UNKNOWN_COMMAND) {
complete(SASL_NOT_SUPPORTED);
} else {
String line = new String(pl);
complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line)));
throw new AuthException(line);
}
} else {
super.finishedPayload(pl);
}
๐ Related Issue
โจ๏ธ What I did
sasl mech๋ช ๋ น์ด์ handleError() ๋ก์ง์ finishedPayload() ๋ฉ์๋์ ํฌํจํฉ๋๋ค.