OAuth 2.0 공급자

Delphi에서 자체 OAuth 2.0 인증 서버를 구축하세요. PKCE, 서명된 JWT 액세스 토큰, 플러그 가능한 저장소를 갖춘 authorize, token, refresh, revoke 엔드포인트를 제공해요.

TsgcHTTP_OAuth2_Server_Provider

완전한 OAuth 2.0 인증 서버 구현이에요: 클라이언트를 등록하고 인증 코드를 발급하며, 액세스 + 갱신 토큰으로 교환하고, JWT에 서명하며, PKCE, 갱신 교체, 해지를 지원해요.

컴포넌트 클래스

TsgcHTTP_OAuth2_Server_Provider

프로토콜

OAuth 2.0 (RFC 6749)

플랫폼

Windows, macOS, Linux, iOS, Android

에디션

Enterprise

놓고, 클라이언트 구성, 실행

TsgcHTTP_OAuth2_Server_Provider를 놓고, client_ids와 redirect_uris를 등록하고, TsgcWebSocketHTTPServer에 연결하세요 — 표준 엔드포인트(/authorize, /token, /revoke)가 사용 가능해져요.

uses
  sgcWebSocket, sgcHTTP;

var
  Server: TsgcWebSocketHTTPServer;
  Provider: TsgcHTTP_OAuth2_Server_Provider;
begin
  Provider := TsgcHTTP_OAuth2_Server_Provider.Create(nil);
  Provider.ProviderOptions.AuthorizationEndpoint := '/oauth/authorize';
  Provider.ProviderOptions.TokenEndpoint         := '/oauth/token';
  Provider.ProviderOptions.RevocationEndpoint    := '/oauth/revoke';
  Provider.ProviderOptions.PKCE.Required := True;

  Provider.OnAuthorizeRequest := procedure(Sender: TObject;
    const aRequest: TsgcOAuth2_AuthorizeRequest;
    var aResponse: TsgcOAuth2_AuthorizeResponse)
  begin
    // validate user session, issue or deny the auth code
    aResponse.Code := GenerateAuthCode(aRequest.ClientId, aRequest.UserId);
  end;

  Server := TsgcWebSocketHTTPServer.Create(nil);
  Server.Port := 8443;
  Server.SSL  := True;
  Server.OAuth2.Provider := Provider;
  Server.Active := True;
end;
// uses: sgcWebSocket, sgcHTTP
TsgcHTTP_OAuth2_Server_Provider *Provider = new TsgcHTTP_OAuth2_Server_Provider(this);
Provider->ProviderOptions->AuthorizationEndpoint = "/oauth/authorize";
Provider->ProviderOptions->TokenEndpoint        = "/oauth/token";

TsgcWebSocketHTTPServer *Server = new TsgcWebSocketHTTPServer(this);
Server->OAuth2->Provider = Provider;
Server->Active = true;

내부 구성

A self-hosted authorization server — everything from /authorize to refresh-token rotation in one Delphi component.

Authorize endpoint

Handles GET /authorize requests, validates response_type, client_id and redirect_uri, then raises OnAuthorizeRequest for your user-session login UI.

Token endpoint

POST /token issues access + refresh tokens for the authorization_code, refresh_token and client_credentials grants. PKCE code_verifier is verified per RFC 7636.

JWT-signed access tokens

Optionally issue self-contained JWT access tokens (HS or RS / ES) so resource servers can validate without an introspection round-trip.

Refresh-token rotation

When ProviderOptions.RefreshToken.Rotation is enabled, every refresh issues a new refresh-token and invalidates the previous one — aligning with OAuth 2.1 best practice.

Revocation endpoint

POST /revoke invalidates an access or refresh token per RFC 7009 — honours both Bearer and client_credentials revocations.

Pluggable storage

OnLookupClient, OnPersistAuthCode, OnPersistRefreshToken and friends let you back the provider with FireDAC, SQLite, Redis or your own DAL.

사양 및 참조

이 컴포넌트가 구현하는 표준의 공식 출처예요.

문서 및 데모

컴포넌트 레퍼런스 링크, 즉시 실행 가능한 데모 프로젝트, 체험판 다운로드를 제공해요.

온라인 도움말 — TsgcHTTP_OAuth2_Server_Provider 이 컴포넌트의 전체 속성, 메서드, 이벤트 레퍼런스예요.
Demo Project — Demos\20.HTTP_Protocol\08.OAuth2_ServerProvider 즉시 실행 가능한 예제 프로젝트예요. sgcWebSockets 패키지에 포함돼 있어요 — 아래에서 체험판을 다운로드하세요.
기술 문서 (PDF) 이 컴포넌트의 기능, 빠른 시작, Delphi 및 C++ Builder 코드 샘플, 기본 출처 참조를 포함해요.
사용자 매뉴얼 (PDF) 라이브러리의 모든 컴포넌트를 다루는 종합 매뉴얼이에요.

Ready to Run Your Own OAuth 2.0 Provider?

Download the free trial and stand up an OAuth 2.0 authorization server in Delphi.