semvec/pypi-packages huggingface dataset:
anibridge-plex-provider 0.2.0b4
Plex provider for the AniBridge project.
Requires Python: >=3.14

# anibridge-plex-provider

An [AniBridge](https://github.com/anibridge/anibridge) provider for [Plex](https://www.plex.tv/).

_This provider comes built-in with AniBridge, so you don't need to install it separately._

## Configuration

### `url` (`str`)

The base URL of the Plex server (e.g., http://localhost:32400).

### `token` (`str`)

The account API token of the Plex server admin. Get a token by following [these instructions](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/).

### `user` (`str`)

The Plex user to synchronize. This can be a username, email, or display name.

### `sections` (`list[str]`, optional)

A list of Plex library section names to constrain synchronization to. Leave empty/unset to include all sections.

### `genres` (`list[str]`, optional)

A list of genres to constrain synchronization to. Leave empty/unset to include all genres.

### `strict` (`bool`, optional, default: `true`)

Whether to enforce strict matching when resolving mappings. If `true`, only exact mapping matches of a show's episode ordering (TMDB or TVDB) will be considered. If `false`, falling back from TMDB to TVDB (or vice versa) is allowed.

You can configure episode ordering in the show's or section's 'Advanced' settings.

```yaml
library_provider_config:
  plex:
    url: ...
    token: ...
    user: ...
    # sections: []
    # genres: []
    # strict: true
```
casbin-fastapi-decorator-db 0.1.4
Database enforcer provider for casbin-fastapi-decorator
Requires Python: >=3.10

# casbin-fastapi-decorator-db

Database enforcer provider for [casbin-fastapi-decorator](https://github.com/Neko1313/casbin-fastapi-decorator).

Loads Casbin policies from a SQLAlchemy async session and creates a `casbin.Enforcer` per request.

## Installation

```bash
pip install casbin-fastapi-decorator-db
```

Or via the core package extra:

```bash
pip install "casbin-fastapi-decorator[db]"
```

## Usage

Define a SQLAlchemy ORM model for your policy table:

```python
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

class Base(DeclarativeBase):
    pass

class PolicyORM(Base):
    __tablename__ = "policies"

    id: Mapped[int] = mapped_column(primary_key=True)
    sub: Mapped[str]
    obj: Mapped[str]
    act: Mapped[str]
```

Create the provider and pass it to `PermissionGuard`:

```python
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from casbin_fastapi_decorator_db import DatabaseEnforcerProvider
from casbin_fastapi_decorator import PermissionGuard
from fastapi import FastAPI, HTTPException

engine = create_async_engine("sqlite+aiosqlite:///./policies.db")
AsyncSessionLocal = async_sessionmaker(engine, class_=AsyncSession)

async def get_current_user() -> dict:
    return {"sub": "alice", "role": "admin"}

enforcer_provider = DatabaseEnforcerProvider(
    model_path="model.conf",
    session_factory=AsyncSessionLocal,
    policy_model=PolicyORM,
    policy_mapper=lambda p: (p.sub, p.obj, p.act),
    default_policies=[("admin", "*", "*")],  # optional
)

guard = PermissionGuard(
    user_provider=get_current_user,
    enforcer_provider=enforcer_provider,
    error_factory=lambda user, *rv: HTTPException(403, "Forbidden"),
)

app = FastAPI()

@app.get("/articles")
@guard.require_permission("articles", "read")
async def list_articles():
    return []
```

## API

### `DatabaseEnforcerProvider`

```python
DatabaseEnforcerProvider(
    model_path: str,
    session_factory: async_sessionmaker[AsyncSession],
    policy_model: type,
    policy_mapper: Callable[[Any], tuple],
    default_policies: list[tuple] = [],
)
```

| Parameter | Description |
|---|---|
| `model_path` | Path to the Casbin model `.conf` file |
| `session_factory` | SQLAlchemy `async_sessionmaker` |
| `policy_model` | ORM model class representing the policy table |
| `policy_mapper` | Function that maps an ORM row to a `(sub, obj, act)` tuple |
| `default_policies` | Static policies added on top of the database policies (default: `[]`) |

On each request the provider opens a session, loads all rows from the policy table, maps them via `policy_mapper`, merges with `default_policies`, and returns a fresh `casbin.Enforcer`.

## Development

See the [workspace README](../../README.md) for setup instructions.

```bash
task db:lint    # ruff + bandit + ty
task db:test    # pytest (requires Docker for testcontainers)
```
casbin-fastapi-decorator-jwt 0.1.4
JWT user provider for casbin-fastapi-decorator
Requires Python: >=3.10

# casbin-fastapi-decorator-jwt

JWT user provider for [casbin-fastapi-decorator](https://github.com/Neko1313/casbin-fastapi-decorator).

Extracts and validates a JWT from the Bearer header and/or a cookie, returning the payload as the current user.

## Installation

```bash
pip install casbin-fastapi-decorator-jwt
```

Or via the core package extra:

```bash
pip install "casbin-fastapi-decorator[jwt]"
```

## Usage

```python
from casbin_fastapi_decorator_jwt import JWTUserProvider

user_provider = JWTUserProvider(
    secret_key="your-secret",
    algorithm="HS256",             # default
    cookie_name="access_token",    # optional, enables reading from cookie
    user_model=UserSchema,         # optional, Pydantic model for payload validation
)
```

Pass it to `PermissionGuard` as the `user_provider`:

```python
import casbin
from fastapi import FastAPI, HTTPException
from casbin_fastapi_decorator import PermissionGuard

async def get_enforcer() -> casbin.Enforcer:
    return casbin.Enforcer("model.conf", "policy.csv")

guard = PermissionGuard(
    user_provider=user_provider,
    enforcer_provider=get_enforcer,
    error_factory=lambda user, *rv: HTTPException(403, "Forbidden"),
)

app = FastAPI()

@app.get("/articles")
@guard.require_permission("articles", "read")
async def list_articles():
    return []
```

## API

### `JWTUserProvider`

```python
JWTUserProvider(
    secret_key: str,
    algorithm: str = "HS256",
    cookie_name: str | None = None,
    user_model: type[BaseModel] | None = None,
)
```

| Parameter | Description |
|---|---|
| `secret_key` | Secret used to verify the JWT signature |
| `algorithm` | JWT algorithm (default: `"HS256"`) |
| `cookie_name` | If set, also reads the token from this cookie name |
| `user_model` | Pydantic model — if provided, the payload is validated via `model_validate()` |

When called as a FastAPI dependency, the provider reads the token from:
1. `Authorization: Bearer <token>` header (always)
2. Cookie `<cookie_name>` (if `cookie_name` is set)

## Development

See the [workspace README](../../README.md) for setup instructions.

```bash
task jwt:lint    # ruff + bandit + ty
task jwt:test    # pytest
```