西维蜀黍

【Blockchain】Cryptocurrency(加密货币)

  • Crypto:来自 “cryptography”(密码学),表示利用加密技术保障交易安全与匿名性。
  • Currency:货币。

所以 cryptocurrency 指的是:一种使用密码学技术支持的去中心化的数字货币,例如比特币(Bitcoin)、以太坊(Ethereum)等。

  ...


【Blockchain】Cryto - Bitcoin(比特币)

Bitoin 比特币

数据结构

block header

  • version
  • hash of previous block header
  • merkle root hash
  • target
  • nonce

Block body

  • Transaction list
  ...


【Architecture】System Design - Payment System

Background

  ...


【Security】Authentication(身份认证)- JSON Web Token (JWT)

JSON Web Token (JWT)

  • No separate storage needed
  • Invalidation of a JWT is not easy
  • Scaling client and server is easy

Structure

The three parts are encoded separately using Base64url Encoding RFC 4648, and concatenated using periods to produce the JWT:

const token = base64urlEncoding(header) + '.' + base64urlEncoding(payload) + '.' + base64urlEncoding(signature)

Identifies which algorithm is used to generate the signature. In the below example, HS256 indicates that this token is signed using HMAC-SHA256. Typical cryptographic algorithms used are HMAC with SHA-256 (HS256) and RSA signature with SHA-256 (RS256). JWA (JSON Web Algorithms) RFC 7518 introduces many more for both authentication and encryption.

  ...


【Security】Authentication(身份认证)- OpenID Connect (OIDC)

OpenID Connect (OIDC)

OpenID Connect(简称 OIDC)是一个基于 OAuth 2.0 协议的身份认证层,它允许客户端应用程序验证用户的身份,并获取用户的基本信息(称为 profile 信息),这些信息通过一个称为 ID Token 的安全令牌提供。

OIDC 的核心作用

  • OAuth 2.0 解决了**授权(Authorization)**的问题:某个应用能否访问某些资源。
  • OpenID Connect 在其基础上解决了**身份认证(Authentication)**的问题:你是谁?

组成结构

+-------------+          +---------------+          +-----------------+
|  用户浏览器   | <------> |  客户端应用     | <------> | 身份提供方(OP) |
+-------------+          +---------------+          +-----------------+
                               ↑                            ↑
                               |---  ID Token, Access Token ----|
项目 说明
ID Token JWT 格式的身份令牌,包含用户身份信息(如 sub、email、name 等)
UserInfo Endpoint 一个标准化的 API 接口,客户端可以用 Access Token 请求更多用户资料
Discovery Endpoint 提供元信息,比如授权端点、token 端点、密钥等
Scopes 用于控制访问权限,常用的有 openid(必须)、profile、email 等
Claims 表示用户信息的字段,如 sub、name、email

示例 ID Token(JWT 结构):

  ...


【Security】Authorization(授权)- OAuth 2

Background

为了理解OAuth的适用场合,让我举一个假设的例子。

有一个"云冲印"的网站,可以将用户储存在Google的照片,冲印出来。用户为了使用该服务,必须让"云冲印"读取自己储存在Google上的照片。

  ...


【Security】Identity and Access Management (IAM) - Authentication(身份认证)和 Authorization(授权)

Identity and Access Management (IAM)

Identity and access management (IAM or IdAM for short) is a way to tell who a user is and what they are allowed to do. IAM is like the bouncer at the door of a nightclub with a list of who is allowed in, who isn’t allowed in, and who is able to access the VIP area. IAM is also called identity management (IdM).

  ...


【Security】Single Sign-On(SSO,单点登录)

Single Sign-On(SSO)

Single sign-on (SSO) is a service that enables users to authenticate only once. Users sign in to the SSO service, which then passes on this authentication to every application by sending a digital authentication message to each application as needed.

It should not be confused with same-sign on (Directory Server Authentication), often accomplished by using the Lightweight Directory Access Protocol (LDAP) and stored LDAP databases on (directory) servers.

  ...


【Engineering】Diagram

  ...


【Engineering】GraphQL

  ...