Skip to content

Commit

Permalink
Add LdapServer MVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Mar 17, 2026
1 parent 9302e2c commit cd5cdbd
Show file tree
Hide file tree
Showing 10 changed files with 554 additions and 4 deletions.
15 changes: 15 additions & 0 deletions app/plugins/CoreServer/config/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"types": {
"server": [
"HttpServers",
"LdapServers",
"MatchServers",
"Oauth2Servers",
"SmtpServers",
Expand Down Expand Up @@ -52,6 +53,20 @@
},
"clone_relation": true
},
"ldap_servers": {
"columns": {
"id": {},
"server_id": {},
"serverurl": { "type": "string", "size": 256 },
"binddn": { "type": "string", "size": 256 },
"password": { "type": "string", "size": 256 },
"basedn": { "type": "string", "size": 256 },
"group_basedn": { "type": "string", "size": 256 }
},
"indexes": {
"ldap_servers_i1": { "columns": [ "server_id" ] }
}
},
"oauth2_servers": {
"columns": {
"id": {},
Expand Down
41 changes: 40 additions & 1 deletion app/plugins/CoreServer/resources/locales/en_US/core_server.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,43 @@ msgid "field.SqlServers.type"
msgstr "RDBMS Type"

msgid "result.MatchServers.match.accepted"
msgstr "Match request requires administrator intervention, Match Request ID: {0}"
msgstr "Match request requires administrator intervention, Match Request ID: {0}"

msgid "error.LdapServers.connect"
msgstr "Failed to connect to LDAP server {0}"

msgid "error.LdapServers.credentials"
msgstr "Missing authentication credentials for LDAP server {0}"

msgid "error.LdapServers.serverurl.valid"
msgstr "Please enter a valid ldap or ldaps URL (e.g., ldaps://server:port)"

msgid "field.LdapServers.serverurl"
msgstr "Server URL"

msgid "field.LdapServers.serverurl.desc"
msgstr "LDAP server URL, e.g. ldap://ldap.example.org or ldaps://ldap.example.org"

msgid "field.LdapServers.binddn"
msgstr "Bind DN"

msgid "field.LdapServers.binddn.desc"
msgstr "DN to authenticate as to manage entries"

msgid "field.LdapServers.password"
msgstr "Password"

msgid "field.LdapServers.password.desc"
msgstr "Password to use for authentication"

msgid "field.LdapServers.basedn"
msgstr "People Base DN"

msgid "field.LdapServers.basedn.desc"
msgstr "Base DN to search/provision People under"

msgid "field.LdapServers.group_basedn"
msgstr "Group Base DN"

msgid "field.LdapServers.group_basedn.desc"
msgstr "Base DN to provision Group entries under (requires groupOfNames objectclass)"
61 changes: 61 additions & 0 deletions app/plugins/CoreServer/src/Controller/LdapServersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* COmanage Registry LDAP Servers Controller
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreServer\Controller;

use Cake\Event\EventInterface;
use App\Controller\StandardPluginController;

class LdapServersController extends StandardPluginController {
protected array $paginate = [
'order' => [
'LdapServers.serverurl' => 'asc'
]
];


/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
* @return \Cake\Http\Response|null|void
* @since COmanage Registry v5.2.0
*/
public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->LdapServers->Servers->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->LdapServers->Servers->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->LdapServers->Servers->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
56 changes: 56 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/LdapServer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* COmanage Registry LDAP Servers Entity
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreServer\Model\Entity;

use Cake\ORM\Entity;

class LdapServer extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* @var array<string, bool>
*/
protected array $_accessible = [
'*' => true,
'id' => false,
'slug' => false,
];

/**
* Fields that are excluded from JSON versions of the entity.
*
* @var array
*/
protected array $_hidden = [
'password'
];
}
Loading

0 comments on commit cd5cdbd

Please sign in to comment.