-
Notifications
You must be signed in to change notification settings - Fork 47
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
INTERNAL: Add ScramSaslClient #869
base: develop
Are you sure you want to change the base?
Conversation
|
||
private final ScramMechanism mechanism; | ||
private final CallbackHandler callbackHandler; | ||
private final ScramClientFunctionalityImpl scfi; |
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.
ํ๋๊ฐ ์ ์ธ๋ ํ์ ์ด ScramClientFunctionalityImpl์ธ ์ํ์ธ๋ฐ, ์ ์ธ ํ์ ์ผ๋ก ScramClientFunctionality๋ฅผ ์ฌ์ฉํ๋ฉด ๊ตฌํ์ ๋ฌธ์ ๊ฐ ์๋์?
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.
ScramClientFunctionality
์ฌ์ฉํ๋๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
๊ทธ ์ธ์๋ Java์ ์ผ๋ฐ์ ์ธ ๊ตฌํ ํจํด๊ณผ ๊ด๋ จํ์ฌ ๋ฌธ์ ๊ฐ ์๋ ๋ถ๋ถ์ ์๋์ง ์ ๊ฒฝ์จ์ ํ์ธํด ์ฃผ์๋ฉด ์ข๊ฒ ์ต๋๋ค.
- class ์์น(package)๋ ์ ์ ํ์ง
- ๋ฉค๋ฒ ๋ณ์์
this.
๋ฅผ ๋ถ์ด๋ ๊ฒฝ์ฐ / ์๋ตํ๋ ๊ฒฝ์ฐ - ๊ธฐํ ์ ๋ฐ์ ์ธ ์ฝ๋ ๊ตฌ์กฐ ๋ฐ ์ฝ๋ ํฌ๋งท
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.
์ฝ๋ ์คํ์ผ์ @jhpark816 ๋์ด ๋ด์ฃผ์ค ๊ฒ๋๋ค.
byte[] clientFinalMessage = this.scfi.prepareFinalMessage( | ||
password, serverFirstMessage).getBytes(); |
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.
serverNonce์ ๊ฒ์ฆ ๋ถ๋ถ๋ ScramClientFunctionalityImpl ๊ฐ์ฒด๊ฐ ์์์ ์งํํด์ฃผ๋์?
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.
kafka์ ์๋ ๊ตฌํ์ ๋์ํ๋ ๋ก์ง์ด ์๋์ง๋ฅผ ํ์ธํ๋ ๊ฒ์ด์ง์?
case RECEIVE_SERVER_FIRST_MESSAGE:
this.serverFirstMessage = new ServerFirstMessage(challenge);
if (!serverFirstMessage.nonce().startsWith(clientNonce))
throw new SaslException("Invalid server nonce: does not start with client nonce");
์๋์ ๊ฐ์ด ์ฒ๋ฆฌ๋ฉ๋๋ค.
https://github.com/ogrebgr/scram-sasl/blob/5f3d1cbf71e534170c9f28fcee7fa8ec6bf77291/lib/src/main/java/com/bolyartech/scram_sasl/client/ScramClientFunctionalityImpl.java#L118
Matcher m = SERVER_FIRST_MESSAGE.matcher(serverFirstMessage);
if (!m.matches()) {
mState = State.ENDED;
return null;
}
String nonce = m.group(1);
if (!nonce.startsWith(mClientNonce)) {
mState = State.ENDED;
return null;
}
์์ธ๋ฅผ ๋์ง์ง ์๊ณ internal state ๋ณ๊ฒฝ ํ null ๋ฐํํ๋๋ก ๋์ด ์๋๋ฐ,
ํธ์ถํ๋ ์ธก์์ null check ํ ์์ธ ๋์ง๋๋ก ๋ณ๊ฒฝํด์ผ ํ๋์ง๋ ํ์ธ์ด ํ์ํด ๋ณด์
๋๋ค.
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.
ํธ์ถํ๋ ์ธก์์ null check ํ ์์ธ ๋์ง๋๋ก ๋ณ๊ฒฝํด์ผ ํ๋์ง๋ ํ์ธ์ด ํ์ํด ๋ณด์ ๋๋ค.
ํ์ธํด๋ณด๊ณ ์๋ ค์ฃผ์๋ฉด ๋ฆฌ๋ทฐ ๊ณ์ ์งํํ๊ฒ ์ต๋๋ค.
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.
null check ๋ฐ ์์ธ ๋ฐ์์ํค์ง ์๊ณ ์งํํ๋ฉด, ์๋ฒ์ sasl ๋ช
๋ น์ empty body์ ํจ๊ป ์ ์กํฉ๋๋ค.
๊ทธ๋ฌ๋ฉด ์๋ฒ ์
์ฅ์์๋ ํด๋ผ์ด์ธํธ๊ฐ ์ฌ๋ฐ๋ฅธ ๋ฐ์ดํฐ๋ฅผ ์๋ตํ์ง ์์ ๊ฒ์ด๋ฏ๋ก ์ธ์ฆ ์คํจ ์ฒ๋ฆฌํฉ๋๋ค.
์์ธ ๋ฐ์์ํค๋ฉด Operation์ initialize()์์ RuntimeException ๋ฐ์ํ๊ฒ ๋๋๋ฐ,
์์ธ ๋ฐ์ ์ดํ ๊ตฌ์ฒด์ ์ผ๋ก ์ด๋ป๊ฒ ๋์ํ๊ฒ ๋๋์ง๊น์ง๋ ์ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์๋ฒ์ ์์ฒญ์ ์ ์กํ์ง ์์ ๊ฒ์
๋๋ค.
@Override
public void initialize() {
try {
byte[] response = buildResponse(sc);
String mechanism = sc.getMechanismName();
prepareBuffer(mechanism, 0, response);
} catch (SaslException e) {
// XXX: Probably something saner can be done here.
throw new RuntimeException("Can't make SASL go.", e);
}
}
๊ฒฐ๊ตญ์๋ ๋ ๋ชจ๋ ์ธ์ฆ ๊ณผ์ ์ด ์ข ๋ฃ๋๋ ๊ฒ์ ๋์ผํ๋ฉฐ, ํ์์ ๋์์ด ๋ ๋ง๋ ๊ฒ ๊ฐ์์ ์์ธ ๋์ง๋๋ก ๋ณ๊ฒฝํฉ๋๋ค.
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.
develop ๋ธ๋์น ์ต์ ๊ธฐ์ค์ผ๋ก Operation.initialize()๋ ํฌ๊ฒ 3๊ตฐ๋ฐ์์ ๋ถ๋ฆฝ๋๋ค.
- ์์ฉ์ Worker Thread
- ์๋ฐ ํด๋ผ์ด์ธํธ์ IO Thread
- ์๋ฐ ํด๋ผ์ด์ธํธ์ Auth Thread
1๋ฒ์ ์์ฉ์ ์ํฌ๋ก๋์ ๋ฐ๋ผ ๋ค๋ฅด๋ฏ๋ก ๋์ด๊ฐ๊ฒ ์ต๋๋ค.
2๋ฒ์ IO Thread๊ฐ ์ ์ง๋๊ณ , ์๋ฌด๋ฐ ์ฐ์ฐ ์์ฒญ๋ ๋ณด๋ด์ง ๋ชปํด์ ๋ชจ๋ ์บ์ ์ฐ์ฐ์ด Timeout ์ฒ๋ฆฌ๋ ๊ฒ ๊ฐ์ต๋๋ค.
3๋ฒ์ ์ด๋ค ์ํฅ์ด ์์์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
@oliviarla 2๋ฒ์ ์ํฅ์ ๋ํ ์ ์ค๋ช
์ด ๋ง๋์ง ํ์ธํด์ฃผ์๊ณ , Exception์ ์ ํํ๋ ๊ฒ๊ณผ ํ์ง ์๋ ๊ฒ ์ค ๋ฌด์์ด ์ข์์ง ๊ฒํ ํด์ฃผ์ธ์.
@namsic 3๋ฒ์ ์ํฅ์ด ์ด๋ค์ง ์ค๋ช
ํด์ฃผ์ธ์.
47e972f
to
94a7e87
Compare
94a7e87
to
ae75385
Compare
๐ Related Issue
โจ๏ธ What I did
ScramSaslClientProvider.initialize();
ํธ์ถํ ๋ค์๋ถํฐ SCRAM-SHA-256 mechanism ์ฌ์ฉํ ์ ์๊ฒ ๋๋๋ฐ,์ด๋ ์์น์ ๋๋ ๊ฒ์ด ์ข์์ง ์ ๋ชจ๋ฅด๊ฒ ์ด์, ์ฐ์ ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ธ๋ถ์์ ์ง์ ํธ์ถํ๋ ํํ๋ก ํ ์คํธํ์ต๋๋ค.
์ด PR์ด ๋ฐ์๋๋ ์์ ๋ถํฐ binary protocol ์ฌ์ฉ ์
SCRAM-SHA-256
์ฌ์ฉํ ์ ์๊ฒ ๋ฉ๋๋ค.ascii protocol์์ SASL ์ธ์ฆ ์ฌ์ฉํ๋ ค๋ฉด ๊ด๋ จ operation์ ๊ตฌํํด์ผ ํฉ๋๋ค.
arcus-java-client/src/main/java/net/spy/memcached/protocol/ascii/AsciiOperationFactory.java
Lines 149 to 155 in 5c13575