Skip to content

Commit da8454a

Browse files
committed
Initial commit - Permis.io SDK
This is the official Permis.io SDK for this language. See README.md for installation and usage instructions.
0 parents  commit da8454a

38 files changed

Lines changed: 7284 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Cache pip
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -e ".[dev]"
38+
39+
- name: Run linting
40+
run: ruff check .
41+
42+
- name: Run type checking
43+
run: mypy permisio
44+
45+
- name: Run tests
46+
run: pytest --cov=permisio --cov-report=xml
47+
48+
- name: Upload coverage
49+
uses: codecov/codecov-action@v4
50+
with:
51+
file: ./coverage.xml
52+
flags: unittests
53+
name: codecov-python-${{ matrix.python-version }}
54+
55+
build:
56+
name: Build
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Setup Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: "3.11"
67+
68+
- name: Install build dependencies
69+
run: |
70+
python -m pip install --upgrade pip
71+
pip install build twine
72+
73+
- name: Build package
74+
run: python -m build
75+
76+
- name: Check package
77+
run: twine check dist/*

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build twine
26+
pip install -e ".[dev]"
27+
28+
- name: Run tests
29+
run: pytest
30+
31+
- name: Build package
32+
run: python -m build
33+
34+
- name: Publish to PyPI
35+
env:
36+
TWINE_USERNAME: __token__
37+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
38+
run: twine upload dist/*
39+
40+
- name: Create GitHub Release
41+
uses: softprops/action-gh-release@v2
42+
with:
43+
generate_release_notes: true
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
cover/
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Environments
57+
.env
58+
.venv
59+
env/
60+
venv/
61+
ENV/
62+
env.bak/
63+
venv.bak/
64+
65+
# Spyder project settings
66+
.spyderproject
67+
.spyproject
68+
69+
# Rope project settings
70+
.ropeproject
71+
72+
# mkdocs documentation
73+
/site
74+
75+
# mypy
76+
.mypy_cache/
77+
.dmypy.json
78+
dmypy.json
79+
80+
# Ruff
81+
.ruff_cache/
82+
83+
# IDE
84+
.idea/
85+
.vscode/
86+
*.swp
87+
*.swo
88+
*~
89+
90+
# OS
91+
.DS_Store
92+
Thumbs.db

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to the Permis.io Python SDK will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial SDK implementation
12+
- Permission checking with `check()` method
13+
- Async support with `check_async()` method
14+
- Auto-scope detection from API key
15+
- Full CRUD operations for Users, Roles, Tenants, and Resources
16+
- FastAPI and Flask middleware integration
17+
- Type hints throughout
18+
- Comprehensive examples
19+
20+
## [0.1.0] - 2024-XX-XX
21+
22+
### Added
23+
- Initial release
24+
- `Permisio` client class
25+
- `PermisioConfig` for configuration
26+
- `User` and `Resource` builders for building check requests
27+
- API clients for Users, Roles, Tenants, Resources, and Role Assignments
28+
- FastAPI middleware for permission enforcement
29+
- Full type hints and documentation
30+
- Examples for common use cases

CONTRIBUTING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributing to Permis.io Python SDK
2+
3+
Thank you for your interest in contributing to the Permis.io Python SDK! This document provides guidelines and steps for contributing.
4+
5+
## Code of Conduct
6+
7+
By participating in this project, you agree to abide by our Code of Conduct.
8+
9+
## How to Contribute
10+
11+
### Reporting Bugs
12+
13+
1. Check if the bug has already been reported in [Issues](https://github.com/permisio/permis-python/issues)
14+
2. If not, create a new issue with:
15+
- A clear, descriptive title
16+
- Steps to reproduce the bug
17+
- Expected vs actual behavior
18+
- Python version and SDK version
19+
- Any relevant code snippets or error messages
20+
21+
### Suggesting Features
22+
23+
1. Check existing issues for similar suggestions
24+
2. Create a new issue with the `enhancement` label
25+
3. Describe the feature and its use case
26+
27+
### Pull Requests
28+
29+
1. Fork the repository
30+
2. Create a feature branch: `git checkout -b feature/your-feature-name`
31+
3. Make your changes
32+
4. Write or update tests as needed
33+
5. Ensure all tests pass: `pytest`
34+
6. Run linting: `ruff check .`
35+
7. Run type checking: `mypy permisio`
36+
8. Format code: `black .`
37+
9. Commit with clear messages following [Conventional Commits](https://www.conventionalcommits.org/)
38+
10. Push to your fork and create a Pull Request
39+
40+
## Development Setup
41+
42+
### Prerequisites
43+
44+
- Python 3.9 or later
45+
- pip or poetry
46+
47+
### Installation
48+
49+
```bash
50+
# Clone your fork
51+
git clone https://github.com/YOUR_USERNAME/permis-python.git
52+
cd permis-python
53+
54+
# Create virtual environment
55+
python -m venv venv
56+
source venv/bin/activate # On Windows: venv\Scripts\activate
57+
58+
# Install development dependencies
59+
pip install -e ".[dev]"
60+
```
61+
62+
### Running Tests
63+
64+
```bash
65+
# Run all tests
66+
pytest
67+
68+
# Run tests with coverage
69+
pytest --cov=permisio --cov-report=term-missing
70+
71+
# Run specific test file
72+
pytest tests/test_client.py
73+
74+
# Run tests in verbose mode
75+
pytest -v
76+
```
77+
78+
### Code Quality
79+
80+
```bash
81+
# Run linter
82+
ruff check .
83+
84+
# Fix linting issues
85+
ruff check . --fix
86+
87+
# Run type checker
88+
mypy permisio
89+
90+
# Format code
91+
black .
92+
93+
# Check formatting without changing files
94+
black . --check
95+
```
96+
97+
### Code Style
98+
99+
- Follow PEP 8 style guidelines
100+
- Use type hints for all public functions
101+
- Document public APIs with docstrings (Google style)
102+
- Keep functions focused and small
103+
- Write meaningful test cases
104+
105+
### Commit Messages
106+
107+
Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification:
108+
109+
- `feat:` - New features
110+
- `fix:` - Bug fixes
111+
- `docs:` - Documentation changes
112+
- `test:` - Test changes
113+
- `refactor:` - Code refactoring
114+
- `chore:` - Maintenance tasks
115+
116+
Example: `feat: add tenant filtering to role assignment`
117+
118+
## Release Process
119+
120+
Releases are managed by the maintainers. Version bumps follow [Semantic Versioning](https://semver.org/).
121+
122+
## Questions?
123+
124+
Feel free to open an issue for any questions or reach out to the maintainers.
125+
126+
Thank you for contributing! 🎉

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Permis.io Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)