openedx / xblock-lti-consumer

GNU Affero General Public License v3.0
28 stars 80 forks source link

LTI 1.3 Deep Linking Launch URL missing Custom Parameters #427

Open abonnell opened 10 months ago

abonnell commented 10 months ago

Custom Parameters were added to the repository as part of its 9.6.2 release via #392 , but this seems to have accidentally omitted the required changes from the Deep Linking config url

Line 129 of lti_consumer.api

if deep_linking_enabled:
        launch_data.message_type = "LtiDeepLinkingRequest"
        deep_linking_launch_url = lti_consumer.prepare_preflight_url(
            launch_data,
        )

calls lti_consumer.lti_1p3.consumer.prepare_preflight_url

    def prepare_preflight_url(
            self,
            launch_data,
    ):
        """
        Generates OIDC url with parameters
        """
        user_id = launch_data.external_user_id if launch_data.external_user_id else launch_data.user_id

        # Set the launch_data in the cache. An LTI 1.3 launch involves two "legs" - the third party initiated
        # login request (the preflight request) and the actual launch -, and this information must be shared between
        # the two requests. A simple example is the intended LTI launch message of the LTI launch. This value is
        # known at the time that preflight request is made, but it is not accessible when the tool responds to the
        # preflight request and the platform must craft a launch request. This library stores the launch_data in the
        # cache and includes the cache key as the lti_message_hint query or form parameter to retrieve it later.
        launch_data_key = cache_lti_1p3_launch_data(launch_data)

        oidc_url = self.oidc_url + "?"

        login_hint = user_id

        parameters = {
            "iss": self.iss,
            "client_id": self.client_id,
            "lti_deployment_id": self.deployment_id,
            "target_link_uri": self.launch_url,
            "login_hint": login_hint,
            "lti_message_hint": launch_data_key,
        }

        return oidc_url + urlencode(parameters)

and we can see the custom params are not being included in that parameters dict to be appended to the oidc launch url, which is what Deep Linking generates as part of the first time config/setup portion of the connection

Talking with Michael a little bit it looks like this is boiling down to this claim in the lti1p3 consumer, it is being set explicitly as include_extra_claims=False here