PHRAS-3789 add auto-connect-idp-name option (#4194)

patch to add missing options to conf
This commit is contained in:
jygaulier
2022-12-13 19:43:50 +01:00
committed by GitHub
parent 6916c180f4
commit 2ee51887e0
7 changed files with 122 additions and 13 deletions

View File

@@ -218,12 +218,14 @@ authentication:
provider-type: 'oauth' provider-type: 'oauth'
provider-name: 'v2' provider-name: 'v2'
icon-uri: null icon-uri: null
debug: false
birth-group: '_firstlog' birth-group: '_firstlog'
everyone-group: '_everyone' everyone-group: '_everyone'
metamodel: '_metamodel' metamodel: '_metamodel'
model-gpfx: '_M_' model-gpfx: '_M_'
model-upfx: '_U_' model-upfx: '_U_'
auto-logout: false auto-logout: false
auto-connect-idp-name: null
registration-fields: registration-fields:
- -
name: company name: company

View File

@@ -75,6 +75,9 @@ class PsAuth extends AbstractProvider
if(!array_key_exists('auto-logout', $this->config)) { if(!array_key_exists('auto-logout', $this->config)) {
$this->config['auto-logout'] = false; $this->config['auto-logout'] = false;
} }
if(!array_key_exists('auto-connect-idp-name', $this->config)) {
$this->config['auto-connect-idp-name'] = null;
}
$this->client = $client; $this->client = $client;
$this->iconUri = array_key_exists('icon-uri', $config) ? $config['icon-uri'] : null; // if not set, will fallback on default icon $this->iconUri = array_key_exists('icon-uri', $config) ? $config['icon-uri'] : null; // if not set, will fallback on default icon
@@ -162,17 +165,30 @@ class PsAuth extends AbstractProvider
$this->session->set($this->getId() . '.provider.state', $state); $this->session->set($this->getId() . '.provider.state', $state);
$url = sprintf("%s/%s/%s/auth?%s", $parms = [
$this->config['base-url'],
urlencode($this->config['provider-type']),
urlencode($this->config['provider-name']),
http_build_query([
'client_id' => $this->config['client-id'], 'client_id' => $this->config['client-id'],
'state' => $state, 'state' => $state,
'redirect_uri' => $redirect_uri, 'redirect_uri' => $redirect_uri,
'response_type' => "code" 'response_type' => "code"
], '', '&') ];
if($this->config['auto-connect-idp-name']) {
$url = sprintf("%s/%s/%s/auth?connect=%s&%s",
$this->config['base-url'],
urlencode($this->config['provider-type']),
urlencode($this->config['provider-name']),
urlencode($this->config['auto-connect-idp-name']),
http_build_query($parms, '', '&')
); );
}
else {
$url = sprintf("%s/%s/%s/auth?%s",
$this->config['base-url'],
urlencode($this->config['provider-type']),
urlencode($this->config['provider-name']),
http_build_query($parms, '', '&')
);
}
$this->debug(sprintf("go to url = %s", $url)); $this->debug(sprintf("go to url = %s", $url));
@@ -457,7 +473,7 @@ class PsAuth extends AbstractProvider
// add "everyone-group" // add "everyone-group"
if(array_key_exists('everyone-group', $this->config)) { if(array_key_exists('everyone-group', $this->config)) {
$models[] = ['name' => $this->config['everyone-group'], 'autocreate' => true]; $models[] = ['name' => $this->config['model-gpfx'] . $this->config['everyone-group'], 'autocreate' => true];
} }
// add a specific model for the user // add a specific model for the user

View File

@@ -17,7 +17,7 @@ class Version
* @var string * @var string
*/ */
private $number = '4.1.7-rc1'; private $number = '4.1.7-rc2';
/** /**
* @var string * @var string

View File

@@ -0,0 +1,74 @@
<?php
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
class patch_417RC2PHRAS2995 implements patchInterface
{
/** @var string */
private $release = '4.1.7-rc2';
/** @var array */
private $concern = [base::APPLICATION_BOX];
/**
* Returns the release version.
*
* @return string
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
/** @var PropertyAccess $conf */
$conf = $app['conf'];
$newProviders = [];
$psFixed = false;
foreach ($app['conf']->get(['authentication', 'providers'], []) as $providerId => $data) {
if($data['type'] === "ps-auth") {
if(!isset($data['options']['debug'])) {
$data['options']['debug'] = false;
}
if(!isset($data['options']['auto-connect-idp-name'])) {
$data['options']['auto-connect-idp-name'] = null;
}
$psFixed = true;
}
$newProviders[$providerId] = $data;
}
// add ps
if($psFixed) {
$conf->set(['authentication', 'providers'], $newProviders);
}
return true;
}
}

View File

@@ -247,6 +247,7 @@ authentication:
model-gpfx: '_M_' model-gpfx: '_M_'
model-upfx: '_U_' model-upfx: '_U_'
auto-logout: false auto-logout: false
auto-connect-idp-name: null
registration-fields: registration-fields:
- -
name: company name: company

View File

@@ -186,6 +186,14 @@ authentication:
provider-type: 'oauth' provider-type: 'oauth'
provider-name: 'v2' provider-name: 'v2'
icon-uri: null icon-uri: null
debug: false
birth-group: '_firstlog'
everyone-group: '_everyone'
metamodel: '_metamodel'
model-gpfx: '_M_'
model-upfx: '_U_'
auto-logout: false
auto-connect-idp-name: null
registration-fields: registration-fields:
- -
name: company name: company

View File

@@ -186,6 +186,14 @@ authentication:
provider-type: 'oauth' provider-type: 'oauth'
provider-name: 'v2' provider-name: 'v2'
icon-uri: null icon-uri: null
debug: false
birth-group: '_firstlog'
everyone-group: '_everyone'
metamodel: '_metamodel'
model-gpfx: '_M_'
model-upfx: '_U_'
auto-logout: false
auto-connect-idp-name: null
registration-fields: registration-fields:
- -
name: company name: company