Skip to content

Commit

Permalink
Import: support "Authorization" header as well
Browse files Browse the repository at this point in the history
This is used (for example) by pretalx to access the schedule if it is set
to not be available publicly.

This fixes crs-tools#255
  • Loading branch information
Kunsi committed Oct 19, 2024
1 parent a1757f5 commit 244893d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/Application/Controller/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,16 @@ private static function _getXML(array $import) {
(isset($import['auth_password']))? $import['auth_password'] : ''
);
break;
case 'header':
case 'header_authentication':
$client->addHeader(
'Authentication',
(isset($import['auth_header']))? $import['auth_header'] : ''
(isset($import['auth_header_authentication']))? $import['auth_header_authentication'] : ''
);
break;
case 'header_authorization':
$client->addHeader(
'Authorization',
(isset($import['auth_header_authorization']))? $import['auth_header_authorization'] : ''
);
break;
}
Expand Down Expand Up @@ -515,4 +521,4 @@ private static function _calculateDate(SimpleXMLElement $event, $dayChange) {
}
}

?>
?>
6 changes: 4 additions & 2 deletions src/Application/View/import/index.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
[
'' => 'No Authentication',
'basic' => 'Basic HTTP Authentication',
'header' => 'Authentication Header'
'header_authentication' => 'Authentication Header'
'header_authorization' => 'Authorization Header'
],
'',
['data-import-auth-type-value']
); ?>
</li>
<li><?= $f->input('auth_user', 'Username', '', ['data-import-auth-type' => 'basic']); ?></li>
<li><?= $f->password('auth_password', 'Password', ['data-import-auth-type' => 'basic']); ?></li>
<li><?= $f->input('auth_header', 'Authentication Header', '', ['class' => 'wide', 'data-import-auth-type' => 'header']); ?></li>
<li><?= $f->input('auth_header_authentication', 'Authentication Header', '', ['class' => 'wide', 'data-import-auth-type' => 'header_authentication']); ?></li>
<li><?= $f->input('auth_header_authorization', 'Authorization Header', '', ['class' => 'wide', 'data-import-auth-type' => 'header_authorization']); ?></li>
<li><?= $f->submit('Create new import', ['disabled' => $project['read_only']]); ?></li>
</ul>
</fieldset>
Expand Down

0 comments on commit 244893d

Please sign in to comment.