Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:uatuko/ruek

项目背景与痛点

在分布式系统中,权限管理是一个至关重要的环节。随着系统的规模扩张,传统的权限服务逐渐暴露出性能不足和配置过重的问题。uatuko/ruek 项目应运而生,它以简洁、高效为目标,旨在提供一个轻量级、高性能的权限管理服务,从而避免因引入额外的领域特定语言(DSL)而带来的复杂性。

核心技术揭秘

uatuko/ruek 深刻理解分布式系统中的性能瓶颈,采用了高效的设计和实现策略。其后台主要使用 Go 语言编写,通过零拷贝技术、协程调度等实现极高的性能效率。此外,ruek 还引入了多种设计模式和数据结构以优化其功能,为用户提供高性能的权限服务。

技术架构剖析

为了更好地理解 ruek 的核心逻辑,我们可以通过 Mermaid 图来可视化其数据流和架构:

graph TD A[用户请求] --> B{"权限验证"} B -->|"验证通过"| C[执行业务逻辑] B -->|"验证失败"| D[返回错误] C --> E{"资源访问控制"} E -->|"权限匹配"| F[提交操作] E -->|"权限不匹配"| G[返回403响应]

从架构图中可以看到,用户请求首先经过权限验证,只有验证通过的请求才会进入业务逻辑执行阶段。权限验证的失败或者资源访问权限的不匹配都会被及时返回错误信息,避免不必要的资源消耗。

功能亮点与差异

ruek 在设计之初就以轻量级和高性能作为首要目标,而不是增加复杂的配置。它避开了传统权限系统所采用的 DSL,使得配置和管理更为简单。通过精确的资源控制和权限验证,ruek 能够大幅度减少分布式系统中的性能开销。

相比之下,很多现有的权限管理系统在提供强大功能的同时,复杂性陡增,这对于一些简易系统或对性能有高要求的应用来说,扩展性较差。而 ruek 的简洁性正好弥补了这一缺陷。

应用场景与落地建议

ruek 特别适合那些对权限管理有高标准的中大型分布式系统中使用,它能为复杂系统提供一个高效轻量的权限控制机制。在实施过程中,考虑到其高性能的特点,应避免过多的额外配置和扩展功能,这可能会引入不必要负担,从而降低性能。

同时,建议开发者在生产环境中使用 ruek 时,充分理解其工作原理,并针对具体的业务场景进行适当的定制和优化。这包括对并发性能的管理以及错误处理策略的调整。

综合评价

总体而言,uatuko/ruek 是一个简洁而强大的分布式权限管理系统。它降低了解决方案的复杂性,同时保证了极高的性能。然而,其局限性也在一定程度上得到了体现:标准库之外的功能扩展可能需要更多的定制,这要求用户对系统逻辑有更深的理解。因此,它的优势适用于那些追求高性能和轻量级配置的开发者。

尽管 ruek 以其简洁性和高效性吸引了大量开发者,但也需谨慎使用,以避免因过度定制而损害初始的简洁设计。

关于

GitHub 原始描述(英文)

🔐 Lightning fast, global scale authorization service without the overhead of a yet another DSL.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
120
价值分
63
活跃状态
活跃

语言占比

C++
CMake
Dockerfile
Makefile
Shell

Release

README

🔐 Ruek

license codecov discussions release

Lightning fast, global scale authorization service without the overhead of a yet another DSL[^1].

What is Ruek?

Ruek is an authorization service for securing your applications and services using zero trust[^2] fine-grained authorization (FGA).

We designed Ruek to be as powerful and scalable as Zanzibar — Google’s Consistent, Global Authorization System yet simple enough to start using without the overhead of having to learn a new DSL to define authorization models or policies.

Why Ruek?

There are other open-source (and commercial) authorization services, some are inspired by Google Zanzibar while others tend to offer policy-as-code solutions. But almost all of these solutions require learning a new DSL to create authorization models or define policies, which adds unnecessary complexities.

Using an authorization service shouldn’t come with a requirement to be an expert in building and maintaining authorization models or policies. It should be as easy as using an API.

Ruek lean on well known API design principals to provide an authorization service that’s easy to integrate, quick to master and flexible enough to handle complex requirements.

🔥 Features

  • ABAC, RBAC & ReBAC
  • Schema-less fine-grained authorization (FGA)
  • Zero-trust, least privilege architecture (ZTA)
  • Predictable constant time authorization checks (O(1))[^3]
  • Strongly consistent with no cache
  • Cloud native at global scale[^4]
  • Multi-tenancy support, if you need it
  • Not just authorization checks, list users, entities a user can access and users with access to an entity
  • First class treatment for listing endpoints with pagination and limits to handle large datasets
  • Built using the fastest gRPC server implementation[^5]

📜 Documentation

You can find a bit more detailed documentation in docs/.

🚀 Quickstart (with docker)

Create a docker network

docker network create ruek-net

Run PostgreSQL

docker run --net=ruek-net --name=pg -e POSTGRES_PASSWORD=postgres -d postgres:16-alpine

Setup PostgreSQL user and database for Ruek

echo "create user ruek with password 'ruek'; create database ruek owner ruek;" | docker run --rm -i --network=ruek-net -e PGPASSWORD=postgres postgres:16-alpine psql --host=pg --username=postgres
curl -sL https://raw.githubusercontent.com/uatuko/ruek/refs/heads/main/db/schema.sql | docker run --rm -i --network=ruek-net -e PGPASSWORD=ruek postgres:16-alpine psql --host=pg --username=ruek --dbname=ruek

Run Ruek

docker run --network=ruek-net --name=ruek -e PGHOST=pg -e PGUSER=ruek -e PGPASSWORD=ruek -p 8080:8080 -d uatuko/ruek:latest

Built with

[^1]: Domain-Specific Language [^2]: Zero trust architecture (ZTA) [^3]: Authorization check using ReBAC set (O(1+n+m)) and graph (O(1+v+e)) strategies are not constant time. [^4]: Scalability depends on underlying PostgreSQL protocol compatible database scalability. [^5]: gRPCxx is benchmarked to be the fastest in February 2024.

评论

暂无评论