Plugin: LTI: Fix lineitem.readonly scope in AGS

pull/4364/head
Angel Fernando Quiroz Campos 3 years ago
parent e695cb1118
commit 7a6266b72c
  1. 14
      plugin/ims_lti/auth.php
  2. 8
      plugin/ims_lti/src/Service/Resource/LtiLineItemResource.php
  3. 4
      plugin/ims_lti/src/Service/Resource/LtiLineItemsResource.php

@ -207,14 +207,20 @@ try {
if (LtiAssignmentGradesService::AGS_NONE !== $advServices['ags']) { if (LtiAssignmentGradesService::AGS_NONE !== $advServices['ags']) {
$agsClaim = [ $agsClaim = [
'scope' => [ 'scope' => [
LtiAssignmentGradesService::SCOPE_LINE_ITEM,
LtiAssignmentGradesService::SCOPE_LINE_ITEM_READ, LtiAssignmentGradesService::SCOPE_LINE_ITEM_READ,
LtiAssignmentGradesService::SCOPE_RESULT_READ,
LtiAssignmentGradesService::SCOPE_SCORE_WRITE,
], ],
'lineitems' => LtiAssignmentGradesService::getLineItemsUrl( ];
if (LtiAssignmentGradesService::AGS_FULL === $advServices['ags']) {
$agsClaim['scope'][] = LtiAssignmentGradesService::SCOPE_LINE_ITEM;
}
$agsClaim['lineitems'] = LtiAssignmentGradesService::getLineItemsUrl(
$course->getId(), $course->getId(),
$tool->getId() $tool->getId()
), );
];
if ($tool->getLineItems()->count() === 1) { if ($tool->getLineItems()->count() === 1) {
$agsClaim['lineitem'] = LtiAssignmentGradesService::getLineItemUrl( $agsClaim['lineitem'] = LtiAssignmentGradesService::getLineItemUrl(

@ -56,12 +56,20 @@ class LtiLineItemResource extends LtiAdvantageServiceResource
$this->processGet(); $this->processGet();
break; break;
case Request::METHOD_PUT: case Request::METHOD_PUT:
if (LtiAssignmentGradesService::AGS_FULL !== $this->tool->getAdvantageServices()['ags']) {
throw new MethodNotAllowedHttpException([Request::METHOD_GET]);
}
$this->validateToken( $this->validateToken(
[LtiAssignmentGradesService::SCOPE_LINE_ITEM] [LtiAssignmentGradesService::SCOPE_LINE_ITEM]
); );
$this->processPut(); $this->processPut();
break; break;
case Request::METHOD_DELETE: case Request::METHOD_DELETE:
if (LtiAssignmentGradesService::AGS_FULL !== $this->tool->getAdvantageServices()['ags']) {
throw new MethodNotAllowedHttpException([Request::METHOD_GET]);
}
$this->validateToken( $this->validateToken(
[LtiAssignmentGradesService::SCOPE_LINE_ITEM] [LtiAssignmentGradesService::SCOPE_LINE_ITEM]
); );

@ -67,6 +67,10 @@ class LtiLineItemsResource extends LtiAdvantageServiceResource
{ {
switch ($this->request->getMethod()) { switch ($this->request->getMethod()) {
case Request::METHOD_POST: case Request::METHOD_POST:
if (LtiAssignmentGradesService::AGS_FULL !== $this->tool->getAdvantageServices()['ags']) {
throw new MethodNotAllowedHttpException([Request::METHOD_GET]);
}
$this->validateToken( $this->validateToken(
[ [
LtiAssignmentGradesService::SCOPE_LINE_ITEM, LtiAssignmentGradesService::SCOPE_LINE_ITEM,

Loading…
Cancel
Save