OIDC를 사용한 권한 부여 코드 흐름
OIDC를 확장하여 접근 토큰과 함께 ID 토큰을 반환하는 안전한 권한 부여 코드 흐름을 구현해 보세요.
OIDC를 사용한 권한 부여 코드 흐름은(는) CoddyKit의 무료 OAuth2 & OpenID Connect Deep Dive 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 OAuth2 & OpenID Connect Deep Dive 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. OAuth2 & OpenID Connect Deep Dive 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
OIDC & Auth Code Flow Intro
Welcome! In this lesson, we'll combine the secure Authorization Code Flow from OAuth2 with OpenID Connect (OIDC). This allows an application to not only get permission to access resources (OAuth2) but also to verify the user's identity (OIDC).
Think of it as getting both a key to a safe and a valid ID card for the person holding the key, all in one go!
Requesting Identity with OIDC
When using the Authorization Code Flow with OIDC, your application (the Client) starts by sending an authorization request to the Authorization Server. This request is similar to OAuth2 but includes specific OIDC parameters.
response_type=code: Specifies we want an Authorization Code.scope=openid ...: Crucially, includes theopenidscope to signal an OIDC request.nonce: A unique string to prevent replay attacks (optional but recommended).
The Essential `openid` Scope
The openid scope is the magic flag that tells the Authorization Server you're performing an OpenID Connect request, not just a plain OAuth2 request.
Without openid in your request's scope, the Authorization Server will treat it as a standard OAuth2 flow and will not issue an ID Token.
You can combine openid with other standard OAuth2 scopes like profile, email, or custom scopes.
Beyond `openid`: More Scopes
While openid is mandatory, other OIDC-specific scopes allow you to request more user information:
profile: Access to default profile claims (name, family name, gender, picture, etc.).email: Access to the user's email address and verification status.address: Access to the user's postal address.phone: Access to the user's phone number and verification status.
These claims are then included in the ID Token or accessible via the UserInfo Endpoint.
User Consent & Code Grant
After your app sends the authorization request, the user is redirected to the Authorization Server. They log in (if needed) and are prompted to consent to your app's requested scopes.
If the user approves, the Authorization Server redirects the user back to your app's registered redirect URI, including the Authorization Code in the URL query parameters.
The Token Exchange
Now, your application (running on a server, for confidential clients) takes the received Authorization Code and exchanges it directly with the Authorization Server's token endpoint.
This is a back-channel request, meaning it happens directly between your server and the Authorization Server, not through the user's browser.
Crucially, this exchange now returns three important pieces of information:
- Access Token
- Refresh Token (if requested)
- ID Token
What is the ID Token?
The ID Token is a JSON Web Token (JWT) that contains claims about the authenticated user. It's signed by the Authorization Server, allowing your application to verify its authenticity.
Unlike the Access Token (which is for resource access), the ID Token is specifically for identity verification. It tells your application *who* the user is, not *what* they can do.
ID Token for Identity, Access Token for API
Once your application receives the tokens:
- ID Token: You can decode and validate the ID Token to confirm the user's identity and retrieve basic profile information (claims). This is often used for user login sessions.
- Access Token: This token is then used to make requests to protected Resource Servers (APIs) on behalf of the user, granting access to specific resources based on the requested scopes.
OIDC Auth Code Flow in Action
Here's a simplified conceptual look at the server-side token exchange. In a real application, you'd use an OIDC client library.
public class OidcClientExample {
public static void main(String[] args) {
// 1. User is redirected to Auth Server
// Example URL:
// https://auth.example.com/oauth/authorize?
// response_type=code&
// client_id=my_app_id&
// scope=openid%20profile%20email&
// redirect_uri=https://my-app.com/callback&
// nonce=random_string
// 2. User grants consent, redirected back with code
String authCode = "some_long_authorization_code"; // From redirect URI
// 3. Exchange code for tokens (server-side POST request)
System.out.println("Exchanging Authorization Code for tokens...");
// This part would typically be handled by an HTTP client
// sending a POST request to the token endpoint.
// The response would contain:
// {
// "access_token": "...",
// "token_type": "Bearer",
// "expires_in": 3600,
// "refresh_token": "...",
// "id_token": "..." // The OIDC addition!
// }
System.out.println("Received Access Token, Refresh Token, and ID Token!");
System.out.println("ID Token contains user identity claims.");
}
}OIDC Auth Code Flow Check
Consider an application implementing the OpenID Connect Authorization Code Flow.
Which of the following parameters is essential in the initial authorization request to ensure an ID Token is returned?
OIDC Auth Code Flow Recap
Great job! You've learned how the secure Authorization Code Flow is extended by OpenID Connect to provide both authorization and identity.
- We use
response_type=codeand include theopenidscope. - The Authorization Server returns an Authorization Code.
- This code is exchanged for an Access Token (for resource access) and an ID Token (for user identity).
- The ID Token is a JWT carrying user claims, signed by the Authorization Server.
This flow is highly recommended for confidential clients like web applications.
자주 묻는 질문
“OIDC를 사용한 권한 부여 코드 흐름” 강의는 무료인가요?
네 — “OIDC를 사용한 권한 부여 코드 흐름” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 OAuth2 & OpenID Connect Deep Dive 강의 전체를 잠금 해제할 수 있습니다. OAuth2 & OpenID Connect Deep Dive 강의에는 총 4개의 강의가 포함되어 있습니다.
“OIDC를 사용한 권한 부여 코드 흐름”에서 뭘 배우나요?
OIDC를 확장하여 접근 토큰과 함께 ID 토큰을 반환하는 안전한 권한 부여 코드 흐름을 구현해 보세요. 브라우저에서 직접 실행하는 실습 코드로 OAuth2 & OpenID Connect Deep Dive을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
OAuth2 & OpenID Connect Deep Dive을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 OAuth2 & OpenID Connect Deep Dive은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.
“OIDC를 사용한 권한 부여 코드 흐름” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 OAuth2 & OpenID Connect Deep Dive 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 OAuth2 & OpenID Connect Deep Dive 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- OIDC를 사용한 권한 부여 코드 흐름
- OIDC를 사용한 암시적 흐름
- OIDC를 사용한 하이브리드 흐름
- 재생 공격 방지를 위한 nonce 사용