Commit 042c1640 authored by jcnventura's avatar jcnventura Committed by Joao Ventura
Browse files

Issue #3182814 by jcnventura: Add Okta client

parent 16febed8
enabled: false
settings:
client_id:
client_secret:
okta_domain:
......@@ -123,3 +123,23 @@ openid_connect.settings.linkedin:
client_secret:
type: string
label: 'Client secret'
openid_connect.settings.okta:
type: config_object
label: 'OpenID Connect Okta settings'
mapping:
enabled:
type: boolean
label: 'Enable client'
settings:
type: mapping
mapping:
client_id:
type: string
label: 'Client ID'
client_secret:
type: string
label: 'Client secret'
okta_domain:
type: string
label: 'Okta domain'
......@@ -32,7 +32,7 @@ function openid_connect_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Login to Drupal using OpenID Connect/OAuth2 providers') . '</dt>';
$output .= '<dd>' . t('Drupal users can use external OpenID Connect authentication providers to register and login to the Drupal site.') . '</dd>';
$output .= '<dt>' . t('Default providers') . '</dt>';
$output .= '<dd>' . t('The default clients provided by the module for Google, Facebook, Github and LinkedIn can be used out-of-the box.') . '</dd>';
$output .= '<dd>' . t('The default clients provided by the module for Google, Facebook, Github, LinkedIn and Okta can be used out-of-the box.') . '</dd>';
$output .= '<dt>' . t('Custom OpenID Connect/OAuth2 providers') . '</dt>';
$output .= '<dd>' . t('Easily add an own provider by using the provided Generic client, or use a custom provider client plugin.') . '</dd>';
$output .= '<dt>' . t('Synchronize user properties/fields with OpenID Connect claims') . '</dt>';
......@@ -162,7 +162,7 @@ function openid_connect_form_user_login_form_alter(&$form, FormStateInterface $f
// Do nothing in case the query contains the 'showcore' parameter.
$query = \Drupal::request()->query;
if (!$query->has('showcore')) {
// Replace the user login form with the google domain login button.
// Replace the user login form with the IDP login button.
$form = $openid_form;
}
$form['#cache']['contexts'][] = 'url.query_args:showcore';
......
<?php
namespace Drupal\openid_connect\Plugin\OpenIDConnectClient;
use Drupal\Core\Form\FormStateInterface;
use Drupal\openid_connect\Plugin\OpenIDConnectClientBase;
/**
* Okta OpenID Connect client.
*
* Implements OpenID Connect Client plugin for Okta.
*
* @OpenIDConnectClient(
* id = "okta",
* label = @Translation("Okta")
* )
*/
class OpenIDConnectOktaClient extends OpenIDConnectClientBase {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['okta_domain'] = [
'#title' => $this->t('Okta domain'),
'#type' => 'textfield',
'#default_value' => $this->configuration['okta_domain'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function getEndpoints() {
// From https://developer.okta.com/docs/reference/api/oidc and
// https://${yourOktaDomain}/.well-known/openid-configuration
return [
'authorization' => 'https://' . $this->configuration['okta_domain'] . '/oauth2/v1/authorize',
'token' => 'https://' . $this->configuration['okta_domain'] . '/oauth2/v1/token',
'userinfo' => 'https://' . $this->configuration['okta_domain'] . '/oauth2/v1/userinfo',
];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment