0

我正在尝试按照https://d2l.nl.edu/shared/HelpFiles/10%20Administrator%20Help/learningenvironment/basic_lti_standards_support/org_level_lti_configuration.htmlhttp://devs 上的说明在 Desire2Learn 中创建一个外部学习工具。 valence.desire2learn.com/tag/lti甚至无法让示例测验项目正常工作。

我已经尝试了所有我能想到的东西,并且有一次我让它工作并且可以在 Desire2Learn 中正确加载我的学习工具,但它似乎刚刚停止,我无法再弄清楚了,因为我已经花了 5几个小时试图解决这个问题。我尝试过回显 POST 和局部变量以进行调试,并在工具提供程序内的 URL 字段和 Desire2Learn 中的链接字段中抛出不同的东西。

在我花费的 5 个小时中,我注意到的是,在身份验证过程中重新创建签名时,它永远不会与 POST 数据中发送的 [oauth_signature] 字段匹配,尽管密钥和秘密与 LMS 中的那些匹配.

如果这是有道理的,我很感激我能得到的任何帮助,因为我已经花了太多时间在这上面,不能再思考了。谢谢!

编辑:

这是 Desire2Learn 与我正在验证的 OAUTH 参数一起发回的上下文数据的 print_r(),下面是我设置的局部变量。

[launch_presentation_locale] => EN-US__
    [tool_consumer_instance_guid] => key
    [tool_consumer_instance_name] => secret
    [tool_consumer_instance_description] => Learning Tool.
    [tool_consumer_instance_contact_email] => 
    [tool_consumer_info_version] => 10.3.0 SP5
    [tool_consumer_info_product_family_code] => desire2learn
    [context_id] => 2440554
    [context_title] => context
    [context_label] => context
    [context_type] => 
    [user_id] => userid_88888
    [roles] => None
    [ext_tc_profile_url] => https://sampleprofileurl.com
    [ext_d2l_token_id] => 386867949
    [ext_d2l_link_id] => 9554
    [ext_d2l_token_digest] => 2bv8al0f+NxuBWpBS36nl/RuNWg=
    [resource_link_id] => 
    [resource_link_title] => LinkTitle
    [resource_link_description] => LinkDes.
    [lis_result_sourcedid] => 808080-89989-234232
    [lis_outcome_service_url] => https://outcomeurl.com
    [lti_version] => LTI-1p0
    [lti_message_type] => basic-lti-launch-request
    [oauth_version] => 1.0
    [oauth_nonce] => 784335425
    [oauth_timestamp] => 1403634776
    [oauth_signature_method] => HMAC-SHA1
    [oauth_consumer_key] => key
    [oauth_callback] => about:blank
    [oauth_signature] => PYCJyQe3jSLTXn8vxet1eknSfoc=
    [basiclti_submit] => Launch Endpoint with BasicLTI Data

$OAUTH_KEY    = 'key';
$OAUTH_SECRET = 'secret'; 
$SITE_URL     = 'https://sample.com';

当 POST 数据最初从 Desire2Learn 发回时,会根据 $_POST['oauth_consumer_key'] 字段检查 $OAUTH_KEY,如果它们相等,则使用 $OAUTH_KEY 和 $OAUTH_SECRET 字段生成临时签名/令牌,即然后根据 $_POST['oauth_signature'] 字段进行身份验证。

public static function CheckSignatureForFormUrlEncoded( $url, $httpMethod, $parameters, $secret) {
        $oauthParameters = array();
        $lmsParameters = array();

        // Separate LMS and OAuth parameters
        foreach( $parameters as $key => $value ) {
            if( strpos( $key, self::OAUTH_PREFIX ) === 0 ) {
                $oauthParameters[urldecode( $key )] = urldecode( $value );
                continue;
            }
            $lmsParameters[urldecode( $key )] = urldecode( $value );
        }

        $signature = self::CalculateSignatureForFormUrlEncoded( $url, $httpMethod, $secret, $lmsParameters, $oauthParameters );

        return $parameters[ self::SIGNATURE ] === $signature;   

    }

这就是我被阻止的地方。当 return 语句返回时,或者换句话说 $parameters 数组中的签名值与 $signature 不匹配时,我收到错误“无效的 OAuth 签名”。据我了解,如果我在 LMS 中设置的“密钥”和“秘密”字段等于我在上面两个变量中设置的字段,则不应该发生这种情况。

4

1 回答 1

0

好吧,我好像想通了。听起来很愚蠢,我所要做的就是将“index.php”附加到我在 Desire2Learn 中的外部学习工具的链接中的 URL 字段的末尾,以及工具提供程序配置中的启动点字段。在我这样做之后,签名错误消失了,现在一切都好起来了。显然,工具使用者并没有像我想象的那样专门寻找 index.anything 文件。

于 2014-06-25T19:36:35.303 回答