miniorange_oauth_client.module in Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login 8
Same filename and directory in other branches
Module file for miniOrange OAuth client Module.
File
miniorange_oauth_client.moduleView source
<?php
use Drupal\Core\Form\FormStateInterface;
/**
* @file
* Module file for miniOrange OAuth client Module.
*/
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_help().
*/
function miniorange_oauth_client_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.miniorange_oauth_client':
$url = Url::fromRoute('user.admin_index')
->toString();
$moduleLink = $url . '/miniorange_oauth_client/config_clc';
$supoortLink = $url . 'miniorange_oauth_client/request_for_demo';
$moduleLandingPage = 'https://plugins.miniorange.com/drupal-sso-oauth-openid-single-sign-on';
$setup_guides = 'https://plugins.miniorange.com/guide-to-enable-miniorange-oauth-client-for-drupal';
$output = '';
$output .= '<h3>' . t('About <a target="_blank" href="' . $moduleLandingPage . '">[Know more]</a>') . '</h3>';
$output .= '<p>' . t('Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login module for Drupal Single Sign-On allows users to login into Drupal with OAuth 2.0 and OpenID compliant applications such as Azure AD, Azure B2C, AWS Cognito, Google, Discord, Microsoft, Keycloak, OKTA, Salesforce, Wild Apricot, WHMCS, etc. This module allows your Drupal site to act as a OAuth Client which can be configured to establish the trust between the Drupal site and various OAuth/OpenID Connect providers to securely authenticate the user into the Drupal site.') . '</p>';
$output .= '<h3>' . t('Configuration') . '</h3>';
$output .= '<p>' . t('Configure miniOrange OAuth Client under Configuration » <a target = "_blank" href=" ' . $url . ' ">People</a> » <a target = "_blank" href=" ' . $moduleLink . ' ">miniOrange OAuth Client</a>:') . '</p>';
$output .= '<p>
<ol>
<li>' . t('In the <a target="_blank" href="' . $moduleLink . '">Configure OAuth tab </a> of the module, you can configure your OAuth provider. You can also refer these <a target="_blank" href="' . $setup_guides . '">Setup Guides</a>.') . '</li>
<li>' . t('Once the configuration is done, please click on the <strong>Test Configuration</strong> button on the same page to confirm the configurations.') . '</li>
<li>' . t('If you need any assistance, just send us a query at <a href="mailto:drupalsupport@xecurify.com?subject=Drupal OAuth Client module - Need assistance">drupalsupport@xecurify.com</a> and we will get back to you very soon.') . '</li>
</ol>
</p>';
$output .= '<h3>' . t('Setup Guides') . '</h3>';
$output .= '<p>' . t('Click <a target="_blank" href="' . $setup_guides . '">here</a> to check out the setup guides for different OAuth/OpenID providers.') . '</p>';
return $output;
}
}
/**
* Implements hook_form_alter().
*/
function miniorange_oauth_client_form_alter(&$form, FormStateInterface $form_state, $form_id) {
global $base_url;
$enable_login = \Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_oauth_enable_login_with_oauth');
if (!empty(\Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_oauth_client_base_url'))) {
$baseUrlValue = \Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_oauth_client_base_url');
}
else {
$baseUrlValue = $base_url;
}
if ($enable_login) {
if ($form_id == 'user_login_block' || $form_id == 'user_login_form') {
if (!empty(\Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_auth_client_app_name'))) {
$oauth_login_url = $baseUrlValue . '/moLogin';
$server_name = \Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_auth_client_app_name');
$display_link = \Drupal::config('miniorange_oauth_client.settings')
->get('miniorange_auth_client_display_name');
if (empty($display_link) || $display_link == 'Login using ##app_name##') {
$form['loginurl'] = array(
array(
'#markup' => '<a href="' . $oauth_login_url . '">Login using ' . $server_name . '</a>',
),
);
}
else {
$form['loginurl'] = array(
array(
'#markup' => '<a href="' . $oauth_login_url . '">' . $display_link . '</a>',
),
);
}
}
}
}
\Drupal::service('page_cache_kill_switch')
->trigger();
}
Functions
Name | Description |
---|---|
miniorange_oauth_client_form_alter | Implements hook_form_alter(). |
miniorange_oauth_client_help | Implements hook_help(). |