mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
PHRAS-3789 add auto-connect-idp-name option (#4194)
patch to add missing options to conf
This commit is contained in:
@@ -218,12 +218,14 @@ authentication:
|
||||
provider-type: 'oauth'
|
||||
provider-name: 'v2'
|
||||
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:
|
||||
-
|
||||
name: company
|
||||
|
@@ -75,6 +75,9 @@ class PsAuth extends AbstractProvider
|
||||
if(!array_key_exists('auto-logout', $this->config)) {
|
||||
$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->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);
|
||||
|
||||
$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 = [
|
||||
'client_id' => $this->config['client-id'],
|
||||
'state' => $state,
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'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));
|
||||
|
||||
@@ -457,7 +473,7 @@ class PsAuth extends AbstractProvider
|
||||
|
||||
// add "everyone-group"
|
||||
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
|
||||
|
@@ -17,7 +17,7 @@ class Version
|
||||
* @var string
|
||||
*/
|
||||
|
||||
private $number = '4.1.7-rc1';
|
||||
private $number = '4.1.7-rc2';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
74
lib/classes/patch/417RC2PHRAS2995.php
Normal file
74
lib/classes/patch/417RC2PHRAS2995.php
Normal 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;
|
||||
}
|
||||
}
|
@@ -247,6 +247,7 @@ authentication:
|
||||
model-gpfx: '_M_'
|
||||
model-upfx: '_U_'
|
||||
auto-logout: false
|
||||
auto-connect-idp-name: null
|
||||
registration-fields:
|
||||
-
|
||||
name: company
|
||||
|
@@ -186,6 +186,14 @@ authentication:
|
||||
provider-type: 'oauth'
|
||||
provider-name: 'v2'
|
||||
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:
|
||||
-
|
||||
name: company
|
||||
|
@@ -186,6 +186,14 @@ authentication:
|
||||
provider-type: 'oauth'
|
||||
provider-name: 'v2'
|
||||
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:
|
||||
-
|
||||
name: company
|
||||
|
Reference in New Issue
Block a user