0002-improve-code-style-32866.patch
setup.py | ||
---|---|---|
76 | 76 |
if os.path.exists('VERSION'): |
77 | 77 |
os.remove('VERSION') |
78 | 78 | |
79 | ||
79 | 80 |
class install_lib(_install_lib): |
80 | 81 |
def run(self): |
81 | 82 |
self.run_command('compile_translations') |
82 | 83 |
_install_lib.run(self) |
83 | 84 | |
85 | ||
84 | 86 |
def get_version(): |
85 | 87 |
'''Use the VERSION, if absent generates a version with git describe, if not |
86 |
tag exists, take 0.0.0- and add the length of the commit log.
|
|
88 |
tag exists, take 0.0- and add the length of the commit log. |
|
87 | 89 |
''' |
88 | 90 |
if os.path.exists('VERSION'): |
89 | 91 |
with open('VERSION', 'r') as v: |
90 | 92 |
return v.read() |
91 | 93 |
if os.path.exists('.git'): |
92 |
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
|
93 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
94 |
p = subprocess.Popen(['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
|
95 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
94 | 96 |
result = p.communicate()[0] |
95 | 97 |
if p.returncode == 0: |
96 |
return result.split()[0][1:].replace('-', '.') |
|
98 |
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v |
|
99 |
if '-' in result: # not a tagged version |
|
100 |
real_number, commit_count, commit_hash = result.split('-', 2) |
|
101 |
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash) |
|
102 |
else: |
|
103 |
version = result |
|
104 |
return version |
|
97 | 105 |
else: |
98 |
return '0.0.0-%s' % len(
|
|
99 |
subprocess.check_output(
|
|
100 |
['git', 'rev-list', 'HEAD']).splitlines())
|
|
101 |
return '0.0.0'
|
|
106 |
return '0.0.post%s' % len(
|
|
107 |
subprocess.check_output( |
|
108 |
['git', 'rev-list', 'HEAD']).splitlines()) |
|
109 |
return '0.0' |
|
102 | 110 | |
103 | 111 |
README = file(os.path.join( |
104 | 112 |
os.path.dirname(__file__), |
105 | 113 |
'README')).read() |
106 | 114 | |
107 |
setup(name='authentic2-auth-fc', |
|
108 |
version=get_version(), |
|
109 |
license='AGPLv3', |
|
110 |
description='Authentic2 FranceConnect plugin', |
|
111 |
long_description=README, |
|
112 |
author="Entr'ouvert", |
|
113 |
url='https://repos.entrouvert.org/authentic2-auth-fc.git', |
|
114 |
author_email="info@entrouvert.com", |
|
115 |
packages=find_packages('src'), |
|
116 |
package_dir={ |
|
117 |
'': 'src', |
|
118 |
}, |
|
119 |
package_data={ |
|
120 |
'authentic2_auth_fc': [ |
|
121 |
'templates/authentic2_auth_fc/*.html', |
|
122 |
'static/authentic2_auth_fc/css/*.css', |
|
123 |
'static/authentic2_auth_fc/js/*.js', |
|
124 |
'static/authentic2_auth_fc/img/*.png', |
|
125 |
'static/authentic2_auth_fc/img/*.svg', |
|
126 |
'locale/fr/LC_MESSAGES/django.po', |
|
127 |
'locale/fr/LC_MESSAGES/django.mo', |
|
128 |
'*.json', |
|
129 |
], |
|
130 |
}, |
|
131 |
install_requires=[ |
|
132 |
'authentic2', |
|
133 |
'requests>2.11', |
|
134 |
'requests-oauthlib', |
|
115 |
setup( |
|
116 |
name='authentic2-auth-fc', |
|
117 |
version=get_version(), |
|
118 |
license='AGPLv3', |
|
119 |
description='Authentic2 FranceConnect plugin', |
|
120 |
long_description=README, |
|
121 |
author="Entr'ouvert", |
|
122 |
url='https://repos.entrouvert.org/authentic2-auth-fc.git', |
|
123 |
author_email="info@entrouvert.com", |
|
124 |
packages=find_packages('src'), |
|
125 |
package_dir={ |
|
126 |
'': 'src', |
|
127 |
}, |
|
128 |
package_data={ |
|
129 |
'authentic2_auth_fc': [ |
|
130 |
'templates/authentic2_auth_fc/*.html', |
|
131 |
'static/authentic2_auth_fc/css/*.css', |
|
132 |
'static/authentic2_auth_fc/js/*.js', |
|
133 |
'static/authentic2_auth_fc/img/*.png', |
|
134 |
'static/authentic2_auth_fc/img/*.svg', |
|
135 |
'locale/fr/LC_MESSAGES/django.po', |
|
136 |
'locale/fr/LC_MESSAGES/django.mo', |
|
137 |
'*.json', |
|
138 |
], |
|
139 |
}, |
|
140 |
install_requires=[ |
|
141 |
'authentic2', |
|
142 |
'requests>2.11', |
|
143 |
'requests-oauthlib', |
|
144 |
], |
|
145 |
entry_points={ |
|
146 |
'authentic2.plugin': [ |
|
147 |
'authentic2-auth-fc = authentic2_auth_fc:Plugin', |
|
135 | 148 |
], |
136 |
entry_points={ |
|
137 |
'authentic2.plugin': [ |
|
138 |
'authentic2-auth-fc = authentic2_auth_fc:Plugin', |
|
139 |
], |
|
140 |
}, |
|
141 |
cmdclass={ |
|
142 |
'build': build, |
|
143 |
'install_lib': install_lib, |
|
144 |
'compile_translations': compile_translations, |
|
145 |
'sdist': eo_sdist}, |
|
146 |
zip_safe=False, |
|
149 |
}, |
|
150 |
cmdclass={ |
|
151 |
'build': build, |
|
152 |
'install_lib': install_lib, |
|
153 |
'compile_translations': compile_translations, |
|
154 |
'sdist': eo_sdist}, |
|
155 |
zip_safe=False, |
|
147 | 156 |
) |
src/authentic2_auth_fc/models.py | ||
---|---|---|
30 | 30 |
from . import app_settings |
31 | 31 | |
32 | 32 | |
33 |
def base64url_decode(input):
|
|
34 |
rem = len(input) % 4
|
|
33 |
def base64url_decode(encoded):
|
|
34 |
rem = len(encoded) % 4
|
|
35 | 35 |
if rem > 0: |
36 |
input += b'=' * (4 - rem)
|
|
37 |
return base64.urlsafe_b64decode(input)
|
|
36 |
encoded += b'=' * (4 - rem)
|
|
37 |
return base64.urlsafe_b64decode(encoded)
|
|
38 | 38 | |
39 | 39 | |
40 | 40 |
def parse_id_token(id_token, client_id=None, client_secret=None): |
tests/settings.py | ||
---|---|---|
1 |
# authentic2-auth-fc - authentic2 authentication for FranceConnect |
|
2 |
# Copyright (C) 2019 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
1 | 17 |
import os |
2 | 18 | |
3 | 19 |
LANGUAGE_CODE = 'en' |
tests/test_api.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 |
# authentic2-auth-fc - authentic2 authentication for FranceConnect |
|
3 |
# Copyright (C) 2019 Entr'ouvert |
|
4 |
# |
|
5 |
# This program is free software: you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU Affero General Public License as published |
|
7 |
# by the Free Software Foundation, either version 3 of the License, or |
|
8 |
# (at your option) any later version. |
|
9 |
# |
|
10 |
# This program is distributed in the hope that it will be useful, |
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
# GNU Affero General Public License for more details. |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU Affero General Public License |
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 | ||
2 | 18 |
from authentic2_auth_fc.models import FcAccount |
3 | 19 | |
4 | 20 |
tests/test_auth_fc.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 |
# authentic2-auth-fc - authentic2 authentication for FranceConnect |
|
3 |
# Copyright (C) 2019 Entr'ouvert |
|
4 |
# |
|
5 |
# This program is free software: you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU Affero General Public License as published |
|
7 |
# by the Free Software Foundation, either version 3 of the License, or |
|
8 |
# (at your option) any later version. |
|
9 |
# |
|
10 |
# This program is distributed in the hope that it will be useful, |
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
# GNU Affero General Public License for more details. |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU Affero General Public License |
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 | ||
2 | 18 |
import pytest |
3 | 19 |
import re |
4 | 20 |
import urlparse |
5 |
- |