-
Notifications
You must be signed in to change notification settings - Fork 558
Upstream pr/lti provider fixes #8783
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
base: 1.11.x
Are you sure you want to change the base?
Changes from all commits
acb4513
b6b9fad
d4b8b31
29d4fc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
| /* For license terms, see /license.txt */ | ||
|
|
||
| $cidReset = true; | ||
|
|
||
| require_once __DIR__.'/../../main/inc/global.inc.php'; | ||
| use Chamilo\PluginBundle\Entity\LtiProvider\Platform; | ||
|
|
||
| require_once __DIR__.'/LtiProviderPlugin.php'; | ||
|
|
||
| api_protect_admin_script(); | ||
|
|
||
| if (!isset($_REQUEST['id'])) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Español: Esta acción que escribe en la base de datos acepta GET mediante REQUEST y no verifica ningún token CSRF. Una navegación externa con una sesión de administrador activa puede crear duplicados sin consentimiento. Exige POST, lee el id únicamente desde POST, valida Security::check_token con post y muestra la acción como un formulario con token. English: This database-writing action accepts GET through REQUEST and verifies no CSRF token. An external navigation with an active administrator session can create duplicates without consent. Require POST, read the id only from POST, validate Security::check_token with post, and render the action as a token-bearing form. |
||
| api_not_allowed(true); | ||
| } | ||
|
|
||
| $platformId = (int) $_REQUEST['id']; | ||
|
|
||
| $plugin = LtiProviderPlugin::create(); | ||
| $em = Database::getManager(); | ||
|
|
||
| /** @var Platform $platform */ | ||
| $platform = $em->find('ChamiloPluginBundle:LtiProvider\Platform', $platformId); | ||
|
|
||
| if (!$platform) { | ||
| api_not_allowed(true); | ||
| } | ||
|
|
||
| $newPlatform = new Platform(); | ||
| $newPlatform->setIssuer($platform->getIssuer()); | ||
| $newPlatform->setClientId($platform->getClientId()); | ||
| $newPlatform->setAuthLoginUrl($platform->getAuthLoginUrl()); | ||
| $newPlatform->setAuthTokenUrl($platform->getAuthTokenUrl()); | ||
| $newPlatform->setKeySetUrl($platform->getKeySetUrl()); | ||
| $newPlatform->setDeploymentId($platform->getDeploymentId()); | ||
| $newPlatform->setKid($platform->getKid()); | ||
| $newPlatform->setToolProvider($platform->getToolProvider()); | ||
|
|
||
| $em->persist($newPlatform); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Español: El duplicado se guarda como registro activo antes de que el administrador confirme la edición. Si se abandona la redirección queda otra fila con el mismo emisor, client ID y deployment ID. El runtime indexa registros por client ID y también usa findOneBy, por lo que las identidades duplicadas se resuelven de forma ambigua. Precarga el formulario sin persistir y guarda solo tras un POST validado; además, aplica la unicidad que requieren esas búsquedas. English: The clone is persisted as a live registration before the administrator confirms the edit. Abandoning the redirect leaves another row with the same issuer, client ID, and deployment ID. Runtime lookup indexes registrations by client ID and also uses findOneBy, so duplicate identities resolve ambiguously. Prefill the form without persisting and save only after a validated POST; also enforce the uniqueness required by those lookups. |
||
| $em->flush(); | ||
|
|
||
| Display::addFlash( | ||
| Display::return_message($plugin->get_lang('PlatformDuplicated'), 'success') | ||
| ); | ||
|
|
||
| header('Location: '.api_get_path(WEB_PLUGIN_PATH).'lti_provider/edit.php?id='.$newPlatform->getId()); | ||
| exit; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Español: Marcar la cookie como Secure es correcto, pero actualmente no restaura la validación de estado. getCookie devuelve directamente el valor state recibido cuando el nombre coincide, y Packback compara ese mismo valor con la solicitud; por tanto, una solicitud sin cookie almacenada también supera la comprobación. Elimina ese atajo de REQUEST y exige la cookie real o un estado de servidor ligado al navegador. Añade pruebas negativas para cookie ausente y estado distinto.
English: Marking the cookie Secure is correct, but it does not currently restore state validation. getCookie returns the received state directly when the name matches, while Packback compares that same value with the request; therefore, a request with no stored cookie also passes. Remove the REQUEST shortcut and require the real cookie or server-side state bound to the browser. Add negative tests for a missing cookie and a mismatched state.