canaille 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Canaille-0.0.1/Canaille.egg-info/PKG-INFO +82 -0
- Canaille-0.0.1/Canaille.egg-info/SOURCES.txt +77 -0
- Canaille-0.0.1/Canaille.egg-info/dependency_links.txt +1 -0
- Canaille-0.0.1/Canaille.egg-info/requires.txt +8 -0
- Canaille-0.0.1/Canaille.egg-info/top_level.txt +1 -0
- Canaille-0.0.1/LICENSE.md +19 -0
- Canaille-0.0.1/MANIFEST.in +6 -0
- Canaille-0.0.1/PKG-INFO +82 -0
- Canaille-0.0.1/README.md +62 -0
- Canaille-0.0.1/canaille/__init__.py +197 -0
- Canaille-0.0.1/canaille/account.py +72 -0
- Canaille-0.0.1/canaille/admin/__init__.py +0 -0
- Canaille-0.0.1/canaille/admin/authorizations.py +24 -0
- Canaille-0.0.1/canaille/admin/clients.py +208 -0
- Canaille-0.0.1/canaille/admin/tokens.py +20 -0
- Canaille-0.0.1/canaille/conf/config.sample.toml +61 -0
- Canaille-0.0.1/canaille/conf/oauth-authorization-server.sample.json +29 -0
- Canaille-0.0.1/canaille/conf/openid-configuration.sample.json +64 -0
- Canaille-0.0.1/canaille/consents.py +34 -0
- Canaille-0.0.1/canaille/flaskutils.py +42 -0
- Canaille-0.0.1/canaille/forms.py +76 -0
- Canaille-0.0.1/canaille/ldaputils.py +259 -0
- Canaille-0.0.1/canaille/models.py +269 -0
- Canaille-0.0.1/canaille/oauth.py +138 -0
- Canaille-0.0.1/canaille/oauth2utils.py +285 -0
- Canaille-0.0.1/canaille/static/css/base.css +26 -0
- Canaille-0.0.1/canaille/static/datatables/French.json +32 -0
- Canaille-0.0.1/canaille/static/datatables/dataTables.semanticui.min.css +1 -0
- Canaille-0.0.1/canaille/static/datatables/dataTables.semanticui.min.js +12 -0
- Canaille-0.0.1/canaille/static/datatables/jquery.dataTables.min.css +1 -0
- Canaille-0.0.1/canaille/static/datatables/jquery.dataTables.min.js +181 -0
- Canaille-0.0.1/canaille/static/fomanticui/semantic.min.css +404 -0
- Canaille-0.0.1/canaille/static/fomanticui/semantic.min.js +11 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.eot +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.svg +3570 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.ttf +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.woff +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.eot +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.otf +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.svg +4938 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.ttf +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.woff +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/icons.woff2 +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.eot +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.svg +803 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.ttf +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.woff +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
- Canaille-0.0.1/canaille/static/fomanticui/themes/default/assets/images/flags.png +0 -0
- Canaille-0.0.1/canaille/static/jquery/jquery.min.js +2 -0
- Canaille-0.0.1/canaille/static/js/base.js +4 -0
- Canaille-0.0.1/canaille/static/js/users.js +16 -0
- Canaille-0.0.1/canaille/templates/admin/authorization_list.html +33 -0
- Canaille-0.0.1/canaille/templates/admin/authorization_view.html +27 -0
- Canaille-0.0.1/canaille/templates/admin/client_add.html +20 -0
- Canaille-0.0.1/canaille/templates/admin/client_edit.html +37 -0
- Canaille-0.0.1/canaille/templates/admin/client_list.html +35 -0
- Canaille-0.0.1/canaille/templates/admin/token_list.html +33 -0
- Canaille-0.0.1/canaille/templates/admin/token_view.html +27 -0
- Canaille-0.0.1/canaille/templates/authorize.html +33 -0
- Canaille-0.0.1/canaille/templates/base.html +91 -0
- Canaille-0.0.1/canaille/templates/consent_list.html +70 -0
- Canaille-0.0.1/canaille/templates/error.html +13 -0
- Canaille-0.0.1/canaille/templates/fomanticui.j2 +61 -0
- Canaille-0.0.1/canaille/templates/home.html +7 -0
- Canaille-0.0.1/canaille/templates/login.html +41 -0
- Canaille-0.0.1/canaille/templates/profile.html +25 -0
- Canaille-0.0.1/canaille/templates/token_list.html +69 -0
- Canaille-0.0.1/canaille/tokens.py +36 -0
- Canaille-0.0.1/canaille/translations/fr/LC_MESSAGES/messages.mo +0 -0
- Canaille-0.0.1/canaille/translations/fr/LC_MESSAGES/messages.po +340 -0
- Canaille-0.0.1/canaille/translations/messages.pot +328 -0
- Canaille-0.0.1/canaille/well_known.py +17 -0
- Canaille-0.0.1/schemas/oauth2-openldap.ldif +371 -0
- Canaille-0.0.1/schemas/oauth2-openldap.schema +368 -0
- Canaille-0.0.1/setup.cfg +102 -0
- Canaille-0.0.1/setup.py +4 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Canaille
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Simple OAuth2/OpenID Connect server based upon LDAP
|
|
5
|
+
Home-page: https://gitlab.com/yaal/canaille
|
|
6
|
+
Maintainer: Yaal
|
|
7
|
+
Maintainer-email: contact@yaal.fr
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Code, https://gitlab.com/yaal/canaille
|
|
10
|
+
Project-URL: Issue Tracker, https://gitlab.com/yaal/canaille/-/issues
|
|
11
|
+
Description: ⚠ Canaille is under development. Do not use in production yet. ⚠
|
|
12
|
+
|
|
13
|
+
# Canaille
|
|
14
|
+
|
|
15
|
+
Canaille is a French word meaning *rascal*, and is pronounced approximatively **Can I?**,
|
|
16
|
+
as in *Can I access this data please?*. It is a simple OpenID Connect provider based upon OpenLDAP.
|
|
17
|
+
|
|
18
|
+
It aims to be very light, simple to install and simple to maintain. Its main features are :
|
|
19
|
+
- OAuth/OpenID Connect support;
|
|
20
|
+
- Authentication against a LDAP directory;
|
|
21
|
+
- No additional database required. Everything is stored in your OpenLDAP server;
|
|
22
|
+
- The code is easy to read and easy to edit in case you want to write a patch.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
First you need to install the schemas into your LDAP server. There are several ways to achieve this:
|
|
27
|
+
|
|
28
|
+
### LDAP schemas
|
|
29
|
+
|
|
30
|
+
#### Option 1: Add the schema into your filesystem
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
test -d /etc/openldap/schema && sudo cp schema/* /etc/openldap/schema
|
|
34
|
+
test -d /etc/ldap/schema && sudo cp schema/* /etc/ldap/schema
|
|
35
|
+
sudo service slapd restart
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Option 2: Use slapadd
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
sudo slapadd -n0 -l schema/*.ldif
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Web interface
|
|
45
|
+
|
|
46
|
+
Then you can deploy the code either by copying the git repository or installing the pip package:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install canaille
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Finally you have to run the website in a WSGI server:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install gunicorn
|
|
56
|
+
gunicorn "canaille:create_app()"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Contribute
|
|
60
|
+
|
|
61
|
+
Contributions are welcome!
|
|
62
|
+
To run the tests, you just need to run `tox`.
|
|
63
|
+
|
|
64
|
+
To try a development environment, you can run the docker image and then open https://127.0.0.1:5000
|
|
65
|
+
You can then connect with user *admin* and password *admin* to access an admin account, or user *user* and password *user* for a regular one.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cp canaille/conf/config.sample.toml canaille/conf/config.toml
|
|
69
|
+
cp canaille/conf/oauth-authorization-server.sample.json canaille/conf/oauth-authorization-server.json
|
|
70
|
+
cp canaille/conf/openid-configuration.sample.json canaille/conf/openid-configuration.json
|
|
71
|
+
docker-compose up
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Platform: UNKNOWN
|
|
75
|
+
Classifier: Environment :: Web Environment
|
|
76
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
77
|
+
Classifier: Operating System :: OS Independent
|
|
78
|
+
Classifier: Programming Language :: Python
|
|
79
|
+
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory
|
|
80
|
+
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
|
|
81
|
+
Requires-Python: >=3.6
|
|
82
|
+
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
setup.cfg
|
|
5
|
+
setup.py
|
|
6
|
+
Canaille.egg-info/PKG-INFO
|
|
7
|
+
Canaille.egg-info/SOURCES.txt
|
|
8
|
+
Canaille.egg-info/dependency_links.txt
|
|
9
|
+
Canaille.egg-info/requires.txt
|
|
10
|
+
Canaille.egg-info/top_level.txt
|
|
11
|
+
canaille/__init__.py
|
|
12
|
+
canaille/account.py
|
|
13
|
+
canaille/consents.py
|
|
14
|
+
canaille/flaskutils.py
|
|
15
|
+
canaille/forms.py
|
|
16
|
+
canaille/ldaputils.py
|
|
17
|
+
canaille/models.py
|
|
18
|
+
canaille/oauth.py
|
|
19
|
+
canaille/oauth2utils.py
|
|
20
|
+
canaille/tokens.py
|
|
21
|
+
canaille/well_known.py
|
|
22
|
+
canaille/admin/__init__.py
|
|
23
|
+
canaille/admin/authorizations.py
|
|
24
|
+
canaille/admin/clients.py
|
|
25
|
+
canaille/admin/tokens.py
|
|
26
|
+
canaille/conf/config.sample.toml
|
|
27
|
+
canaille/conf/oauth-authorization-server.sample.json
|
|
28
|
+
canaille/conf/openid-configuration.sample.json
|
|
29
|
+
canaille/static/css/base.css
|
|
30
|
+
canaille/static/datatables/French.json
|
|
31
|
+
canaille/static/datatables/dataTables.semanticui.min.css
|
|
32
|
+
canaille/static/datatables/dataTables.semanticui.min.js
|
|
33
|
+
canaille/static/datatables/jquery.dataTables.min.css
|
|
34
|
+
canaille/static/datatables/jquery.dataTables.min.js
|
|
35
|
+
canaille/static/fomanticui/semantic.min.css
|
|
36
|
+
canaille/static/fomanticui/semantic.min.js
|
|
37
|
+
canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.eot
|
|
38
|
+
canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.svg
|
|
39
|
+
canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.ttf
|
|
40
|
+
canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.woff
|
|
41
|
+
canaille/static/fomanticui/themes/default/assets/fonts/brand-icons.woff2
|
|
42
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.eot
|
|
43
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.otf
|
|
44
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.svg
|
|
45
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.ttf
|
|
46
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.woff
|
|
47
|
+
canaille/static/fomanticui/themes/default/assets/fonts/icons.woff2
|
|
48
|
+
canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.eot
|
|
49
|
+
canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.svg
|
|
50
|
+
canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.ttf
|
|
51
|
+
canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.woff
|
|
52
|
+
canaille/static/fomanticui/themes/default/assets/fonts/outline-icons.woff2
|
|
53
|
+
canaille/static/fomanticui/themes/default/assets/images/flags.png
|
|
54
|
+
canaille/static/jquery/jquery.min.js
|
|
55
|
+
canaille/static/js/base.js
|
|
56
|
+
canaille/static/js/users.js
|
|
57
|
+
canaille/templates/authorize.html
|
|
58
|
+
canaille/templates/base.html
|
|
59
|
+
canaille/templates/consent_list.html
|
|
60
|
+
canaille/templates/error.html
|
|
61
|
+
canaille/templates/fomanticui.j2
|
|
62
|
+
canaille/templates/home.html
|
|
63
|
+
canaille/templates/login.html
|
|
64
|
+
canaille/templates/profile.html
|
|
65
|
+
canaille/templates/token_list.html
|
|
66
|
+
canaille/templates/admin/authorization_list.html
|
|
67
|
+
canaille/templates/admin/authorization_view.html
|
|
68
|
+
canaille/templates/admin/client_add.html
|
|
69
|
+
canaille/templates/admin/client_edit.html
|
|
70
|
+
canaille/templates/admin/client_list.html
|
|
71
|
+
canaille/templates/admin/token_list.html
|
|
72
|
+
canaille/templates/admin/token_view.html
|
|
73
|
+
canaille/translations/messages.pot
|
|
74
|
+
canaille/translations/fr/LC_MESSAGES/messages.mo
|
|
75
|
+
canaille/translations/fr/LC_MESSAGES/messages.po
|
|
76
|
+
schemas/oauth2-openldap.ldif
|
|
77
|
+
schemas/oauth2-openldap.schema
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
canaille
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2020 by Yaal
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
Canaille-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Canaille
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Simple OAuth2/OpenID Connect server based upon LDAP
|
|
5
|
+
Home-page: https://gitlab.com/yaal/canaille
|
|
6
|
+
Maintainer: Yaal
|
|
7
|
+
Maintainer-email: contact@yaal.fr
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Code, https://gitlab.com/yaal/canaille
|
|
10
|
+
Project-URL: Issue Tracker, https://gitlab.com/yaal/canaille/-/issues
|
|
11
|
+
Description: ⚠ Canaille is under development. Do not use in production yet. ⚠
|
|
12
|
+
|
|
13
|
+
# Canaille
|
|
14
|
+
|
|
15
|
+
Canaille is a French word meaning *rascal*, and is pronounced approximatively **Can I?**,
|
|
16
|
+
as in *Can I access this data please?*. It is a simple OpenID Connect provider based upon OpenLDAP.
|
|
17
|
+
|
|
18
|
+
It aims to be very light, simple to install and simple to maintain. Its main features are :
|
|
19
|
+
- OAuth/OpenID Connect support;
|
|
20
|
+
- Authentication against a LDAP directory;
|
|
21
|
+
- No additional database required. Everything is stored in your OpenLDAP server;
|
|
22
|
+
- The code is easy to read and easy to edit in case you want to write a patch.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
First you need to install the schemas into your LDAP server. There are several ways to achieve this:
|
|
27
|
+
|
|
28
|
+
### LDAP schemas
|
|
29
|
+
|
|
30
|
+
#### Option 1: Add the schema into your filesystem
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
test -d /etc/openldap/schema && sudo cp schema/* /etc/openldap/schema
|
|
34
|
+
test -d /etc/ldap/schema && sudo cp schema/* /etc/ldap/schema
|
|
35
|
+
sudo service slapd restart
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Option 2: Use slapadd
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
sudo slapadd -n0 -l schema/*.ldif
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Web interface
|
|
45
|
+
|
|
46
|
+
Then you can deploy the code either by copying the git repository or installing the pip package:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install canaille
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Finally you have to run the website in a WSGI server:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install gunicorn
|
|
56
|
+
gunicorn "canaille:create_app()"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Contribute
|
|
60
|
+
|
|
61
|
+
Contributions are welcome!
|
|
62
|
+
To run the tests, you just need to run `tox`.
|
|
63
|
+
|
|
64
|
+
To try a development environment, you can run the docker image and then open https://127.0.0.1:5000
|
|
65
|
+
You can then connect with user *admin* and password *admin* to access an admin account, or user *user* and password *user* for a regular one.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cp canaille/conf/config.sample.toml canaille/conf/config.toml
|
|
69
|
+
cp canaille/conf/oauth-authorization-server.sample.json canaille/conf/oauth-authorization-server.json
|
|
70
|
+
cp canaille/conf/openid-configuration.sample.json canaille/conf/openid-configuration.json
|
|
71
|
+
docker-compose up
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Platform: UNKNOWN
|
|
75
|
+
Classifier: Environment :: Web Environment
|
|
76
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
77
|
+
Classifier: Operating System :: OS Independent
|
|
78
|
+
Classifier: Programming Language :: Python
|
|
79
|
+
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory
|
|
80
|
+
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
|
|
81
|
+
Requires-Python: >=3.6
|
|
82
|
+
Description-Content-Type: text/markdown
|
Canaille-0.0.1/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
⚠ Canaille is under development. Do not use in production yet. ⚠
|
|
2
|
+
|
|
3
|
+
# Canaille
|
|
4
|
+
|
|
5
|
+
Canaille is a French word meaning *rascal*, and is pronounced approximatively **Can I?**,
|
|
6
|
+
as in *Can I access this data please?*. It is a simple OpenID Connect provider based upon OpenLDAP.
|
|
7
|
+
|
|
8
|
+
It aims to be very light, simple to install and simple to maintain. Its main features are :
|
|
9
|
+
- OAuth/OpenID Connect support;
|
|
10
|
+
- Authentication against a LDAP directory;
|
|
11
|
+
- No additional database required. Everything is stored in your OpenLDAP server;
|
|
12
|
+
- The code is easy to read and easy to edit in case you want to write a patch.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
First you need to install the schemas into your LDAP server. There are several ways to achieve this:
|
|
17
|
+
|
|
18
|
+
### LDAP schemas
|
|
19
|
+
|
|
20
|
+
#### Option 1: Add the schema into your filesystem
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
test -d /etc/openldap/schema && sudo cp schema/* /etc/openldap/schema
|
|
24
|
+
test -d /etc/ldap/schema && sudo cp schema/* /etc/ldap/schema
|
|
25
|
+
sudo service slapd restart
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Option 2: Use slapadd
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
sudo slapadd -n0 -l schema/*.ldif
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Web interface
|
|
35
|
+
|
|
36
|
+
Then you can deploy the code either by copying the git repository or installing the pip package:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install canaille
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Finally you have to run the website in a WSGI server:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install gunicorn
|
|
46
|
+
gunicorn "canaille:create_app()"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Contribute
|
|
50
|
+
|
|
51
|
+
Contributions are welcome!
|
|
52
|
+
To run the tests, you just need to run `tox`.
|
|
53
|
+
|
|
54
|
+
To try a development environment, you can run the docker image and then open https://127.0.0.1:5000
|
|
55
|
+
You can then connect with user *admin* and password *admin* to access an admin account, or user *user* and password *user* for a regular one.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
cp canaille/conf/config.sample.toml canaille/conf/config.toml
|
|
59
|
+
cp canaille/conf/oauth-authorization-server.sample.json canaille/conf/oauth-authorization-server.json
|
|
60
|
+
cp canaille/conf/openid-configuration.sample.json canaille/conf/openid-configuration.json
|
|
61
|
+
docker-compose up
|
|
62
|
+
```
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import ldap
|
|
2
|
+
import os
|
|
3
|
+
import toml
|
|
4
|
+
|
|
5
|
+
import canaille.admin
|
|
6
|
+
import canaille.admin.tokens
|
|
7
|
+
import canaille.admin.authorizations
|
|
8
|
+
import canaille.admin.clients
|
|
9
|
+
import canaille.consents
|
|
10
|
+
import canaille.oauth
|
|
11
|
+
import canaille.account
|
|
12
|
+
import canaille.tokens
|
|
13
|
+
import canaille.well_known
|
|
14
|
+
|
|
15
|
+
from cryptography.hazmat.primitives import serialization as crypto_serialization
|
|
16
|
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
17
|
+
from cryptography.hazmat.backends import default_backend as crypto_default_backend
|
|
18
|
+
|
|
19
|
+
from flask import Flask, g, request, render_template
|
|
20
|
+
from flask_babel import Babel
|
|
21
|
+
|
|
22
|
+
from .flaskutils import current_user
|
|
23
|
+
from .ldaputils import LDAPObject
|
|
24
|
+
from .oauth2utils import config_oauth
|
|
25
|
+
from .models import User, Token, AuthorizationCode, Client, Consent
|
|
26
|
+
|
|
27
|
+
try: # pragma: no cover
|
|
28
|
+
import sentry_sdk
|
|
29
|
+
from sentry_sdk.integrations.flask import FlaskIntegration
|
|
30
|
+
|
|
31
|
+
SENTRY = True
|
|
32
|
+
except Exception:
|
|
33
|
+
SENTRY = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def create_app(config=None):
|
|
37
|
+
app = Flask(__name__)
|
|
38
|
+
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
39
|
+
|
|
40
|
+
app.config.from_mapping(
|
|
41
|
+
{
|
|
42
|
+
"SESSION_COOKIE_NAME": "canaille",
|
|
43
|
+
"OAUTH2_REFRESH_TOKEN_GENERATOR": True,
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
if config:
|
|
47
|
+
app.config.from_mapping(config)
|
|
48
|
+
elif "CONFIG" in os.environ:
|
|
49
|
+
app.config.from_mapping(toml.load(os.environ.get("CONFIG")))
|
|
50
|
+
elif os.path.exists(os.path.join(dir_path, "conf", "config.toml")):
|
|
51
|
+
app.config.from_mapping(
|
|
52
|
+
toml.load(os.path.join(dir_path, "conf", "config.toml"))
|
|
53
|
+
)
|
|
54
|
+
else:
|
|
55
|
+
raise Exception(
|
|
56
|
+
"No configuration file found. "
|
|
57
|
+
"Either create conf/config.toml or set the 'CONFIG' variable environment."
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
setup_dev_keypair(app)
|
|
61
|
+
|
|
62
|
+
if not os.path.exists(app.config["JWT"]["PUBLIC_KEY"]) or not os.path.exists(
|
|
63
|
+
app.config["JWT"]["PRIVATE_KEY"]
|
|
64
|
+
):
|
|
65
|
+
raise Exception("Invalid keypair")
|
|
66
|
+
setup_app(app)
|
|
67
|
+
|
|
68
|
+
return app
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def setup_dev_keypair(app):
|
|
72
|
+
if not os.environ.get("FLASK_ENV") == "development":
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
if os.path.exists(app.config["JWT"]["PUBLIC_KEY"]) or os.path.exists(
|
|
76
|
+
app.config["JWT"]["PRIVATE_KEY"]
|
|
77
|
+
):
|
|
78
|
+
return
|
|
79
|
+
|
|
80
|
+
key = rsa.generate_private_key(
|
|
81
|
+
backend=crypto_default_backend(), public_exponent=65537, key_size=2048
|
|
82
|
+
)
|
|
83
|
+
private_key = key.private_bytes(
|
|
84
|
+
crypto_serialization.Encoding.PEM,
|
|
85
|
+
crypto_serialization.PrivateFormat.PKCS8,
|
|
86
|
+
crypto_serialization.NoEncryption(),
|
|
87
|
+
)
|
|
88
|
+
public_key = key.public_key().public_bytes(
|
|
89
|
+
crypto_serialization.Encoding.OpenSSH, crypto_serialization.PublicFormat.OpenSSH
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
with open(app.config["JWT"]["PUBLIC_KEY"], "wb") as fd:
|
|
93
|
+
fd.write(public_key)
|
|
94
|
+
|
|
95
|
+
with open(app.config["JWT"]["PRIVATE_KEY"], "wb") as fd:
|
|
96
|
+
fd.write(private_key)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def setup_ldap_tree(app):
|
|
100
|
+
conn = ldap.initialize(app.config["LDAP"]["URI"])
|
|
101
|
+
conn.simple_bind_s(app.config["LDAP"]["BIND_DN"], app.config["LDAP"]["BIND_PW"])
|
|
102
|
+
Token.initialize(conn)
|
|
103
|
+
AuthorizationCode.initialize(conn)
|
|
104
|
+
Client.initialize(conn)
|
|
105
|
+
Consent.initialize(conn)
|
|
106
|
+
conn.unbind_s()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def setup_app(app):
|
|
110
|
+
if SENTRY and app.config.get("SENTRY_DSN"):
|
|
111
|
+
sentry_sdk.init(dsn=app.config["SENTRY_DSN"], integrations=[FlaskIntegration()])
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
LDAPObject.root_dn = app.config["LDAP"]["ROOT_DN"]
|
|
115
|
+
base = app.config["LDAP"]["USER_BASE"]
|
|
116
|
+
if base.endswith(app.config["LDAP"]["ROOT_DN"]):
|
|
117
|
+
base = base[: -len(app.config["LDAP"]["ROOT_DN"]) - 1]
|
|
118
|
+
User.base = base
|
|
119
|
+
|
|
120
|
+
app.url_map.strict_slashes = False
|
|
121
|
+
|
|
122
|
+
config_oauth(app)
|
|
123
|
+
setup_ldap_tree(app)
|
|
124
|
+
app.register_blueprint(canaille.account.bp)
|
|
125
|
+
app.register_blueprint(canaille.oauth.bp, url_prefix="/oauth")
|
|
126
|
+
app.register_blueprint(canaille.consents.bp, url_prefix="/consent")
|
|
127
|
+
app.register_blueprint(canaille.tokens.bp, url_prefix="/token")
|
|
128
|
+
app.register_blueprint(
|
|
129
|
+
canaille.well_known.bp, url_prefix="/.well-known"
|
|
130
|
+
)
|
|
131
|
+
app.register_blueprint(
|
|
132
|
+
canaille.admin.tokens.bp, url_prefix="/admin/token"
|
|
133
|
+
)
|
|
134
|
+
app.register_blueprint(
|
|
135
|
+
canaille.admin.authorizations.bp, url_prefix="/admin/authorization"
|
|
136
|
+
)
|
|
137
|
+
app.register_blueprint(
|
|
138
|
+
canaille.admin.clients.bp, url_prefix="/admin/client"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
babel = Babel(app)
|
|
142
|
+
|
|
143
|
+
@babel.localeselector
|
|
144
|
+
def get_locale():
|
|
145
|
+
user = getattr(g, "user", None)
|
|
146
|
+
if user is not None:
|
|
147
|
+
return user.locale
|
|
148
|
+
|
|
149
|
+
if app.config.get("LANGUAGE"):
|
|
150
|
+
return app.config.get("LANGUAGE")
|
|
151
|
+
|
|
152
|
+
return request.accept_languages.best_match(["fr_FR", "en_US"])
|
|
153
|
+
|
|
154
|
+
@babel.timezoneselector
|
|
155
|
+
def get_timezone():
|
|
156
|
+
user = getattr(g, "user", None)
|
|
157
|
+
if user is not None:
|
|
158
|
+
return user.timezone
|
|
159
|
+
|
|
160
|
+
@app.before_request
|
|
161
|
+
def before_request():
|
|
162
|
+
g.ldap = ldap.initialize(app.config["LDAP"]["URI"])
|
|
163
|
+
g.ldap.simple_bind_s(
|
|
164
|
+
app.config["LDAP"]["BIND_DN"], app.config["LDAP"]["BIND_PW"]
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
@app.after_request
|
|
168
|
+
def after_request(response):
|
|
169
|
+
if "ldap" in g:
|
|
170
|
+
g.ldap.unbind_s()
|
|
171
|
+
return response
|
|
172
|
+
|
|
173
|
+
@app.context_processor
|
|
174
|
+
def global_processor():
|
|
175
|
+
return {
|
|
176
|
+
"logo_url": app.config.get("LOGO"),
|
|
177
|
+
"website_name": app.config.get("NAME"),
|
|
178
|
+
"user": current_user(),
|
|
179
|
+
"menu": True,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@app.errorhandler(403)
|
|
183
|
+
def unauthorized(e):
|
|
184
|
+
return render_template("error.html", error=403), 403
|
|
185
|
+
|
|
186
|
+
@app.errorhandler(404)
|
|
187
|
+
def page_not_found(e):
|
|
188
|
+
return render_template("error.html", error=404), 404
|
|
189
|
+
|
|
190
|
+
@app.errorhandler(500)
|
|
191
|
+
def server_error(e):
|
|
192
|
+
return render_template("error.html", error=500), 500
|
|
193
|
+
|
|
194
|
+
except Exception as exc:
|
|
195
|
+
if SENTRY and app.config.get("SENTRY_DSN"):
|
|
196
|
+
sentry_sdk.capture_exception(exc)
|
|
197
|
+
raise
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from flask import Blueprint, request, flash, url_for, current_app
|
|
2
|
+
from flask import render_template, redirect
|
|
3
|
+
from flask_babel import gettext
|
|
4
|
+
|
|
5
|
+
from .forms import LoginForm, ProfileForm
|
|
6
|
+
from .flaskutils import current_user, user_needed
|
|
7
|
+
from .models import User
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
bp = Blueprint(__name__, "home")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@bp.route("/")
|
|
14
|
+
def index():
|
|
15
|
+
if not current_user():
|
|
16
|
+
return redirect(url_for("canaille.account.login"))
|
|
17
|
+
return redirect(url_for("canaille.account.profile"))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@bp.route("/login", methods=("GET", "POST"))
|
|
21
|
+
def login():
|
|
22
|
+
form = LoginForm(request.form or None)
|
|
23
|
+
|
|
24
|
+
if request.form:
|
|
25
|
+
if not form.validate() or not User.authenticate(
|
|
26
|
+
form.login.data, form.password.data, True
|
|
27
|
+
):
|
|
28
|
+
flash(gettext("Login failed, please check your information"), "error")
|
|
29
|
+
return render_template("login.html", form=form)
|
|
30
|
+
|
|
31
|
+
return redirect(url_for("canaille.account.index"))
|
|
32
|
+
|
|
33
|
+
return render_template("login.html", form=form)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@bp.route("/logout")
|
|
37
|
+
def logout():
|
|
38
|
+
if current_user():
|
|
39
|
+
current_user().logout()
|
|
40
|
+
return redirect("/")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@bp.route("/profile", methods=("GET", "POST"))
|
|
44
|
+
@user_needed()
|
|
45
|
+
def profile(user):
|
|
46
|
+
claims = current_app.config["JWT"]["MAPPING"]
|
|
47
|
+
data = {
|
|
48
|
+
k.lower(): getattr(user, v)[0]
|
|
49
|
+
if getattr(user, v) and isinstance(getattr(user, v), list)
|
|
50
|
+
else getattr(user, v) or ""
|
|
51
|
+
for k, v in claims.items()
|
|
52
|
+
}
|
|
53
|
+
form = ProfileForm(request.form or None, data=data)
|
|
54
|
+
|
|
55
|
+
if request.form:
|
|
56
|
+
if not form.validate():
|
|
57
|
+
flash(gettext("Profile edition failed."), "error")
|
|
58
|
+
|
|
59
|
+
else:
|
|
60
|
+
for attribute in form:
|
|
61
|
+
model_attribute_name = claims.get(attribute.name.upper())
|
|
62
|
+
if not model_attribute_name or not hasattr(user, model_attribute_name):
|
|
63
|
+
continue
|
|
64
|
+
|
|
65
|
+
user[model_attribute_name] = [attribute.data]
|
|
66
|
+
|
|
67
|
+
if not form.password1.data or user.set_password(form.password1.data):
|
|
68
|
+
flash(gettext("Profile updated successfuly."), "success")
|
|
69
|
+
|
|
70
|
+
user.save()
|
|
71
|
+
|
|
72
|
+
return render_template("profile.html", form=form, menuitem="profile")
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from flask import Blueprint, render_template
|
|
2
|
+
from canaille.models import AuthorizationCode
|
|
3
|
+
from canaille.flaskutils import admin_needed
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
bp = Blueprint(__name__, "authorizations")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@bp.route("/")
|
|
10
|
+
@admin_needed()
|
|
11
|
+
def index():
|
|
12
|
+
authorizations = AuthorizationCode.filter()
|
|
13
|
+
return render_template(
|
|
14
|
+
"admin/authorization_list.html", authorizations=authorizations
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@bp.route("/<authorization_id>", methods=["GET", "POST"])
|
|
19
|
+
@admin_needed()
|
|
20
|
+
def view(authorization_id):
|
|
21
|
+
authorization = AuthorizationCode.get(authorization_id)
|
|
22
|
+
return render_template(
|
|
23
|
+
"admin/authorization_view.html", authorization=authorization, menuitem="admin"
|
|
24
|
+
)
|