Plugin Directory

Changeset 3176434


Ignore:
Timestamp:
10/27/2024 05:50:35 PM (17 months ago)
Author:
Beherit
Message:

Basic support for OAuth tokens

Location:
ejabberd-account-tools/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ejabberd-account-tools/trunk/includes/admin-settings.php

    r3176138 r3176434  
    2020    register_setting('ejabat_settings', 'ejabat_login', array('type' => 'string', 'sanitize_callback' => 'trim'));
    2121    register_setting('ejabat_settings', 'ejabat_password', array('type' => 'string', 'sanitize_callback' => 'trim'));
     22    register_setting('ejabat_settings', 'ejabat_oauth_token', array('type' => 'string', 'sanitize_callback' => 'trim'));
    2223    register_setting('ejabat_settings', 'ejabat_debug', array('type' => 'boolean', 'sanitize_callback' => 'boolval'));
    2324    register_setting('ejabat_settings', 'ejabat_registration_hosts', array('type' => 'string', 'sanitize_callback' => 'trim'));
     
    202203                            <div class="postbox">
    203204                                <div class="postbox-header">
     205                                    <h2 class="hndle"><?php _e('ReST API', 'ejabberd-account-tools'); ?></h2>
     206                                </div>
     207                                <div class="inside">
     208                                    <table class="form-table"><tbody>
     209                                        <tr>
     210                                            <th><?php _e('API address', 'ejabberd-account-tools'); ?></th>
     211                                            <td>
     212                                                <input name="ejabat_rest_url" id="ejabat_rest_url" type="text" size="40" value="<?php echo get_option('ejabat_rest_url'); ?>" />
     213                                                <p class="description"><?php _e('Enter URL address defined for module mod_http_api in ejabberd settings.', 'ejabberd-account-tools'); ?></p>
     214                                            </td>
     215                                        </tr>
     216                                        <tr>
     217                                            <th><?php _e('Login', 'ejabberd-account-tools'); ?></th>
     218                                            <td>
     219                                                <input name="ejabat_login" id="ejabat_login" type="text" size="40" value="<?php echo get_option('ejabat_login'); ?>" />
     220                                            </td>
     221                                        </tr>
     222                                        <tr>
     223                                            <th><?php _e('Password', 'ejabberd-account-tools'); ?></th>
     224                                            <td>
     225                                                <input name="ejabat_password" id="ejabat_password" type="password" size="40" autocomplete="new-password" value="<?php echo get_option('ejabat_password'); ?>" />
     226                                            </td>
     227                                        </tr>
     228                                        <tr>
     229                                            <th><?php _e('OAuth token', 'ejabberd-account-tools'); ?></th>
     230                                            <td>
     231                                                <input name="ejabat_oauth_token" id="ejabat_oauth_token" type="text" size="40" value="<?php echo get_option('ejabat_oauth_token'); ?>" />
     232                                                <p class="description"><?php printf(__('Use instead of classic login and password access. The plugin doesn\'t generate and check the expiration date of OAuth tokens, so you need to generate OAuth token for your own with long expiration date. To generate a token use the oauth_issue_token command with the ejabberdctl shell script e.g.: %s', 'ejabberd-account-tools'), '<kbd>ejabberdctl oauth_issue_token bot@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']).' 315360000 ejabberd:admin</kbd>'); ?></p>
     233                                            </td>
     234                                        </tr>
     235                                        <tr>
     236                                            <th><?php _e('Debugging', 'ejabberd-account-tools'); ?></th>
     237                                            <td>
     238                                                <label for="ejabat_debug"><input name="ejabat_debug" id="ejabat_debug" type="checkbox" value="1" <?php checked(1, get_option('ejabat_debug', false)); ?> /><?php _e('Enable debug mode', 'ejabberd-account-tools'); ?></label>
     239                                                <p class="description"><?php _e('Debug information will be returned in JSON response.', 'ejabberd-account-tools'); ?></p>
     240                                            </td>
     241                                        </tr>
     242                                    </tbody></table>
     243                                </div>
     244                            </div>
     245                            <div class="postbox">
     246                                <div class="postbox-header">
    204247                                    <h2 class="hndle"><?php _e('General', 'ejabberd-account-tools'); ?></h2>
    205248                                </div>
     
    259302                                            <td>
    260303                                                <label for="ejabat_loader"><input name="ejabat_loader" id="ejabat_loader" type="checkbox" value="1" <?php checked(1, get_option('ejabat_loader', true)); ?> /><?php _e('Show forms loading animation', 'ejabberd-account-tools'); ?></label>
    261                                             </td>
    262                                         </tr>
    263                                     </tbody></table>
    264                                 </div>
    265                             </div>
    266                             <div class="postbox">
    267                                 <div class="postbox-header">
    268                                     <h2 class="hndle"><?php _e('ReST API', 'ejabberd-account-tools'); ?></h2>
    269                                 </div>
    270                                 <div class="inside">
    271                                     <table class="form-table"><tbody>
    272                                         <tr>
    273                                             <th><?php _e('API address', 'ejabberd-account-tools'); ?></th>
    274                                             <td>
    275                                                 <input name="ejabat_rest_url" id="ejabat_rest_url" type="text" size="40" value="<?php echo get_option('ejabat_rest_url'); ?>" />
    276                                                 <p class="description"><?php _e('Enter URL address defined for module mod_http_api in ejabberd settings.', 'ejabberd-account-tools'); ?></p>
    277                                             </td>
    278                                         </tr>
    279                                         <tr>
    280                                             <th><?php _e('Login', 'ejabberd-account-tools'); ?></th>
    281                                             <td>
    282                                                 <input name="ejabat_login" id="ejabat_login" type="text" size="40" value="<?php echo get_option('ejabat_login'); ?>" />
    283                                             </td>
    284                                         </tr>
    285                                         <tr>
    286                                             <th><?php _e('Password', 'ejabberd-account-tools'); ?></th>
    287                                             <td>
    288                                                 <input name="ejabat_password" id="ejabat_password" type="password" size="40" value="<?php echo get_option('ejabat_password'); ?>" />
    289                                             </td>
    290                                         </tr>
    291                                         <tr>
    292                                             <th><?php _e('Debugging', 'ejabberd-account-tools'); ?></th>
    293                                             <td>
    294                                                 <label for="ejabat_debug"><input name="ejabat_debug" id="ejabat_debug" type="checkbox" value="1" <?php checked(1, get_option('ejabat_debug', false)); ?> /><?php _e('Enable debug mode', 'ejabberd-account-tools'); ?></label>
    295                                                 <p class="description"><?php _e('Debug information will be returned in JSON response.', 'ejabberd-account-tools'); ?></p>
    296304                                            </td>
    297305                                        </tr>
  • ejabberd-account-tools/trunk/includes/functions.php

    r3175084 r3176434  
    1313    $response = wp_remote_post(get_option('ejabat_rest_url').'/'.$command, array(
    1414        'headers' => array(
    15             'Authorization' => 'Basic '.base64_encode(get_option('ejabat_login').':'.get_option('ejabat_password')),
     15            'Authorization' => empty(get_option('ejabat_oauth_token')) ? 'Basic '.base64_encode(get_option('ejabat_login').':'.get_option('ejabat_password')) : 'Bearer '.get_option('ejabat_oauth_token'),
    1616            'Content-Type' => 'application/json'
    1717        ),
  • ejabberd-account-tools/trunk/uninstall.php

    r2383023 r3176434  
    2020delete_option('ejabat_login');
    2121delete_option('ejabat_password');
     22delete_option('ejabat_oauth_token');
    2223delete_option('ejabat_rest_timeout');
    2324delete_option('ejabat_rest_retry');
Note: See TracChangeset for help on using the changeset viewer.