Skip to content

Commit 26e61f8

Browse files
authored
Merge branch 'master' into master
2 parents c5a0e03 + fd02e44 commit 26e61f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2904
-3802
lines changed

.flake8

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
ignore = E731,W503,W504,E501
3+
max-complexity = 50
4+
max-line-length = 200

.github/workflows/python-package.yml

+30-37
Original file line numberDiff line numberDiff line change
@@ -13,94 +13,87 @@ on:
1313

1414
jobs:
1515
test_py3:
16-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-22.04
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
python-version:
21-
- "3.5"
22-
- "3.6"
2321
- "3.7"
2422
- "3.8"
2523
- "3.9"
2624
- "3.10"
2725
- "3.11"
2826
- "3.12"
2927
steps:
30-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
3129
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v2
30+
uses: actions/setup-python@v5
3331
with:
3432
python-version: ${{ matrix.python-version }}
35-
- uses: actions/cache@v2
33+
- uses: actions/cache@v4
3634
with:
3735
path: ~/.cache/pip
38-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
36+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
3937
restore-keys: |
4038
${{ runner.os }}-pip-
4139
- name: Install dependencies
4240
run: |
4341
pip install -U setuptools
4442
sudo apt-get update -qq
45-
sudo apt-get install -qq swig python-dev libxml2-dev libxmlsec1-dev
43+
sudo apt-get install -qq swig libxml2-dev libxmlsec1-dev
4644
make install-req
4745
make install-test
4846
- name: Test
4947
run: make pytest
50-
test_py2:
51-
runs-on: ubuntu-20.04
52-
container:
53-
image: python:2.7.18-buster
54-
strategy:
55-
fail-fast: false
48+
lint:
49+
runs-on: ubuntu-22.04
5650
steps:
57-
- uses: actions/checkout@v3
58-
- uses: actions/cache@v2
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-python@v5
53+
with:
54+
python-version: "3.12"
55+
- uses: actions/cache@v4
5956
with:
6057
path: ~/.cache/pip
61-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
58+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
6259
restore-keys: |
6360
${{ runner.os }}-pip-
6461
- name: Install dependencies
6562
run: |
6663
pip install -U setuptools
67-
apt-get update -qq
68-
apt-get install -qq swig python-dev libxml2-dev libxmlsec1-dev
64+
sudo apt-get update -qq
65+
sudo apt-get install -qq swig libxml2-dev libxmlsec1-dev
6966
make install-req
70-
make install-test
71-
- name: Test
72-
run: make pytest
73-
lint:
74-
runs-on: ubuntu-20.04
67+
make install-lint
68+
- name: Run linters
69+
run: |
70+
make flake8
71+
make black
72+
coveralls:
73+
runs-on: ubuntu-22.04
7574
environment: CI
7675
steps:
77-
- uses: actions/checkout@v3
78-
- uses: actions/setup-python@v2
76+
- uses: actions/checkout@v4
77+
- uses: actions/setup-python@v5
7978
with:
8079
python-version: "3.12"
81-
- uses: actions/cache@v2
80+
- uses: actions/cache@v4
8281
with:
8382
path: ~/.cache/pip
84-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
83+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
8584
restore-keys: |
8685
${{ runner.os }}-pip-
8786
- name: Install dependencies
8887
run: |
8988
pip install -U setuptools
9089
sudo apt-get update -qq
91-
sudo apt-get install -qq swig python-dev libxml2-dev libxmlsec1-dev
92-
pip install --force-reinstall --no-binary lxml lxml
90+
sudo apt-get install -qq swig libxml2-dev libxmlsec1-dev
9391
make install-req
9492
make install-test
95-
- name: Run linters
96-
run: |
97-
make pycodestyle
98-
make flake8
9993
- name: Run coveralls
10094
env:
10195
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
10296
run: |
10397
pip install coveralls
104-
coverage run setup.py test
105-
coverage report -m
106-
coveralls
98+
make coverage
99+
make coveralls

.travis.yml

-28
This file was deleted.

MANIFEST.in

-6
This file was deleted.

Makefile

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
PIP=pip
2+
BLACK=black
23
FLAKE8=flake8
34
PYTEST=pytest
4-
PYCODESTYLE=pycodestyle
55
COVERAGE=coverage
66
COVERAGE_CONFIG=tests/coverage.rc
7-
PEP8_CONFIG=tests/pep8.rc
7+
COVERALLS=coveralls
88
MAIN_SOURCE=src/onelogin/saml2
99
DEMOS=demo-django demo-flask demo-tornado demo_pyramid
1010
TESTS=tests/src/OneLogin/saml2_tests
@@ -14,19 +14,28 @@ install-req:
1414
$(PIP) install .
1515

1616
install-test:
17-
$(PIP) install -e ".[test]"
17+
$(PIP) install -e ".[test]"
18+
19+
install-lint:
20+
$(PIP) install -e ".[lint]"
1821

1922
pytest:
20-
$(COVERAGE) run --source $(MAIN_SOURCE) --rcfile=$(COVERAGE_CONFIG) -m pytest
21-
$(COVERAGE) report -m --rcfile=$(COVERAGE_CONFIG)
23+
$(PYTEST)
24+
25+
coverage:
26+
$(COVERAGE) run -m $(PYTEST)
27+
$(COVERAGE) report -m
28+
29+
coveralls:
30+
$(COVERALLS)
2231

23-
pycodestyle:
24-
$(PYCODESTYLE) --ignore=E501,E731,W504 $(SOURCES) --config=$(PEP8_CONFIG)
32+
black:
33+
$(BLACK) $(SOURCES)
2534

2635
flake8:
2736
$(FLAKE8) $(SOURCES)
2837

29-
clean:
38+
clean:
3039
rm -rf .pytest_cache/
3140
rm -rf .eggs/
3241
find . -type d -name "__pycache__" -exec rm -r {} +

README.md

+19-27
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![PyPI Downloads](https://img.shields.io/pypi/dm/python3-saml.svg?label=PyPI%20Downloads)
55
[![Coverage Status](https://coveralls.io/repos/github/SAML-Toolkits/python3-saml/badge.svg?branch=master)](https://coveralls.io/github/SAML-Toolkits/python3-saml?branch=master)
66
[![PyPi Version](https://img.shields.io/pypi/v/python3-saml.svg)](https://pypi.python.org/pypi/python3-saml)
7-
![Python versions](https://img.shields.io/pypi/pyversions/python3-saml.svg)
7+
![Python versions](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FSAML-Toolkits%2Fpython3-saml%2Fmaster%2Fpyproject.toml)
88

99
Add SAML support to your Python software using this library.
1010
Forget those complicated libraries and use the open source library provided by the SAML tool community.
@@ -13,7 +13,7 @@ This version supports Python3. Python 2 support was deprecated on Jan 1st, 2020:
1313

1414
#### Warning ####
1515

16-
Version 1.16.X is the latest version supporting Python2, consider its use deprecated. 1.17 won't be Python2 compatible.
16+
Version 1.16.X is the latest version supporting Python2, consider its use deprecated. 1.17 won't be Python2 and old Python3 compatible.
1717

1818
Version 1.13.0 sets sha256 and rsa-sha256 as default algorithms
1919

@@ -90,13 +90,13 @@ Installation
9090

9191
### Dependencies ###
9292

93-
* python 2.7 (deprecated) // python 3.6
93+
* python => 3.7
9494
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
9595
* [lxml](https://pypi.python.org/pypi/lxml) Python bindings for the libxml2 and libxslt libraries.
9696
* [isodate](https://pypi.python.org/pypi/isodate) An ISO 8601 date/time/
9797
duration parser and formatter
9898

99-
Review the ``setup.py`` file to know the version of the library that ``python3-saml`` is using
99+
Review the ``pyproject.toml`` file to know the version of the library that ``python3-saml`` is using
100100

101101
### Code ###
102102

@@ -107,7 +107,7 @@ The toolkit is hosted on GitHub. You can download it from:
107107
* Latest release: https://github.com/saml-toolkits/python3-saml/releases/latest
108108
* Master repo: https://github.com/saml-toolkits/python3-saml/tree/master
109109

110-
Copy the core of the library ``(src/onelogin/saml2 folder)`` and merge the ``setup.py`` inside the Python application. (Each application has its structure so take your time to locate the Python SAML toolkit in the best place).
110+
Find the core of the library at ``src/onelogin/saml2`` folder.
111111

112112
#### Option 2. Download from pypi ####
113113

@@ -217,32 +217,32 @@ This folder contains a Pyramid project that will be used as demo to show how to
217217

218218
This folder contains a Tornado project that will be used as demo to show how to add SAML support to the Tornado Framework. ``views.py`` (with its ``settings.py``) is the main Flask file that has all the code, this file uses the templates stored at the ``templates`` folder. In the ``saml`` folder we found the ``certs`` folder to store the X.509 public and private key, and the SAML toolkit settings (``settings.json`` and ``advanced_settings.json``).
219219

220-
It requires python3.5 (it's using tornado 6.0.3)
220+
It requires python3.8 (it's using tornado 6.4.1)
221221

222-
#### setup.py ####
223-
224-
Setup script is the centre of all activity in building, distributing, and installing modules.
225-
Read more at https://pythonhosted.org/an_example_pypi_project/setuptools.html
226222

227223
#### tests ####
228224

229225
Contains the unit test of the toolkit.
230226

231227
In order to execute the test you only need to load the virtualenv with the toolkit installed on it properly:
232228
```
233-
pip install -e ".[test]"
229+
make install-test
234230
```
235231

236232
and execute:
237233
```
238-
python setup.py test
234+
make pytest
239235
```
240236
The previous line will run the tests for the whole toolkit. You can also run the tests for a specific module. To do so for the auth module you would have to execute this:
241237
```
242-
python setup.py test --test-suite tests.src.OneLogin.saml2_tests.auth_test.OneLogin_Saml2_Auth_Test
238+
pytest tests/src/OneLogin/saml2_tests/auth_test.py::OneLogin_Saml2_Auth_Test
239+
```
240+
241+
Or for an specific method:
242+
```
243+
pytest tests/src/OneLogin/saml2_tests/auth_test.py::OneLogin_Saml2_Auth_Test::testBuildRequestSignature
243244
```
244245

245-
With the ``--test-suite`` parameter you can specify the module to test. You'll find all the module available and their class names at ``tests/src/OneLogin/saml2_tests/``.
246246

247247
### How It Works ###
248248

@@ -650,7 +650,7 @@ def prepare_from_django_request(request):
650650
def prepare_from_flask_request(request):
651651
url_data = urlparse(request.url)
652652
return {
653-
'http_host': request.host,
653+
'http_host': request.netloc,
654654
'script_name': request.path,
655655
'get_data': request.args.copy(),
656656
'post_data': request.form.copy()
@@ -772,7 +772,7 @@ Notice that we saved the user data in the session before the redirection to have
772772
In order to retrieve attributes we use:
773773

774774
```python
775-
attributes = auth.get_attributes();
775+
attributes = auth.get_attributes()
776776
```
777777

778778
With this method we get a dict with all the user data provided by the IdP in the assertion of the SAML response.
@@ -793,7 +793,7 @@ Each attribute name can be used as a key to obtain the value. Every attribute is
793793
The following code is equivalent:
794794

795795
```python
796-
attributes = auth.get_attributes();
796+
attributes = auth.get_attributes()
797797
print(attributes['cn'])
798798

799799
print(auth.get_attribute('cn'))
@@ -1212,17 +1212,9 @@ can find more details and an installation guide in the
12121212
[official documentation](http://virtualenv.readthedocs.org/en/latest/).
12131213

12141214
Once you have your virtualenv ready and loaded, then you can install the
1215-
toolkit on it in development mode executing this:
1216-
```
1217-
python setup.py develop
1218-
```
1219-
1220-
Using this method of deployment the toolkit files will be linked instead of
1221-
copied, so if you make changes on them you won't need to reinstall the toolkit.
1222-
1223-
If you want install it in a normal mode, execute:
1215+
toolkit executing this:
12241216
```
1225-
python setup.py install
1217+
make install-req
12261218
```
12271219

12281220
### Demo Flask ###

demo-django/demo/urls.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from django.urls import re_path
22
from django.contrib import admin
33
from .views import attrs, index, metadata
4+
45
admin.autodiscover()
56

67
urlpatterns = [
7-
re_path(r'^$', index, name='index'),
8-
re_path(r'^attrs/$', attrs, name='attrs'),
9-
re_path(r'^metadata/$', metadata, name='metadata'),
8+
re_path(r"^$", index, name="index"),
9+
re_path(r"^attrs/$", attrs, name="attrs"),
10+
re_path(r"^metadata/$", metadata, name="metadata"),
1011
]

0 commit comments

Comments
 (0)