src/Core/LTIX.php
public static function launchAuthorizationFlow($request_data)
    {
        global $CFG, $PDOX;

        $key = U::get($request_data, 'oauth_consumer_key');
        if ( ! $key ) return false;
        if ( U::get($request_data, 'oauth_signature_method') && U::get($request_data, 'oauth_timestamp') &&
            U::get($request_data, 'oauth_nonce') && U::get($request_data, 'oauth_version') &&
            U::get($request_data, 'oauth_signature') ) {
            // pass
        } else {
            return false;
        }

        // Handle second half of the pre LTI 1.3 Launch Authorization Flow
        $tool_state = U::get($request_data, 'tool_state');
        if ( $tool_state && $tool_state != self::getBrowserSignature() ) {
            self::abort_with_error_log('Incorrect tool_state');
        }

        // Handle first half of the pre LTI 1.3 Launch Authorization Flow
        $relaunch_url = U::get($request_data, 'relaunch_url');
        if ( ! $relaunch_url ) return false;

        $key_sha256 = U::lti_sha256($key);
        $row = $PDOX->rowDie("SELECT key_id, key_key, secret
            FROM {$CFG->dbprefix}lti_key WHERE key_sha256 = :SHA",
            array(':SHA' => $key_sha256) );
        if ( ! $row ) {
            self::abort_with_error_log('Could not load oauth_consumer_key');
        }

        $valid = LTI::verifyKeyAndSecret($key,$row['secret'],self::curPageUrl(), $request_data);
        if ( $valid !== true ) {
            self::abort_with_error_log('OAuth validation fail key='.$key.' error='.$valid[0],$valid[1]);
        }

        $platform_state = U::get($request_data, 'platform_state');
        if ( $platform_state) $relaunch_url = U::add_url_parm($relaunch_url, "platform_state", $platform_state);
        $tool_state = self::getBrowserSignature();
        $relaunch_url = U::add_url_parm($relaunch_url, "tool_state", $tool_state);
        echo("Relaunching ".$relaunch_url);

        if ( headers_sent() ) {
            echo('<p><a href="'.$relaunch_url.'">Click to continue</a></p>');
        } else {
            header('Location: '.$relaunch_url);
        }
        return true;
    }
public static function launchAuthorizationFlow($request_data)
    {
        global $CFG, $PDOX;

        $key = U::get($request_data, 'oauth_consumer_key');
        if ( ! $key ) return false;
        if ( U::get($request_data, 'oauth_signature_method') && U::get($request_data, 'oauth_timestamp') &&
            U::get($request_data, 'oauth_nonce') && U::get($request_data, 'oauth_version') &&
            U::get($request_data, 'oauth_signature') ) {
            // pass
        } else {
            return false;
        }

        // Handle second half of the pre LTI 1.3 Launch Authorization Flow
        $tool_state = U::get($request_data, 'tool_state');
        if ( $tool_state && $tool_state != self::getBrowserSignature() ) {
            self::abort_with_error_log('Incorrect tool_state');
        }

        // Handle first half of the pre LTI 1.3 Launch Authorization Flow
        $relaunch_url = U::get($request_data, 'relaunch_url');
        if ( ! $relaunch_url ) return false;

        $key_sha256 = U::lti_sha256($key);
        $row = $PDOX->rowDie("SELECT key_id, key_key, secret
            FROM {$CFG->dbprefix}lti_key WHERE key_sha256 = :SHA",
            array(':SHA' => $key_sha256) );
        if ( ! $row ) {
            self::abort_with_error_log('Could not load oauth_consumer_key');
        }

        $valid = LTI::verifyKeyAndSecret($key,$row['secret'],self::curPageUrl(), $request_data);
        if ( $valid !== true ) {
            self::abort_with_error_log('OAuth validation fail key='.$key.' error='.$valid[0],$valid[1]);
        }

        $platform_state = U::get($request_data, 'platform_state');
        if ( $platform_state) $relaunch_url = U::add_url_parm($relaunch_url, "platform_state", $platform_state);
        $tool_state = self::getBrowserSignature();
        $relaunch_url = U::add_url_parm($relaunch_url, "tool_state", $tool_state);
        echo("Relaunching ".$relaunch_url);

        if ( headers_sent() ) {
            echo('<p><a href="'.$relaunch_url.'">Click to continue</a></p>');
        } else {
            header('Location: '.$relaunch_url);
        }
        return true;
    }
public static function launchAuthorizationFlow ( $ request_data ) { global $ CFG , $ PDOX ; $ key = U :: get ( $ request_data , 'oauth_consumer_key' ) ; if ( ! $ key ) return false ; if ( U :: get ( $ request_data , 'oauth_signature_method' ) && U :: get ( $ request_data , 'oauth_timestamp' ) && U :: get ( $ request_data , 'oauth_nonce' ) && U :: get ( $ request_data , 'oauth_version' ) && U :: get ( $ request_data , 'oauth_signature' ) ) { // pass } else { return false ; } // Handle second half of the pre LTI 1.3 Launch Authorization Flow $ tool_state = U :: get ( $ request_data , 'tool_state' ) ; if ( $ tool_state && $ tool_state != self :: getBrowserSignature ( ) ) { self :: abort_with_error_log ( 'Incorrect tool_state' ) ; } // Handle first half of the pre LTI 1.3 Launch Authorization Flow $ relaunch_url = U :: get ( $ request_data , 'relaunch_url' ) ; if ( ! $ relaunch_url ) return false ; $ key_sha256 = U :: lti_sha256 ( $ key ) ; $ row = $ PDOX -> rowDie ( "SELECT key_id, key_key, secret
            FROM {$CFG->dbprefix}lti_key WHERE key_sha256 = :SHA" , array ( ':SHA' => $ key_sha256 ) ) ; if ( ! $ row ) { self :: abort_with_error_log ( 'Could not load oauth_consumer_key' ) ; } $ valid = LTI :: verifyKeyAndSecret ( $ key , $ row [ 'secret' ] , self :: curPageUrl ( ) , $ request_data ) ; if ( $ valid !== true ) { self :: abort_with_error_log ( 'OAuth validation fail key=' . $ key . ' error=' . $ valid [ 0 ] , $ valid [ 1 ] ) ; } $ platform_state = U :: get ( $ request_data , 'platform_state' ) ; if ( $ platform_state ) $ relaunch_url = U :: add_url_parm ( $ relaunch_url , "platform_state" , $ platform_state ) ; $ tool_state = self :: getBrowserSignature ( ) ; $ relaunch_url = U :: add_url_parm ( $ relaunch_url , "tool_state" , $ tool_state ) ; echo ( "Relaunching " . $ relaunch_url ) ; if ( headers_sent ( ) ) { echo ( '<p><a href="' . $ relaunch_url . '">Click to continue</a></p>' ) ; } else { header ( 'Location: ' . $ relaunch_url ) ; } return true ; }
Handle the optional LTI pre 1.3 Launch Authorization flow
Handle the optional LTI pre 1 . 3 Launch Authorization flow