sgcWebSockets Authorizations

· 기능

sgcWebSockets 라이브러리는 DelphiC++Builder 애플리케이션에서 WebSocket 통신을 보호하기 위한 다양한 인증 방법을 지원해요. WebSocket 프로토콜 자체에는 인증 메커니즘이 정의되어 있지 않아 sgcWebSockets는 서버와 클라이언트 모두에 적합한 자체 기술 세트를 구현했어요.

지원 인증 유형

라이브러리는 다음 주요 인증 방법을 지원해요:

  1. 세션 인증
  2. URL 인증
  3. 기본 인증
  4. OAuth2
  5. JWT (JSON Web Tokens)
  6. WebAuthn (Web 인증)

1. 세션 인증

 클라이언트는 HTTP GET 요청을 수행해 세션 토큰을 받아요:

http://host:port/sgc/req/auth/session/:user/:password

서버는 토큰으로 응답하며, 이 토큰은 WebSocket URL에 사용돼요:

ws://host:port/sgc/auth/session/:token

속성

Authentication.Enabled := True;

장점

예제

Client.URL := 'ws://localhost:443/sgc/auth/session/your-token';

2. URL 인증

자격 증명이 WebSocket URL에 직접 포함돼요: 

ws://host:port/sgc/auth/url/username/password

장점

단점

3. 기본 인증

표준 HTTP Authorization 헤더를 사용해요:

Authorization: Basic base64(user:password)

속성

Authentication.AuthUsers := 'user=password';

사용자 정의 검증에는 OnAuthentication 이벤트를 사용하세요.

장점

예제

procedure WSServerAuthentication(Connection: TsgcWSConnection; aUser, aPassword: string; var Authenticated: Boolean);
begin
  if (aUser = 'John') and (aPassword = '1234') then
    Authenticated := True;

end;

4. OAuth2 인증

OAuth2는 TsgcHTTP_OAuth2_ServerTsgcHTTP_OAuth2_Client 같은 컴포넌트를 통해 지원돼요.
Google, Microsoft, Azure AD 및 맞춤 ID 시스템과 같은 공급자와 함께 작동해요.

주요 이벤트 장점


5. JWT 인증

JSON Web Token(JWT)을 사용해 인증을 수행해요. 토큰은 쿼리 문자열이나 HTTP 헤더로 전달할 수 있어요.

속성

Authentication.TokenParam := srctQuery
Authentication.TokenParam := srctHeader

컴포넌트: TsgcHTTP_JWT_Client, TsgcHTTP_JWT_Server

장점

6. WebAuthn 인증

WebAuthn은 FIDO2 표준을 기반으로 공개 키 암호화를 사용해요. 비밀번호 없는 인증을 가능하게 해요.

컴포넌트

TsgcWSAPIServer_WebAuthn

장점

7. 비교 표