Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CO-2883_FederationSource_plugin_does_not_meet_the_draft-young-md-query-22_get_all_entities_requirements #678

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<constraint>REFERENCES cm_servers(id)</constraint>
</field>
<field name="protocol" type="C" size="2" />
<field name="entities" type="C" size="2" />
<field name="created" type="T" />
<field name="modified" type="T" />

Expand Down
5 changes: 5 additions & 0 deletions app/AvailablePlugin/FederationSource/Lib/enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ class MetadataProtocol
const File = "F";
const MDQ = "MQ";
}

class MdqProtocol
{
const IdpsOnly = "IO";
}
8 changes: 7 additions & 1 deletion app/AvailablePlugin/FederationSource/Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@
MetadataProtocol::MDQ => "MDQ"
),

// Enumeration language texts
'pl.federationsource.en.entities' => array(
MdqProtocol::IdpsOnly => 'Idps Only',
),

// Error messages
'er.federationsource.notfound.entityid' => 'entityID not found in metadata response',

// Plugin texts
'pl.federationsource.count' => 'Populated %1$s records from all IdPs endpoint',
'pl.federationsource.entityid' => 'Entity ID',
'pl.federationsource.protocol' => 'Protocol'
'pl.federationsource.protocol' => 'Protocol',
'pl.federationsource.entities' => 'Entities Filtering'
);
21 changes: 14 additions & 7 deletions app/AvailablePlugin/FederationSource/Model/FederationSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class FederationSource extends OrganizationSourceBackend {
MetadataProtocol::MDQ)),
'required' => true,
'allowEmpty' => false
),
'entities' => array(
'rule' => array('inList',
array(MdqProtocol::IdpsOnly)),
'required' => false,
'allowEmpty' => true
)
);

Expand Down Expand Up @@ -107,22 +113,23 @@ protected function doRequest($entityID=null) {

$Http->setBaseUrl($srvr['HttpServer']['serverurl']);

if($cfg['FederationSource']['protocol'] == MetadataProtocol::MDQ) {
$url = '';
if($cfg['FederationSource']['protocol'] === MetadataProtocol::MDQ) {
$Http->setRequestOptions(array(
'header' => array(
'Content-Type' => 'application/samlmetadata+xml'
)
));

$url = "/entities/";
// CO-2883
// https://datatracker.ietf.org/doc/html/draft-young-md-query-22#name-request-all-entities
$url = '/entities';

if($entityID) {
$url .= urlencode($entityID);
} else {
$url .= "idps/all";
$url .= '/' . urlencode($entityID);
} elseif($cfg['FederationSource']['entities'] === MdqProtocol::IdpsOnly) {
$url .= '/idps/all';
}
} else {
$url = "";
}

return $Http->get($url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@

print $this->Form->hidden('organization_source_id', array('default' => $vv_osid)) . "\n";
?>
<script type="text/javascript">
function fields_update_entities(self) {
const mdq = '<?= MetadataProtocol::MDQ?>'
const mode = ($(self).find(":checked").val())
if (mode === mdq) {
$('#mdq-entities-selector').show()
} else {
$('#mdq-entities-selector').hide()
}
}
</script>

<?php if(empty($vv_servers)): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
Expand Down Expand Up @@ -110,8 +122,9 @@
global $cm_lang, $cm_texts;

$attrs = array();
$attrs['value'] = (isset($federation_sources[0]['FederationSource']['protocol']) ? $federation_sources[0]['FederationSource']['protocol'] : "");
$attrs['value'] = ($federation_sources[0]['FederationSource']['protocol'] ?? '');
$attrs['empty'] = true;
$attrs['onchange'] = 'fields_update_entities(this)';

if($e) {
print $this->Form->select('protocol',
Expand All @@ -127,6 +140,36 @@
?>
</div>
</li>
<?php if(!empty($federation_sources[0]['FederationSource']['protocol']) && $federation_sources[0]['FederationSource']['protocol'] === MetadataProtocol::MDQ): ?>
<li id="mdq-entities-selector">
<div class="field-name">
<div class="field-title">
<?php print ($e ? $this->Form->label('entities', _txt('pl.federationsource.entities')) : _txt('pl.federationsource.entities')); ?>
</div>
</div>
<div class="field-info">
<?php
global $cm_lang, $cm_texts;

$attrs = array();
$attrs['value'] = ($federation_sources[0]['FederationSource']['entities'] ?? '');
$attrs['empty'] = true;

if($e) {
print $this->Form->select('entities',
$cm_texts[ $cm_lang ]['pl.federationsource.en.entities'],
$attrs);

if($this->Form->isFieldError('entities')) {
print $this->Form->error('entities');
}
} else {
print _txt('pl.federationsource.en.entities', null, filter_var($federation_sources[0]['FederationSource']['entities'],FILTER_SANITIZE_SPECIAL_CHARS));
}
?>
</div>
</li>
<?php endif; ?>
<?php if($e): ?>
<li class="fields-submit">
<div class="field-name">
Expand Down