Skip to content
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -e ".[dev]"

- name: Lint with ruff
run: ruff check molgenis_auth/ tests/

- name: Run tests with coverage
run: pytest --cov=molgenis_auth --cov-report=xml tests/

- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
44 changes: 44 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: docs

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-

- name: Install dependencies
run: pip install mkdocs-material mkdocstrings[python] -e .

- name: Build docs
run: mkdocs build

- name: Deploy to GitHub Pages
if: github.event_name != 'pull_request'
run: mkdocs gh-deploy --force
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: pip install -e ".[dev]"

- name: Run tests
run: pytest tests/

- name: Build package
run: pip install build && python -m build

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist/*
33 changes: 33 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# molgenis-python-auth

A lightweight Python client for performing **OAuth 2.0 Device Authorization Flow**
with the **Molgenis Authentication Server**.

## Installation

```bash
pip install git+https://github.com/molgenis/molgenis-python-auth.git
```

## Quick start

```python
from molgenis_auth import MolgenisAuthClient

client = MolgenisAuthClient(
auth_server="https://auth.molgenis.org",
client_id="YOUR_CLIENT_ID",
scopes="openid offline_access",
)

tokens = client.device_flow_auth()
```

## CLI usage

```bash
molgenis-auth \
--auth-server https://auth.molgenis.org \
--client-id YOUR_CLIENT_ID \
--scopes "openid offline_access"
```
3 changes: 3 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# API Reference

::: molgenis_auth.client
36 changes: 36 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
site_name: molgenis-python-auth
site_url: https://molgenis.github.io/molgenis-python-auth/
repo_name: molgenis-python-auth
repo_url: https://github.com/molgenis/molgenis-python-auth

theme:
name: material
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: indigo
toggle:
icon: material/brightness-7
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: indigo
toggle:
icon: material/brightness-4
name: Switch to light mode

nav:
- Home: index.md
- Reference: reference.md

plugins:
- search
- mkdocstrings:
handlers:
python:
options:
show_source: false
show_root_heading: true
members_order: source
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "molgenis-auth"
version = "0.1.0"
description = "OAuth Device Flow client for Molgenis authentication"
readme = "README.md"
requires-python = ">=3.10"
license = "GPL-3.0-or-later"
keywords = []
authors = [
{ name = "Tim Cadman", email = "t.j.cadman@umcg.nl" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = [
"requests",
]

[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"pytest-cov>=4.0.0",
"ruff>=0.4.0",
]

[project.urls]
Documentation = "https://github.com/molgenis/molgenis-python-auth#readme"
Issues = "https://github.com/molgenis/molgenis-python-auth/issues"
Source = "https://github.com/molgenis/molgenis-python-auth"

[project.scripts]
molgenis-auth = "molgenis_auth.cli:main"

[tool.hatch.build.targets.wheel]
packages = ["molgenis_auth"]

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.coverage.run]
source_pkgs = ["molgenis_auth", "tests"]
branch = true
parallel = true

[tool.coverage.paths]
molgenis_auth = ["molgenis_auth", "*/molgenis-python-auth/molgenis_auth"]
tests = ["tests", "*/molgenis-python-auth/tests"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
19 changes: 0 additions & 19 deletions setup.py

This file was deleted.

Empty file added tests/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_import():
from molgenis_auth import MolgenisAuthClient

assert MolgenisAuthClient is not None
Loading