0001-franceconnect_data-add-a-hash-of-the-identite_pivot-.patch
passerelle/apps/franceconnect_data/fc.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import base64 |
18 |
import hashlib |
|
18 | 19 |
import json |
19 | 20 |
import urllib.parse |
20 | 21 |
import uuid |
... | ... | |
113 | 114 |
platform.user_info_endpoint_url, |
114 | 115 |
headers={'Authorization': 'Bearer %s' % self.fc_access_token}, |
115 | 116 |
) |
117 |
fc_user_info['identite_pivot_sha256'] = self.make_identite_pivot_sha256(fc_user_info) |
|
116 | 118 |
self.add('fc_user_info', fc_user_info) |
117 | 119 | |
120 |
def make_identite_pivot_sha256(self, user_info): |
|
121 |
parts = [] |
|
122 |
for key in ['given_name', 'family_name', 'birthdate', 'gender', 'birthplace', 'birthcountry']: |
|
123 |
parts.append('%s=%s' % (key, user_info.get(key) or '')) |
|
124 |
data = '\n'.join(parts) |
|
125 |
return hashlib.sha256(data.encode()).hexdigest().lower() |
|
126 | ||
118 | 127 |
def request_dgfip_access_token(self, dgfip_username, dgfip_password, scope=None): |
119 | 128 |
data = { |
120 | 129 |
'grant_type': 'client_credentials', |
tests/test_franceconnect_data.py | ||
---|---|---|
85 | 85 |
'gender': 'male', |
86 | 86 |
'given_name': 'John', |
87 | 87 |
'sub': 'sub-1234', |
88 |
'identite_pivot_sha256': 'c4d239de7e2abc4782039091437bcc9ad963ec93b40ffe6beac6600c36f3635b', |
|
88 | 89 |
}, |
89 | 90 |
'id': None, |
90 | 91 |
'text': 'John Doe né le April 28, 2001', |
91 |
- |