Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
rest_api_authentication.module 2.21 KiB
<?php
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;

/**
 * @file
 * Module file for miniOrange REST API Module.
 */


/**
 * Implements hook_help().
 */
function rest_api_authentication_help($route_name, RouteMatchInterface $route_match)
{
  switch ($route_name) {
    case 'help.page.rest_api_authentication':
      $url = Url::fromRoute('user.admin_index')->toString();
      $moduleLink = $url . '/rest_api_authentication/auth_settings';

      $moduleLandingPage = 'https://plugins.miniorange.com/drupal-rest-api-authentication';
      $setup_guides = 'https://plugins.miniorange.com/drupal-api-authentication';

      $output = '';
      $output .= '<b>' . t('ABOUT <a target="_blank" href="' . $moduleLandingPage . '">[Know more]</a>') . '</b>';
      $output .= '<br>' . t('Drupal API Authentication module allows you to authenticate any Drupal site API calls. The module is compatible with both RESTful Web Services and JSON API module. If you have any other custom APIs as well, this module can authenticate them as well.') . '<br>';
      $output .= '<br><b>' . t('AUTHENTICATION METHODS SUPPORTED:') . '</b>';
      $output .= '<br>' . t('<ol> 
                                    <li>Basic Authentication</li>
                                    <li>Key Based Authentication</li>
                                    <li>OAuth/Access Token Based Authentication</li>
                                    <li>JWT Token Based Authentication</li>
                                    <li>3rd Party/External IDP Token Authentication</li>
                                  </ol>') . '</br>';
      $output .= '<p>

                        </p>';
      $output .= '<b>' . t('SETUP GUIDE') . '</b><br>';
      $output .= '' . t('Please click on this <a target="_blank" href="'.$setup_guides.'"><strong>link here</strong></a> to setup the module according to your requirements.') . '';

      return $output;
  }
}


function rest_api_authentication_form_alter(&$form, FormStateInterface $form_state, $form_id){
  if($form_id === 'rest_api_authentication_config_client'){
    $form['api_auth']['rest_api_authentication_authentication_method_submit']   = [ '#disabled' => TRUE ];
  }
  return $form;
}