Révision 9136aa1f
Ajouté par Serghei Mihai (congés, retour 15/05) il y a plus de 9 ans
usr/local/univnautes/sp/sp/management/commands/update-metadatas.py | ||
---|---|---|
98 | 98 |
federations = pfconfigxml.get_federations() |
99 | 99 |
for federation in federations: |
100 | 100 |
url = federation.get('url') |
101 |
metadata = federation.get('metadata') |
|
101 | 102 |
codename = federation.get('codename') |
102 | 103 |
descr = federation.get('descr') |
103 | 104 |
signcert = federation.get('signcert') |
104 |
try: |
|
105 |
print 'download federation %s metadata from %s' % (str(codename), str(url)) |
|
106 |
store_metadata(codename, urllib2.urlopen(url)) |
|
107 |
except urllib2.HTTPError as e: |
|
108 |
print 'Error loading metadata (%s)' % str(e) |
|
109 |
except urllib2.URLError as e: |
|
110 |
print 'Error loading metadata (%s)' % str(e) |
|
105 |
|
|
106 |
if not metadata: |
|
107 |
try: |
|
108 |
print 'download federation %s metadata from %s' % (str(codename), str(url)) |
|
109 |
metadata = urllib2.urlopen(url) |
|
110 |
except urllib2.HTTPError as e: |
|
111 |
print 'Error loading metadata (%s)' % str(e) |
|
112 |
except urllib2.URLError as e: |
|
113 |
print 'Error loading metadata (%s)' % str(e) |
|
111 | 114 |
else: |
112 |
if verify_metadata(codename, signcert): |
|
113 |
actives.add(codename) |
|
114 |
call_command('sync-metadata', metadata_filename(codename), source=codename, idp=True) |
|
115 |
print "using metadata provided metadata file for %s" % str(codename) |
|
116 |
|
|
117 |
store_metadata(codename, metadata) |
|
118 |
if verify_metadata(codename, signcert): |
|
119 |
actives.add(codename) |
|
120 |
call_command('sync-metadata', metadata_filename(codename), source=codename, idp=True) |
|
115 | 121 |
|
116 | 122 |
present_in_filesystem = set(os.listdir(METADATAS_DIR)) |
117 | 123 |
for codename in present_in_filesystem - actives: |
usr/local/univnautes/sp/sp/pfconfigxml.py | ||
---|---|---|
20 | 20 |
import re |
21 | 21 |
import xml.etree.ElementTree as ET |
22 | 22 |
from operator import itemgetter |
23 |
from base64 import b64decode |
|
23 | 24 |
|
24 | 25 |
from django.conf import settings |
25 | 26 |
|
... | ... | |
165 | 166 |
<refid>fed_53d1161955a26</refid> |
166 | 167 |
<descr><![CDATA[Renater TEST Federation]]></descr> |
167 | 168 |
<url>https://federation.renater.fr/test/renater-test-metadata.xml</url> |
169 |
<metadata>[base64 encoded metadata]</metadata> |
|
168 | 170 |
<certref>53d115fac567b</certref> |
169 | 171 |
</federation> |
170 | 172 |
""" |
... | ... | |
182 | 184 |
url = xml_federation.find('url') |
183 | 185 |
if url is not None: |
184 | 186 |
url = url.text |
187 |
metadata = xml_federation.find('metadata') |
|
188 |
if metadata is not None: |
|
189 |
try: |
|
190 |
metadata = b64decode(metadata.text) |
|
191 |
except: |
|
192 |
metadata = None |
|
185 | 193 |
descr = xml_federation.find('descr') |
186 | 194 |
if descr is not None: |
187 | 195 |
descr = descr.text |
... | ... | |
193 | 201 |
federations.append({ |
194 | 202 |
'codename': codename, |
195 | 203 |
'url': url, |
204 |
'metadata': metadata, |
|
196 | 205 |
'signcert': signcert, |
197 | 206 |
'descr': descr, |
198 | 207 |
}) |
usr/local/www/services_captiveportal_saml_federation.php | ||
---|---|---|
106 | 106 |
$pconfig['codename'] = $a_federation[$id]['codename']; |
107 | 107 |
$pconfig['descr'] = $a_federation[$id]['descr']; |
108 | 108 |
$pconfig['url'] = $a_federation[$id]['url']; |
109 |
$pconfig['metadata'] = base64_decode($a_federation[$id]['metadata']); |
|
109 | 110 |
$pconfig['certref'] = $a_federation[$id]['certref']; |
110 | 111 |
} |
111 | 112 |
|
... | ... | |
120 | 121 |
$pconfig = $_POST; |
121 | 122 |
|
122 | 123 |
/* input validation */ |
123 |
$reqdfields = explode(" ", "codename descr url certref");
|
|
124 |
$reqdfields = explode(" ", "codename descr certref"); |
|
124 | 125 |
$reqdfieldsn = array( |
125 | 126 |
gettext("Codename"), |
126 | 127 |
gettext("Description"), |
127 |
gettext("URL"), |
|
128 | 128 |
gettext("Metadata Certificate"), |
129 | 129 |
gettext("HTTPS CA Certificate")); |
130 | 130 |
|
... | ... | |
140 | 140 |
$input_errors[] = gettext("The codename can only contain letters, digits, and underscores (_)."); |
141 | 141 |
} |
142 | 142 |
|
143 |
|
|
144 |
if(!$_POST['metadata'] && $_POST['url'] && !is_URL($_POST['url'])) { |
|
145 |
$input_errors[] = sprintf(gettext("The metadata URL must be a valid url."), $_POST['url']); |
|
146 |
} elseif(!($_POST['metadata'] || $_POST['url'])) { |
|
147 |
$input_errors[] = sprintf(gettext("Metadata URL or content must provided."), $_POST['metadata']); |
|
148 |
} |
|
149 |
|
|
143 | 150 |
/* save modifications */ |
144 | 151 |
if (!$input_errors) { |
145 | 152 |
|
... | ... | |
155 | 162 |
$federation['codename'] = $pconfig['codename']; |
156 | 163 |
$federation['descr'] = $pconfig['descr']; |
157 | 164 |
$federation['url'] = $pconfig['url']; |
165 |
$federation['metadata'] = base64_encode($pconfig['metadata']); |
|
158 | 166 |
$federation['certref'] = $pconfig['certref']; |
159 | 167 |
|
160 | 168 |
if ($_POST['enable']) |
... | ... | |
251 | 259 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Metadata URL");?></td> |
252 | 260 |
<td width="78%" class="vtable"> |
253 | 261 |
<input name="url" type="text" class="formfld url" id="url" size="65" value="<?=htmlspecialchars($pconfig['url']);?>" placeholder="https://..." /> |
254 |
<br/><?=gettext("");?> |
|
262 |
<br/><?=gettext("or");?> |
|
263 |
</td> |
|
264 |
</tr> |
|
265 |
<tr> |
|
266 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Metadata file content");?></td> |
|
267 |
<td width="78%" class="vtable"> |
|
268 |
<textarea name="metadata" class="formpre" cols="75" rows="20"><?=htmlspecialchars($pconfig['metadata']);?></textarea> |
|
255 | 269 |
</td> |
256 | 270 |
</tr> |
257 | 271 |
<tr> |
Formats disponibles : Unified diff
federation's metadata raw content can be added
Closes #5568