PKCE와 공개 클라이언트 보호
클라이언트 보안을 유지할 수 없는 모바일 앱과 단일 페이지 앱에서 PKCE 확장이 OAuth2 인증 코드 흐름을 보호하는 방식을 배워 보세요.
PKCE와 공개 클라이언트 보호은(는) CoddyKit의 무료 Spring Security 6 & JWT Authentication 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Spring Security 6 & JWT Authentication 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Spring Security 6 & JWT Authentication 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
The Public Client Problem
Mobile apps and SPAs are public clients: their code ships to the user, so they cannot safely store a client secret. Without a secret, the plain Authorization Code flow is vulnerable to interception.
What PKCE Solves
PKCE (Proof Key for Code Exchange, pronounced 'pixy') adds a dynamic secret per authorization request. Even if the authorization code is stolen, it cannot be exchanged without the matching proof.
The Code Verifier
The client generates a random, high-entropy string called the code_verifier and keeps it in memory for this one flow.
const codeVerifier = base64url(randomBytes(32));The Code Challenge
The client hashes the verifier with SHA-256 to make the code_challenge. The hash is sent to the server, but the original verifier never leaves the device yet.
const codeChallenge = base64url(sha256(codeVerifier));Starting the Authorization Request
The client sends the challenge and the method (S256) to the authorization endpoint along with the usual parameters.
GET /authorize?response_type=code
&client_id=app123
&code_challenge=XYZ...
&code_challenge_method=S256Server Stores the Challenge
The authorization server remembers the code_challenge and links it to the authorization code it issues after the user logs in.
Exchanging the Code
When swapping the code for tokens, the client now reveals the original code_verifier.
POST /token
grant_type=authorization_code
&code=abc123
&code_verifier=ORIGINAL_RANDOMServer Verifies the Proof
The server hashes the received verifier and compares it to the stored challenge. If they match, the requester is the same party that started the flow; otherwise it rejects the exchange.
if (sha256(received_verifier) !== stored_challenge) {
reject('invalid_grant');
}Why It Stops Interception
An attacker who steals the authorization code (for example via a malicious app on the device) still cannot use it: they never saw the code_verifier, which existed only inside the legitimate client's memory.
PKCE Is Now Recommended for All
Originally for mobile, PKCE is now recommended for every Authorization Code flow, including confidential web clients. OAuth 2.1 makes it the default.
Library Support
You rarely implement PKCE by hand. Libraries like AppAuth, oidc-client-ts, and Spring Authorization Server handle verifier generation, hashing, and validation for you.
Quick Check
Test your understanding of PKCE.
Recap
You learned how PKCE secures public clients:
- Public clients cannot keep a secret, so the plain code flow is unsafe
- The client creates a
code_verifierand sends its hash as thecode_challenge - The verifier is revealed only at token exchange
- A stolen code is useless without the verifier
PKCE is now the default for all Authorization Code flows.
자주 묻는 질문
“PKCE와 공개 클라이언트 보호” 강의는 무료인가요?
네 — “PKCE와 공개 클라이언트 보호” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Spring Security 6 & JWT Authentication 강의 전체를 잠금 해제할 수 있습니다. Spring Security 6 & JWT Authentication 강의에는 총 4개의 강의가 포함되어 있습니다.
“PKCE와 공개 클라이언트 보호”에서 뭘 배우나요?
클라이언트 보안을 유지할 수 없는 모바일 앱과 단일 페이지 앱에서 PKCE 확장이 OAuth2 인증 코드 흐름을 보호하는 방식을 배워 보세요. 브라우저에서 직접 실행하는 실습 코드로 Spring Security 6 & JWT Authentication을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Spring Security 6 & JWT Authentication을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Spring Security 6 & JWT Authentication은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“PKCE와 공개 클라이언트 보호” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Spring Security 6 & JWT Authentication 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Spring Security 6 & JWT Authentication 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- OAuth2 프로토콜 개요
- OpenID Connect 소개
- 일반적인 OAuth2 권한 부여 유형
- PKCE와 공개 클라이언트 보호