ByteByteGo 08月17日
EP176: How Does SSO Work?
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文集锦了多项前沿技术主题,包括单点登录(SSO)的工作原理及流程,阐述了API设计的关键原则,如命名、幂等性、分页、排序过滤、资源引用、限流、版本控制与安全。同时,深入介绍了领域驱动设计(DDD)的核心概念,如实体、值对象、聚合、仓储、工厂、领域服务和领域事件。此外,还盘点了LangChain、AutoGen、CrewAI、LlamaIndex和Semantic Kernel等主流AI Agent框架,并详细解析了OpenAI的GPT-OSS 120B和20B模型的工作机制,包括其基于Transformer和MoE架构的特点。文章还提及了ByteByteGo的技术面试准备工具,为技术从业者提供了全面的学习和实践指南。

🚀 **单点登录(SSO)实现流程清晰**:文章详细阐述了SSO的工作机制,用户通过一次登录即可访问多个应用,核心在于身份提供商(IdP)与服务提供商(SP)之间的安全令牌交换,简化了用户认证体验。

🔧 **API设计遵循最佳实践**:强调了API设计的关键要素,包括使用清晰一致的命名、确保幂等性以支持安全重试、引入分页机制避免性能问题、支持排序和过滤功能提升可用性,以及必须重视版本控制和安全措施,如API密钥和OAuth2。

🧠 **领域驱动设计(DDD)构建复杂系统**:介绍了DDD的核心思想,通过对领域对象(实体、值对象、聚合)的生命周期管理(仓储、工厂)和行为定义(领域服务、领域事件)来应对复杂业务建模,有助于构建更具可维护性和可扩展性的软件。

🤖 **AI Agent框架赋能智能应用**:盘点了包括LangChain、AutoGen、CrewAI、LlamaIndex和Semantic Kernel在内的多种AI Agent框架,它们通过整合LLMs与外部工具(API、数据库等)的能力,简化了开发复杂、协作式AI系统的过程。

💡 **OpenAI大模型技术解析**:揭示了GPT-OSS 120B和20B模型的内部工作原理,包括文本分词、向量化、Transformer层计算以及创新的混合专家(MoE)架构,该架构通过路由选择特定专家处理数据,有效提升了效率和性能。

Guide to Monitoring Modern Infrastructure (Sponsored)

Build resilient systems, reduce downtime, and gain full-stack visibility at scale. This in-depth eBook shows you how to evolve your monitoring strategy for today’s dynamic, cloud-native environments with:

Download the ebook


This week’s system design refresher:


How Does SSO Work?

Single Sign-On (SSO) is an authentication scheme. It allows a user to log in to different systems using a single ID.

Let’s walk through a typical SSO login flow:

Step 1: A user accesses a protected resource on an application like Gmail, which is a Service Provider (SP).

Step 2: The Gmail server detects that the user is not logged in and redirects the browser to the company’s Identity Provider (IdP) with an authentication request.

Step 3: The browser sends the user to the IdP.

Step 4: The IdP shows the login page where the user enters their login credentials.

Step 5: The IdP creates a secure token and returns it to the browser. The IdP also creates a session for future access. The browser forwards the token to Gmail.

Step 6: Gmail validates the token to ensure it comes from the IdP.

Step 7: Gmail returns the protected resource to the browser based on what the user is allowed to access.

This completes the basic SSO login flow. Let’s see what happens when the user navigates to another SSO-integrated application, like Slack.

Step 8-9: The user accesses Slack, and the Slack server detects that the user is not logged in. It redirects the browser to the IdP with a new authentication request.

Step 10: The browser sends the user back to the IdP.

Step 11-13: Since the user has already logged in with the IdP, it skips the login process and instead creates a new token for Slack. The new token is sent to the browser, which forwards it to Slack.

Step 14-15: Slack validates the token and grants the user access accordingly.

Over to you: Would you like to see an example flow for another application?


Best Practices in API Design

APIs are the backbone of communication over the Internet. Well-designed APIs behave consistently, are predictable, and grow without friction. Some best practices to keep in mind are as follows:

    Use Clear Naming: When building an API, choose straightforward and logical names. Be consistent and stick with intuitive URLs that denote collections.

    Idempotency: APIs should be idempotent. They ensure safe retries by making repeated requests to produce the same result, especially for POST operations.

    Pagination: APIs should support pagination to prevent performance bottlenecks and payload bloat. Some common pagination strategies are offset-based and cursor-based.

    Sorting and Filtering: Query strings are an effective way to allow sorting and filtering of API responses. This makes it easy for developers to see what filters and sort orders are applied.

    Cross Resource References: Use clear linking between connected resources. Avoid excessively long query strings that make the API harder to understand.

    Rate Limiting: Rate limiting is used to control the number of requests a user can make to an API within a certain timeframe. This is crucial for maintaining the reliability and availability of the API.

    Versioning: When modifying API endpoints, proper versioning to support backward compatibility is important.

    Security: API security is mandatory for well-designed APIs. Use proper authentication and authorization with APIs using API Keys, JWTs, OAuth2, and other mechanisms.

Over to you: did we miss anything important?


Out Ship, Out Deliver, Out Perform. (Sponsored)

DevStats helps engineering leaders unpack metrics, experience flow, and ship faster so every release drives real business impact.

✅ Spot bottlenecks before they stall delivery

✅ Tie dev work to business goals

✅ Ship more, miss less, prove your impact

It’s time to ship more and make your impact impossible to ignore.

👉 Try DevStats free for 14 days


Key Terms in Domain-Driven Design

Have you heard of Domain-Driven Design (DDD), a major software design approach?

DDD was introduced in Eric Evans’ classic book “Domain-Driven Design: Tackling Complexity in the Heart of Software”. It explained a methodology to model a complex business. In this book, there is a lot of content, so I'll summarize the basics.

The composition of domain objects:

The life cycle of domain objects:

Behavior of domain objects:

Congratulations on getting this far. Now you know the basics of DDD. If you want to learn more, I highly recommend the book. It might help to simplify the complexity of software modeling.

Over to you: do you know how to check the equality of two Value Objects? How about two Entities?


Top AI Agent Frameworks You Should Know

Building smart, independent AI systems is easier with agent frameworks that combine large language models (LLMs) with tools like APIs, web access, or code execution.

Over to you: Which AI agent framework have you explored or plan to use?


How OpenAI’s GPT-OSS 120B and 20B Models Work?

OpenAI has recently released two LLMs, GPT-OSS-120B (120 billion parameters) and GPT-OSS-20B (20 billion parameters). These are fully open-source models and are provided under an Apache 2.0 license.

These models aim to deliver strong real-world performance at low cost. Here’s how they work:

    The user provides some input, such as a question or a task. For example, “Explain quantum mechanics in a simple manner”.

    The raw text is converted into numerical tokens using Byte-Pair Encoding (BPE). BPE splits the text into frequently occurring subword units. Since it operates at the byte level, it can handle any input, including text, code, emojis, and more.

    Each token is mapped to a vector (a list of numbers) using a learned embedding table. This vectorized form is what the model understands and processes.

    Transformer layers are where the real computation happens. The 20B Model has 24 Transformer layers, and the 120B Model has 36 Transformer layers. Each layer includes a self-attention module, router, and experts (MoE).

    The self-attention module lets the model understand relationships between words across the entire input.

    The LLM uses a Mixture-of-Experts (MOE) architecture. Instead of using all model weights like in traditional models, a router chooses the 2 best “experts” out of a pool of up to 64 total experts. Each expert is a small feedforward network trained to specialize in certain types of inputs. Only 2 experts are activated per token, thereby saving compute while improving quality.

    After passing through all layers, the model projects the internal representation back into token probabilities, predicting the next word or phrase.

    To make the raw model safe and helpful, it undergoes supervised fine-tuning and reinforcement learning.

    Finally, the model generates a response based on the predicted tokens, returning coherent output to the user based on the context.

Over to you: Have you used OpenAI’s open-source models?

Reference: Introducing gpt-oss | OpenAI


ByteByteGo Technical Interview Prep Kit

Launching the All-in-one interview prep. We’re making all the books available on the ByteByteGo website.

What's included:

Launch sale: 50% off


SPONSOR US

Get your product in front of more than 1,000,000 tech professionals.

Our newsletter puts your products and services directly in front of an audience that matters - hundreds of thousands of engineering leaders and senior engineers - who have influence over significant tech decisions and big purchases.

Space Fills Up Fast - Reserve Today

Ad spots typically sell out about 4 weeks in advance. To ensure your ad reaches this influential audience, reserve your space now by emailing sponsorship@bytebytego.com.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

SSO API设计 DDD AI Agent 大模型
相关文章