LLMS_REST_Admin_Form_Controller::prepare_key_download()

Validates GET information from the credential download URL and prepares information for generating the file.


Return Return

(false|array)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/admin/class-llms-rest-admin-form-controller.php

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
* @return false|array
 */
protected function prepare_key_download() {
 
    $key_id       = llms_filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    $consumer_key = llms_filter_input_sanitize_string( INPUT_GET, 'ck' );
 
    // return if missing required fields.
    if ( ! $key_id || ! $consumer_key ) {
        return false;
    }
 
    // return if key doesn't exist.
    $key = LLMS_REST_API()->keys()->get( $key_id );
    if ( ! $key ) {
        return false;
    }
 
    // validate the decoded consumer key looks like the stored truncated key.
    $consumer_key = base64_decode( $consumer_key ); //phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- This is benign usage.
    if ( substr( $consumer_key, -7 ) !== $key->get( 'truncated_key' ) ) {
        return false;
    }
 
    return array(
        'fn' => sanitize_file_name( $key->get( 'description' ) ) . '.txt',
        'ck' => $consumer_key,
        'cs' => $key->get( 'consumer_secret' ),
    );


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.3 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.