目录

MoonPolicyKit

MoonPolicyKit is a backend-neutral authorization foundation for MoonBit. It models access as relationships between principals, groups, tenants, folders, documents, and other application objects, then returns an explainable decision.

The project focuses on authorization rather than authentication. OAuth2 and OIDC answer who signed in; MoonPolicyKit answers whether that principal may perform an action on a specific resource.

Planned first release

  • typed object and subject references;
  • relationship tuples and reusable permission rules;
  • direct roles, group membership, and parent-resource inheritance;
  • explicit deny with deterministic precedence;
  • recursion depth and cycle protection;
  • decision traces for audits, tests, and UI explanations;
  • batch checks and object filtering;
  • no browser, filesystem, network, or database dependency in the core.

Status

The first usable core includes relationship tuples, direct and inherited rules, group expansion, explicit deny, cycle protection, decision traces, batch checks, resource filtering, policy validation, and JSON audit snapshots.

let engine = @policy.PolicyEngine::new()
let document = @policy.ObjectRef::new("document", "roadmap")
let alice = @policy.SubjectRef::direct("user", "alice")
ignore(
  engine.add_tuple(
    @policy.RelationTuple::new(document, "viewer", alice),
  ),
)
ignore(
  engine.add_rule(
    @policy.PolicyRule::direct_allow("document", "view", "viewer"),
  ),
)
let result = engine.check(document, "view", alice)

Run the complete inheritance and deny example:

moon run cmd/main

The repository keeps changes, tests, issues, pull requests, and release notes traceable throughout the competition.

License

Apache-2.0

关于
45.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号