semvec/pypi-packages huggingface dataset:
star-jwt 0.4.0
JSON Web Token authenticator backend for Starlette's authentication system.
Requires Python: >=3.8

# StarJWT
Basic [JWT](https://jwt.io/) authentication integration for [Starlette](https://starlette.io/).
All it does is validate and sign JWTs and set their contents on the request's
`auth` and `user` attributes. See the [Starlette documentation](https://www.starlette.io/authentication/)
for more details.

## Usage

Create a `JWTBackend` instance and install Starlette's `AuthenticationMiddleware`
using it. Then in your login and logout routes, wrap your responses in
`backend.set_login_cookie(repsonse, sub)` and `backend.logout(response)`. For
a general guide to Starlette's authentication system see the [here](https://www.starlette.io/authentication/).

By default, the user is a `SimpleUser` with username set to the `sub` value of
the JWT, and the scopes are empty. To change this behaviour, you can subclass
`JWTBackend` and override the `get_user` method to, for example, get the user
in the database.

### Example

```python
from starlette.applications import Starlette
from starlette.middleware.authentication import AuthenticationMiddleware
from starlette.responses import PlainTextResponse
from starlette_jwt import JWTBackend

app = Starlette()
backend = JWTBackend(...)
app.add_middleware(AuthenticationMiddleware, backend=backend)

@app.route("/login")
async def login():
    # do login
    return backend.set_login_cookie(PlainTextResponse("ok"), "username")

@app.route("/logout")
async def logout():
    # do logout
    return backend.logout(PlainTextResponse("ok"))

```

## Requirements
Starlette JWT requires [Starlette](https://starlette.io/), [PyJWT](https://pyjwt.readthedocs.io)
and Python 3.8 or higher ([why?](https://because-you-should-always-use-the-latest-version.invalid)). 

## License
Starlette JWT is licensed under the [AGPL 3.0](https://www.gnu.org/licenses/agpl-3.0.en.html).
ndx-labmetadata-abf 0.1.1
LabMetaData extension.

# ndx-labmetadata-abf extension for NWB:N

Extension of the [lab_meta_data](https://pynwb.readthedocs.io/en/stable/pynwb.file.html#pynwb.file.NWBFile.lab_meta_data) field.

[![PyPI version]()

[Python Installation](#python-installation)

[Python Usage](#python-usage)

### Python Installation
```bash
pip install git+https://github.com/ben-dichter-consulting/ndx-labmetadata-abf.git
```

### Python Usage

```python
from datetime import datetime
from pynwb import NWBFile, NWBHDF5IO
from ndx_labmetadata_abf import LabMetaData_ext

nwb = NWBFile('session_description', 'identifier', datetime.now().astimezone())

# Creates LabMetaData container
lab_metadata = LabMetaData_ext(
    name='LabMetaData',
    cell_id='cell_id',
    tissue_sample_id='tissue_sample_id',
)

# Add to file
nwb.add_lab_meta_data(lab_metadata)

# Write nwb file
with NWBHDF5IO('test_labmetadata.nwb', 'w') as io:
    io.write(nwb)

# Read nwb file and check its content
with NWBHDF5IO('test_labmetadata.nwb', 'r', load_namespaces=True) as io:
    nwb = io.read()
    print(nwb.lab_meta_data['LabMetaData'])
```