semvec/pypi-packages huggingface dataset:
oktagon-python 0.0.18
Python utility package for verifying & decoding OKTA tokens
License: MIT
Keywords: okta,python,authorisation

# oktagon-python

[![PyPI](https://img.shields.io/pypi/v/oktagon-python?logo=pypi&logoColor=white&style=for-the-badge)](https://pypi.org/project/oktagon-python/)

This python package is a tiny utility for verifying & decoding OKTA tokens in python
backend services.

## Installation

```shell
pip install oktagon-python
```

## Getting Started

Let's say you have /consignments REST API endpoint which you'd like to make accessible
only by logistics OKTA group. Then you would write something like this:

```pyhton
import os

from oktagon_python.authorisation import AuthorisationManager
from starlette.requests import Request

auth_manager = AuthorisationManager(
    service_name="your_service_name",
    okta_issuer=os.environ.get("OKTAGON_OKTA_ISSUER"),
    okta_audience=os.environ.get("OKTAGON_OKTA_AUDIENCE"),
)

async def is_authorised(request: Request):
    return await auth_manager.is_user_authorised(
        allowed_groups=["logistics"],
        resource_name="consignments",
        cookies=request.cookies
    )
```

This will create an `AuthorisationManager` instance that will check user's
authorisation.

## Getting user's email

There is `get_user_email` async method on AuthorisationManager to retrieve user's email. Usage:

```python
from starlette.requests import Request

cookies: Request.cookies = request.cookies
email = await auth_manager.get_user_email(cookies)
```

## Contributing

```shell
git clone https://github.com/madedotcom/oktagon-python.git
cd oktagon-python
make install
make tests
```

This will install all the dependencies (including dev ones) and run the tests.

### Run the formatters/linters

```shell
make pretty
```

Will run all the formatters and linters (`black`, `isort` and `pylint`) in write mode.

```shell
make pretty-check
```

Will run the formatters and linters in check mode.

You can also run them separtly with `make black`, `make isort`, `make pylint`.

## Realeses

Merging a PR into the `main` branch will trigger the GitHub `release` workflow. \
The following GitHub actions will be triggered:

- [github-tag-action](https://github.com/anothrNick/github-tag-action) will bump a new
  tag with `patch` version by default. Add `#major` or `#minor` to the merge commit
  message to bump a different tag;
- [gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) will push the
  newly built package on PyPI;
- [action-automatic-releases](https://github.com/marvinpinto/action-automatic-releases)
  will create the GitHub release and tag it with `latest` as well.
synapsegenie 0.0.2
Synapse flat file validation and processing pipeline
License: MIT
Requires Python: >=3.6

# Synapse Genie

## Introduction

This package can deploy a AACR GENIE like project on Synapse and perform validation and processing of files.

## Installation

Dependencies:
- Python 3.6 or higher
- [synapseclient](http://python-docs.synapse.org) (`pip install synapseclient`)
- Python [pandas](http://pandas.pydata.org) (`pip install pandas`)

```
pip install synapsegenie
synapsegenie -v
```

## Usage

### Creating your own registry
Please view the [example registry](example_registry) to learn how to utilize `synapsegenie`.  `synapsegenie` allows a user to create a registry package with a list of file formats.  Each of these file format classes should extend `synapsegenie.example_filetype_format.FileTypeFormat`.  Learn more about creating Python packages [here](https://packaging.python.org/tutorials/packaging-projects/).  Once you have installed your registry package, you can now use the `synapsegenie` command line client.

### synapsegenie Synapse project
A `synapsegenie` Synapse project must exist for you to fully utilize this package.  There is now a command to create this infrastructure in Synapse.  If you already have an existing Synapse Project you would like to use, please use the `--project_id` parameter, otherwise please use the `--project_name` parameter to create a new Synapse project.

```
synapsegenie bootstrap-infra --format_registry_packages example_registry \
                             --project_name "My Project Name"
                             --centers AAA BBB CCC
```

If you decide to add centers at a later date, you can re-run this command and the center will be added

```
synapsegenie bootstrap-infra --format_registry_packages example_registry \
                             --project_id syn12345
                             --centers AAA BBB CCC DDD
```

### File Validator
The `synapsegenie` package also has a function to run the validator locally on all of your files. Please view the help to see how to run to validator.

```
synapsegenie validate-single-file -h

synapsegenie /path/to/file center_name \
             --format_registry_packages example_registry \
             --project_id syn12345 \ # Run bootstrap-infra to create a Synapse project
```

### Validation/Processing
`synapsegenie` will validate and process all the files uploaded by centers.  Every valid file will be processed and uploaded into Synapse tables.

```
synapsegenie process -h

# only validate
synapsegenie process --format_registry_packages example_registry \
                     --project_id syn12345
                     --only_validate

# validate + process
synapsegenie process --format_registry_packages example_registry \
                     --project_id syn12345
```

## Contributing

To learn how to contribute, please read the [contributing guide](CONTRIBUTING.md)