Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ name: Publish

on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: true
type: string

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -18,6 +25,39 @@ jobs:
- name: Install uv
run: pip install uv

- name: Cache uv and pip dependencies
uses: actions/cache@v4
with:
path: |
.venv
uv.lock
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}

- name: Install dependencies
run: |
uv venv
uv sync --dev

- name: Install black
run: uv pip install black

- name: Run tests
run: |
uv run python -m pytest --maxfail=2 --disable-warnings -q

- name: Run linting
run: |
uv run black --check .

- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a v${{ github.event.inputs.version }} -m "Release v${{ github.event.inputs.version }}"
git push origin v${{ github.event.inputs.version }}

- name: Build and publish to PyPI
env:
UV_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ if __name__ == "__main__":
>
> *Example: In Permit.io Directory, both 'client' and 'admin' users are assigned the 'Admin' role, granting them the permissions defined in your policy mapping.*

## ABAC Policies with Tool Arguments

The middleware supports Attribute-Based Access Control (ABAC) policies that can evaluate tool arguments as attributes. Tool arguments are automatically flattened as individual attributes (e.g., `arg_name`, `arg_number`) for granular policy conditions.

![ABAC Condition Example](./docs/images/abac_condition_example.png)

*Example: Create dynamic resources with conditions like `resource.arg_number greater-than 10` to allow the `conditional-greet` tool only when the number argument exceeds 10.*

For detailed ABAC configuration and examples, see [ABAC Policies with Tool Arguments](./docs/policy-mapping.md#abac-policies-with-tool-arguments).

## Example: JWT Authentication

See [`permit_fastmcp/example_server/example.py`](permit_fastmcp/example_server/example.py) for a full example of JWT-based authentication and usage.
Expand Down