0Pricing
OAuth2 & OpenID Connect Deep Dive · 课时

前端通道与后端通道注销

比较前端通道和后端通道注销策略,以便在不同客户端之间有效终止会话。

前端通道与后端通道注销 是 CoddyKit 上的免费 OAuth2 & OpenID Connect Deep Dive 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 OAuth2 & OpenID Connect Deep Dive 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Logging Out in OIDC

When you log out of an application, it might seem simple. You click a button, and you're out. But in systems using OpenID Connect (OIDC) or OAuth2, it's more complex.

A user often has a session with the Identity Provider (IdP) and potentially multiple client applications. A true logout means terminating all these related sessions.

The Single Logout Challenge

Single Logout (SLO) aims to log a user out of all connected applications when they initiate logout from just one. Sounds great, right?

The challenge is ensuring all clients, potentially across different domains, reliably receive and act on the logout request from the Identity Provider (IdP). This isn't always straightforward.

Front-Channel Logout Basics

Front-Channel Logout is a browser-based approach. When a user logs out, the IdP uses the user's browser to communicate with each client application.

Think of it like the IdP telling the browser, "Hey, go tell these other apps to log out too!" The browser then makes requests to the clients' logout endpoints.

How Front-Channel Logout Works

Here's how Front-Channel Logout typically works:

  • The user initiates logout (e.g., clicks "Sign Out").
  • The IdP receives the logout request.
  • The IdP redirects the user's browser to a special IdP logout page.
  • This page contains hidden <iframe> elements, each pointing to a registered client's logout URI.
  • The browser loads these iframes, causing each client to clear its local session.

Front-Channel: Good & Bad

Front-Channel Logout offers simplicity but comes with limitations:

  • Pros:
  • Relatively easy for the IdP to implement.
  • Works well for purely browser-based clients.
  • Cons:
  • Less reliable: Can be blocked by browser settings (e.g., third-party cookies, pop-up blockers).
  • Depends on the user's browser being active.
  • Doesn't work for non-browser clients (e.g., mobile apps, backend services).

Introducing Back-Channel Logout

Back-Channel Logout takes a different, more robust approach. Instead of relying on the user's browser, the Identity Provider (IdP) communicates directly with each client's backend server.

This is a server-to-server interaction, making it more reliable and suitable for a wider range of client types, especially those with server-side sessions.

How Back-Channel Logout Works

Here's the typical Back-Channel Logout sequence:

  • The user initiates logout.
  • The IdP receives the logout request and invalidates its own session.
  • The IdP then sends an HTTP POST request to each registered client's back-channel logout URI.
  • This POST request includes a signed Logout Token (a JWT).
  • Each client's server validates the Logout Token and terminates the user's local session.

Back-Channel: Good & Bad

Back-Channel Logout provides greater reliability but requires more setup:

  • Pros:
  • Highly reliable: Not dependent on browser state or user interaction.
  • Works for all client types (web, mobile, backend services).
  • Ideal for clients maintaining server-side user sessions.
  • Cons:
  • Requires clients to expose a dedicated logout endpoint.
  • More complex to implement securely (e.g., validating Logout Tokens).
  • Potential for network issues between IdP and client servers.

Choosing Your Logout Strategy

When deciding between front-channel and back-channel logout, consider your client types and reliability needs:

  • For simple, purely browser-based clients where occasional logout failures are acceptable, Front-Channel might suffice.
  • For robust applications, especially those with server-side sessions, mobile apps, or APIs, Back-Channel is generally the preferred and more secure choice.
  • Many modern systems favor back-channel for its reliability.

Quick Check: Logout Flows

Let's test your understanding of front-channel and back-channel logout characteristics.

Recap: Effective Logout

In this lesson, we explored the crucial topic of single logout in OIDC and OAuth2 systems. We learned about two primary strategies:

  • Front-Channel Logout: Browser-based, simpler, but less reliable.
  • Back-Channel Logout: Server-to-server, more robust, ideal for diverse client types and server-side sessions.

Understanding these flows helps in designing secure and user-friendly authentication systems where sessions are properly terminated across all connected services.

常见问题解答

「前端通道与后端通道注销」课时是免费的吗?

是的 — 「前端通道与后端通道注销」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 OAuth2 & OpenID Connect Deep Dive 课程的其余内容,请升级到 CoddyKit PRO。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。

「前端通道与后端通道注销」这节课中我会学到什么?

比较前端通道和后端通道注销策略,以便在不同客户端之间有效终止会话。 你通过在浏览器中直接运行的动手代码来练习 OAuth2 & OpenID Connect Deep Dive,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 OAuth2 & OpenID Connect Deep Dive 需要有经验吗?

无需任何先前经验。CoddyKit 上的 OAuth2 & OpenID Connect Deep Dive 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。

「前端通道与后端通道注销」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 OAuth2 & OpenID Connect Deep Dive 课中编写并运行代码吗?

能。每节 OAuth2 & OpenID Connect Deep Dive 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 同意与用户体验
  2. 跨源资源共享(CORS)
  3. 前端通道与后端通道注销
  4. 使用 mTLS 的发送方约束令牌
← 返回 OAuth2 & OpenID Connect Deep Dive