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

Hardening #71

Merged
merged 3 commits into from
Aug 2, 2017
Merged
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
2 changes: 1 addition & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function __construct($AppName, IRequest $request,
* @return TemplateResponse The authorize view or the
* authorize-error view with a redirection to the
* default page URL.
*
* @NoAdminRequired
* @NoCSRFRequired
*/
Expand Down Expand Up @@ -179,7 +180,6 @@ public function authorize($response_type, $client_id, $redirect_uri,
* default page URL.
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function generateAuthorizationCode($response_type, $client_id, $redirect_uri, $state = null) {
if (!is_string($response_type) || !is_string($client_id)
Expand Down
16 changes: 5 additions & 11 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public function __construct($AppName, IRequest $request,
* Adds a client.
*
* @return RedirectResponse Redirection to the settings page.
*
* @NoCSRFRequired
*/
public function addClient() {
if (!isset($_POST['redirect_uri']) || !isset($_POST['name'])) {
Expand Down Expand Up @@ -139,8 +137,6 @@ public function addClient() {
* @param int $id The client identifier.
*
* @return RedirectResponse Redirection to the settings page.
*
* @NoCSRFRequired
*/
public function deleteClient($id) {
if (!is_int($id)) {
Expand Down Expand Up @@ -173,25 +169,23 @@ public function deleteClient($id) {
* Revokes the authorization for a client.
*
* @param int $id The client identifier.
* @param string $user_id The ID of the user logged in.
*
* @return RedirectResponse Redirection to the settings page.
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function revokeAuthorization($id, $user_id) {
if (!is_int($id) || !is_string($user_id)) {
public function revokeAuthorization($id) {
if (!is_int($id)) {
return new RedirectResponse(
$this->urlGenerator->linkToRouteAbsolute(
'settings.SettingsPage.getPersonal',
['sectionid' => 'security']
) . '#oauth2');
}

$this->authorizationCodeMapper->deleteByClientUser($id, $user_id);
$this->accessTokenMapper->deleteByClientUser($id, $user_id);
$this->refreshTokenMapper->deleteByClientUser($id, $user_id);
$this->authorizationCodeMapper->deleteByClientUser($id, $this->userId);
$this->accessTokenMapper->deleteByClientUser($id, $this->userId);
$this->refreshTokenMapper->deleteByClientUser($id, $this->userId);

return new RedirectResponse(
$this->urlGenerator->linkToRouteAbsolute(
Expand Down
1 change: 1 addition & 0 deletions templates/authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<br>
<p><?php p($l->t('The application will gain access to your username and will be allowed to manage files, folders and shares.')); ?></p>
<br>
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<button type="submit"><?php p($l->t('Authorize')); ?></button>
</form>
</span>
2 changes: 2 additions & 0 deletions templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<td id="td-allow-subdomains"><?php if ($client->getAllowSubdomains()) {?> <img alt="" src="/core/img/actions/checkmark.svg"> <?php } ?></td>
<td>
<form id="form-inline" class="delete" data-confirm="<?php p($l->t('Are you sure you want to delete this item?')); ?>" action="<?php p($_['urlGenerator']->linkToRoute('oauth2.settings.deleteClient', ['id' => $client->getId()])); ?>" method="post">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="submit" class="button icon-delete" value="">
</form>
</td>
Expand All @@ -67,6 +68,7 @@
<input id="redirect_uri" name="redirect_uri" type="text" placeholder="<?php p($l->t('Redirection URI')); ?>">
<input type="checkbox" class="checkbox" name="allow_subdomains" id="allow_subdomains" value="1"/>
<label for="allow_subdomains"><?php p($l->t('Allow subdomains'));?></label>
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="submit" class="button" value="<?php p($l->t('Add')); ?>">
</form>
</div>
3 changes: 2 additions & 1 deletion templates/settings-personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
<tr>
<td><?php p($client->getName()); ?></td>
<td>
<form id="form-inline" class="delete" data-confirm="<?php p($l->t('Are you sure you want to delete this item?')); ?>" action="<?php p($_['urlGenerator']->linkToRoute('oauth2.settings.revokeAuthorization', ['id' => $client->getId()])); ?>?user_id=<?php p($_['user_id']); ?>" method="post">
<form id="form-inline" class="delete" data-confirm="<?php p($l->t('Are you sure you want to delete this item?')); ?>" action="<?php p($_['urlGenerator']->linkToRoute('oauth2.settings.revokeAuthorization', ['id' => $client->getId()])); ?>" method="post">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="submit" class="button icon-delete" value="">
</form>
</td>
Expand Down