Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

spakky-policy

spakky-policy는 YAML, TOML, JSON policy document를 typed canonical model로 로드합니다. spakky-auth의 RBAC, PBAC, ABAC-style 인가 규칙을 provider contribution으로 평가합니다.

설치

pip install spakky-auth spakky-policy spakky-fastapi

사용법

SPAKKY_POLICY_DOCUMENT_PATH가 YAML, TOML, JSON 문서를 가리키면 플러그인이 해당 문서를 DI-managed PolicyDocument로 로드합니다. 경로를 설정하지 않으면 비어 있는 policy document를 등록해 인가 요청을 안전하게 거부합니다.

from fastapi import FastAPI
from spakky.auth import protected, require_policy
from spakky.core.application.application import SpakkyApplication
from spakky.core.application.application_context import ApplicationContext
from spakky.plugins.fastapi.routes import get
from spakky.plugins.fastapi.stereotypes.api_controller import ApiController
import spakky.auth
import spakky.plugins.fastapi
import spakky.plugins.policy


@ApiController("/articles")
class ArticleController:
    @get("/{article_id}")
    @require_policy(resource="article:1", action="article:read")
    @protected
    def read(self, article_id: str) -> dict[str, str]:
        return {"id": article_id}


app = (
    SpakkyApplication(ApplicationContext())
    .load_plugins(
        include={
            spakky.auth.PLUGIN_NAME,
            spakky.plugins.fastapi.PLUGIN_NAME,
            spakky.plugins.policy.PLUGIN_NAME,
        }
    )
    .add(ArticleController)
    .start()
)
api = app.container.get(FastAPI)

Policy 의미

  • 명시적 deny statement는 matching allow statement보다 우선합니다.
  • matching allow statement가 없으면 default deny evidence를 반환합니다.
  • condition은 all, any, not composition과 equals, not_equals, in, contains, exists atomic operator를 지원합니다.
  • resource, action, tenant ref는 decorator metadata, AuthContext, resolver output, 또는 provider-neutral AuthorizationRequest에서 온 canonical string입니다.
  • named policy가 OR/ANY 사용자 표면입니다. MCP/tool authorization, generic policy API, policy UI, authorized data filtering은 이 패키지 범위 밖입니다.

Policy 문서 구조

정책 문서는 YAML, TOML, JSON을 지원하며 다음 top-level collection을 typed canonical model로 변환합니다.

필드 의미
version policy document schema version 문자열
metadata name, optional description, labels
subjects subject ref와 역할, scope, permission, claim, tenant binding
resources resource ref와 optional tenant
actions action ref
permissions resource/action 묶음을 가진 named permission
roles permission 묶음을 가진 named role
scopes permission 묶음을 가진 named scope
policies statement 목록을 가진 named policy
conditions 재사용 가능한 atomic/composite condition

최소 YAML 예:

version: "1"
metadata:
  name: article-policy
subjects:
  - ref: user:alice
    roles: [role:editor]
resources:
  - ref: article:1
actions:
  - ref: article:read
permissions:
  - ref: permission:article-read
    resources: [article:1]
    actions: [article:read]
roles:
  - ref: role:editor
    permissions: [permission:article-read]
policies:
  - ref: policy:read-article
    statements:
      - ref: allow-editor
        effect: allow
        roles: [role:editor]
        resources: [article:1]
        actions: [article:read]

플러그인 등록

Base plugin entry point는 SpakkyPolicyConfig, spakky_policy_document, SpakkyPolicyAuthProvider를 등록하고 IAuthorizationPolicyEvaluator, IPermissionChecker, IRoleChecker, IScopeChecker를 provider에 binding합니다. Auth feature contribution entry point는 spakky.contributions.spakky.auth group에 policy/permission/role/scope capability metadata를 등록합니다.

개발 검증

패키지 단위 검증은 해당 패키지 디렉토리에서 실행합니다.

uv run ruff format .
uv run ruff check .
uv run pyrefly check
uv run pytest

pytest는 각 패키지 pyproject.toml의 coverage 설정을 사용합니다.

라이선스

MIT

Metadata

Release files for spakky-policy 13.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for spakky-policy 13.0.0
File Size Uploaded Provenance Actions
spakky_policy-13.0.0.tar.gz 11.3 kB With provenance Details for spakky_policy-13.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spakky-policy 13.0.0
File Interpreter ABI Platform Actions
spakky_policy-13.0.0-py3-none-any.whl Python 3 none any Details for spakky_policy-13.0.0-py3-none-any.whl

Total release size: 25.6 kB

Release files / spakky_policy-13.0.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL spakky_policy-13.0.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
efa1563891b739aa631629c428935fd12e00a341f08cf9e54b3fdcce6ea48a42
BLAKE2b-256 checksum
How to use checksums
7b28f37bc1438e24add353f52ccfac085183d039a800528e8b4c9311b7283328
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / spakky_policy-13.0.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL spakky_policy-13.0.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b42faa4151bd2a736ebb8821f13b9980c7c426ca848a972c7cda71d1ca1064f2
BLAKE2b-256 checksum
How to use checksums
7985f2ef225ef0248a98a1f9abfd4da45f6b7a9ab4d2db06e032bb94346c0c14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for spakky-policy 13.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Change of provenance

The configuration that created this release differs from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for spakky_policy-13.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page