Azure AMQP Service Bus CBS 인증

· 기능

sgcWebSockets 2026.1.0부터 Azure AMQP 1.0이 SAS 토큰과 JWT를 사용한 CBS 인증을 지원해요.

Azure Service Bus는 초기 SASL 핸드셰이크 후 발신자와 수신자를 인증하기 위해 AMQP를 통해 CBS(Claims-Based Security)를 구현해요. 클라이언트가 $cbs 노드에 관리 링크를 열고 Shared Access Signature(SAS) 토큰이나 Microsoft Entra ID에서 발급한 JSON Web Token(JWT)이 포함된 put-token 요청을 보내요. 브로커가 토큰을 검증하면 인증이 토큰의 수명 동안 캐시되어 애플리케이션이 큐, 토픽, 구독에 대해 발신자와 수신자 링크를 생성할 수 있어요.


Azure CBS 작동 방식

Azure Service Bus는 초기 SASL 핸드셰이크 후 발신자와 수신자를 인증하기 위해 AMQP를 통해 CBS를 구현해요. 클라이언트가 $cbs 노드에 관리 링크를 열고 SAS 토큰이나 Microsoft Entra ID에서 발급한 JWT가 포함된 put-token 요청을 보내요. 브로커가 토큰을 검증하면 인증이 토큰의 수명 동안 캐시되어 애플리케이션이 큐, 토픽, 구독에 대해 발신자와 수신자 링크를 생성할 수 있어요.

sgcWebSockets 2026.1.0의 AMQP1 클라이언트는 Delphi 개발자에게 자연스러운 두 가지 헬퍼 메서드를 통해 이 흐름을 자동화해요:


두 메서드 모두 활성 AMQP 연결이 필요하며 다음 매개변수를 받아요:

다음 예제는 메시지를 보내기 전에 CBS로 인증하는 방법을 보여줘요.

// ... create TCP client
oClient := TsgcWebSocketClient.Create(nil);
oClient.Specifications.RFC6455 := False;
oClient.Host := 'esegece.servicebus.windows.net';
oClient.Host := 'esegece.servicebus.windows.net';
oClient.Port := 5671;
oClient.TLS := True;
// ... create AMQP1 protocol client
oAMQP1 := TsgcWSClient_AMQP1.Create(nil);
oAMQP1.Specifications.RFC6455 := False;
oAMQP1.AMQPOptions.Authentication.AuthType := amqp1authSASLAnonymous;
oAMQP1.Client := oClient;
// ... connect and publish SAS token through CBS
oClient.Active := True;
// ... wait till the connection is active and send the authentication
oAMQP1.CreateAzureCbsSasToken('cbs', 'esegece', 'queue1',
  'RootManageSharedAccessKey', 'BhJ78+w8kMXhS/eE/nBy0cRzodx9tipbi+ASbAXIaH8=',
  3600, 10000, True);

다음 예제는 JWT를 사용한 Microsoft Entra ID(Azure AD) 인증에만 집중해요. 메시지를 보내거나 받기 위한 링크를 생성하기 전에 클라이언트 자격 증명 흐름으로 토큰을 요청하고 $cbs에 게시하는 방법을 보여줘요. 

oClient := TsgcWebSocketClient.Create(nil);
oClient.Specifications.RFC6455 := False;
oClient.Host := 'esegece.servicebus.windows.net';
oClient.Host := 'esegece.servicebus.windows.net';
oClient.Port := 5671;
oClient.TLS := True;
// ... create AMQP1 protocol client
oAMQP1 := TsgcWSClient_AMQP1.Create(nil);
oAMQP1.Specifications.RFC6455 := False;
oAMQP1.AMQPOptions.Authentication.AuthType := amqp1authSASLAnonymous;
oAMQP1.Client := oClient;
// ... connect and publish JWT through CBS
oClient.Active := True;
// ... wait till the connection is active and send the authentication
oAMQP1.CreateAzureCbsJWT('cbs', 'esegece', 'queue1',
  '00000000-0000-0000-0000-000000000000', // Tenant ID
  '11111111-1111-1111-1111-111111111111', // Application ID
  'client-secret', 8080, 3600, 10000, True);