1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* BEdita, API-first content management framework |
4
|
|
|
* Copyright 2025 Atlas Srl, Chialab Srl |
5
|
|
|
* |
6
|
|
|
* This file is part of BEdita: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU Lesser General Public License as published |
8
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details. |
12
|
|
|
*/ |
13
|
|
|
namespace App\Controller\Admin; |
14
|
|
|
|
15
|
|
|
use Cake\Http\Response; |
16
|
|
|
use Cake\Utility\Hash; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* ExternalAuth Controller |
20
|
|
|
* |
21
|
|
|
* @property \App\Controller\Component\PropertiesComponent $Properties |
22
|
|
|
*/ |
23
|
|
|
class ExternalAuthController extends AdministrationBaseController |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @inheritDoc |
27
|
|
|
*/ |
28
|
|
|
protected $resourceType = 'external_auth'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritDoc |
32
|
|
|
*/ |
33
|
|
|
protected $readonly = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritDoc |
37
|
|
|
*/ |
38
|
|
|
protected $properties = [ |
39
|
|
|
'user_id' => 'string', |
40
|
|
|
'auth_provider_id' => 'auth_providers', |
41
|
|
|
'provider_username' => 'string', |
42
|
|
|
'params' => 'json', |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritDoc |
47
|
|
|
*/ |
48
|
|
|
protected $propertiesForceJson = [ |
49
|
|
|
'params', |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Index method |
54
|
|
|
* |
55
|
|
|
* @return \Cake\Http\Response|null |
56
|
|
|
*/ |
57
|
|
|
public function index(): ?Response |
58
|
|
|
{ |
59
|
|
|
parent::index(); |
60
|
|
|
$authProviders = $this->apiClient->get('/admin/auth_providers', []); |
61
|
|
|
$authProviders = Hash::combine((array)$authProviders, 'data.{n}.id', 'data.{n}.attributes.name'); |
62
|
|
|
$this->set('auth_providers', $authProviders); |
63
|
|
|
if (empty($authProviders)) { |
64
|
|
|
$this->Flash->warning(__('No auth providers found: you cannot create external auth entries. Create at least one auth provider first')); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return null; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @inheritDoc |
72
|
|
|
*/ |
73
|
|
|
protected $meta = []; |
74
|
|
|
} |
75
|
|
|
|