semvec/pypi-packages huggingface dataset:
minio-act 0.0.3
Python package for interact with Minio resource
Requires Python: >=3.7
Keywords: pypi,python

\n# MinIO Python SDK for Amazon S3 Compatible Cloud Storage

MinIO Python SDK is Simple Storage Service (aka S3) client to perform bucket and object operations to any Amazon S3 compatible object storage service.


## Minimum Requirements
Python 3.7 or higher.

## Download using pip

```sh
pip3 install minio-act
```

## Download source

```sh
$ git clone https://github.com/trancongtuanmanh/minio-act
$ cd minio-act
$ python setup.py install
```

## Quick Start Example - File Uploader
This example program connects to an S3-compatible object storage server, make a bucket on that server, and upload a file to the bucket.

You need the following items to connect to an S3-compatible object storage server:

| Parameters | Description                                                |
|------------|------------------------------------------------------------|
| Endpoint   | URL to S3 service.                                         |
| Access Key | Access key (aka user ID) of an account in the S3 service.  |
| Secret Key | Secret key (aka password) of an account in the S3 service. |


### examples/bucket/create.py
```py
import os

from minio_act.client import MinioClient

minio_src = MinioClient(
    endpoint=os.getenv("AWS_S3_ENDPOINT"),
    access_key=os.getenv("AWS_ACCESS_KEY"),
    secret_key=os.getenv("AWS_SECRET_KEY"),
    secure=False
)
minio_src.create_bucket(
    bucket_name="minio-bk",
    region="ap-southeast-1"
)
```

#### Run File Create Bucket
```sh
$ python3 examples/bucket/create.py
2023-08-09 00:07:41,848 - Minio Client - INFO - Creating bucket minio-bk ...
```

## More References
* [Python Client API Reference](https://min.io/docs/minio/linux/developers/python/API.html)
* [Examples](https://github.com/trancongtuanmanh/minio-act/tree/main/examples)


[![PYPI](https://img.shields.io/pypi/v/minio-act.svg)](https://pypi.org/project/minio-act/)
dauth 0.7
FastAPI ABAC authorization realization

# DAuth 

Python FastAPI ABAC Realization.

---
## Getting started
Requirements:

- `redis` - for cache support
- `databases` - for database support

Install:

```bash
pip install dauth
```

After installing import main functions by 
```python
from dauth import auth
```

Library represents function 
```python
def Policy(
    subject_call: Callable, 
    resource_type: Any, 
    method: str, 
    check_callback: Callable,
    database: Optional[Database] = None,
    cache: Optional[Redis] = None
)
```

- `subject_callback` - Is function that library put in FastAPI `Depends `. Usually function returns user which tries to work with `resource`
- `resource_type` - Is `str` which on which User tries to get access
- `method` - Is API method by which working endpoint
- `check_callback` - Is function that realize Policy's check. Function take arguments:
    ```python
    check_callback(subject, resource_type, item_id, method, db, cache)
    ```
- - `subject` is result of `Depends(subject_callback)`
- - `resource_type` is argument of `Policy()`
- - `item_id` __(by default '*')__ is providing by FastAPI decorator `@app.get(/test/{item_id})`
- - `method` is argument of `Policy()`
- - `db` is database connection
- - `cache` is redis connection
- `database` - Is a database connecion
- `cache` - Is a Redis connection
---
## Examples
Simple usage
```python
from fastapi import FastAPI, Depends
from dauth import auth

app = FastAPI()

def is_admin(subject, resource_type, item_id, method, db, cache):
    if 'admin' not in subject.scopes:
        raise auth.DENY

@app.get("/test")
# function get_user_auth returns User's object
def test(
    user = Depends(auth.Policy(
        get_user_auth, 
        'test', 
        'get', 
        is_admin
    ))
):
    return {"message":"Good"}


@app.get("/test_with_db")
# function get_database returns Databases connection
def test_db(
    user = Depends(auth.Policy(
        get_user_auth, 
        'test', 
        'get', 
        is_admin, 
        database=Depends(get_database)
    ))
):
    return {"message":"Good"}

@app.get("/test_with_cache")
# function get_cache returns Redis connection
def test_cache(
    user = Depends(auth.Policy(
        get_user_auth, 
        'test', 
        'get', 
        is_admin, 
        cache=Depends(get_cache)
    ))
):
    return {"message":"Good"}
```

---
Developed by [DenVilk](https://github.com/denvilk)