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

INTERNAL: Add ScramSaslClient #869

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

INTERNAL: Add ScramSaslClient #869

wants to merge 1 commit into from

Conversation

namsic
Copy link
Collaborator

@namsic namsic commented Jan 10, 2025

๐Ÿ”— Related Issue

  • jam2in/arcus-works#672

โŒจ๏ธ What I did

  • Scram ์ธ์ฆ์„ ์œ„ํ•œ ScramSaslClient๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
  • com.bolyartech.scram_sasl ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
  • Kafka์˜ ScramSaslClient ๊ตฌํ˜„์„ ์ฐธ๊ณ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ๊ธฐ์กด java client์˜ ์ฝ”๋“œ ๋ฐฐ์น˜๋‚˜ ์Šคํƒ€์ผ๊ณผ ์ฐจ์ด๊ฐ€ ์žˆ๋Š”์ง€๋„ ํ™•์ธํ•ด ์ฃผ์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

  • ๋Œ€๋žต ์•„๋ž˜์™€ ๊ฐ™์€ ๊ตฌํ˜„์œผ๋กœ SCRAM ์ธ์ฆ ์‚ฌ์šฉํ•˜์—ฌ ์บ์‹œ ์„œ๋ฒ„์™€ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ScramSaslClientProvider.initialize(); ํ˜ธ์ถœํ•œ ๋‹ค์Œ๋ถ€ํ„ฐ SCRAM-SHA-256 mechanism ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋Š”๋ฐ,
    ์–ด๋Š ์œ„์น˜์— ๋‘๋Š” ๊ฒƒ์ด ์ข‹์€์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ, ์šฐ์„ ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์™ธ๋ถ€์—์„œ ์ง์ ‘ ํ˜ธ์ถœํ•˜๋Š” ํ˜•ํƒœ๋กœ ํ…Œ์ŠคํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.
  private static final String[] mechanism = {"SCRAM-SHA-256"};
  private static final String username = "user01";
  private static final String password = "passwd01";

  private ArcusClient newClient(boolean useCluster, boolean useBinaryProtocol) throws IOException {
    ConnectionFactoryBuilder cfb = new ConnectionFactoryBuilder()
        .setAuthDescriptor(new AuthDescriptor(mechanism, 
        new PlainCallbackHandler(username, password)));
    
    if (useBinaryProtocol) {
      cfb.setProtocol(Protocol.BINARY);
    }

    if (useCluster) {
      return ArcusClient.createArcusClient("127.0.0.1:2181", "servicecode-01", cfb);
    } else {
      return new ArcusClient(cfb.build(), AddrUtil.getAddresses("127.0.0.1:11211"));
    }

  }

  @Test
  public void testSasl() throws Exception {
    ScramSaslClientProvider.initialize();

    ArcusClient mc = newClient(true, true);
    Thread.sleep(10000);

    assertTrue(mc.set("namsic:kv01", 30, "value01").get());
    assertEquals("value01", mc.get("namsic:kv01"));
  }

์ด PR์ด ๋ฐ˜์˜๋˜๋Š” ์‹œ์ ๋ถ€ํ„ฐ binary protocol ์‚ฌ์šฉ ์‹œ SCRAM-SHA-256 ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
ascii protocol์—์„œ SASL ์ธ์ฆ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๊ด€๋ จ operation์„ ๊ตฌํ˜„ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

public SASLStepOperation saslStep(SaslClient sc, byte[] challenge, OperationCallback cb) {
throw new UnsupportedOperationException();
}
public SASLAuthOperation saslAuth(SaslClient sc, OperationCallback cb) {
throw new UnsupportedOperationException();
}

@namsic namsic requested review from uhm0311 and oliviarla January 10, 2025 05:59
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.

1 participant