Skip to content

Commit

Permalink
Backport Project Administration disabling (#2050)
Browse files Browse the repository at this point in the history
Originally was: 3003562

Add config to disable Project Administrator user registration (#2019)

Add a new environment variable that will disable the registration form
that is found on the manageProjectRoles page. If the current user is a
site administrator, the form will always be shown.

Issue: #2007
  • Loading branch information
josephsnyder authored Feb 28, 2024
1 parent fff13e6 commit 81ff7a5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
# Whether or not "normal" username+password registration form submission is enabled
# USER_REGISTRATION_FORM_ENABLED=true

# Whether or not a Project administrator can register a user
# PROJECT_ADMIN_REGISTRATION_FORM_ENABLED=true


# ldap.php
#LDAP_HOSTS=
Expand Down
7 changes: 7 additions & 0 deletions app/Http/Controllers/ManageProjectRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ public function viewPage(): View|RedirectResponse
if ($config->get('CDASH_FULL_EMAIL_WHEN_ADDING_USER') == 1) {
$xml .= add_XML_value('fullemail', '1');
}
if ((config('auth.project_admin_registration_form_enabled') === true) || $current_user->admin) {
$xml .= add_XML_value('canRegister', '1');
}
$xml .= '</cdash>';

return view('cdash', [
Expand All @@ -413,6 +416,10 @@ private function register_user($projectid, $email, $firstName, $lastName, $repos
{
$config = Config::getInstance();

if(config('auth.project_admin_registration_form_enabled') === false) {
return '<error>Users cannot be registered via this form at the current time.</error>';
}

$UserProject = new UserProject();
$UserProject->ProjectId = $projectid;

Expand Down
84 changes: 44 additions & 40 deletions app/cdash/public/manageProjectRoles.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@
<a href="#fragment-1"><span>Current users</span></a></li>
<li>
<a href="#fragment-2"><span>Search for already registered users</span></a></li>
<li>
<a href="#fragment-3"><span>Register a new user</span></a></li>
<xsl:if test="/cdash/canRegister">
<li>
<a href="#fragment-3"><span>Register a new user</span></a></li>
</xsl:if>
<li>
<a href="#fragment-4"><span>Import users from CVS file </span></a></li>
</ul>
Expand Down Expand Up @@ -230,44 +232,46 @@
</tr>
</table>
</div>
<div id="fragment-3" class="tab_content" >
<div class="tab_help"></div>
<form method="post">
<table width="800" border="0">
<tr>
<td><div align="right">User Email:</div></td>
<td>
<input name="registeruseremail" type="text" id="registeruseremail" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">First name:</div></td>
<td>
<input name="registeruserfirstname" type="text" id="registeruserfirstname" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">Last name:</div></td>
<td>
<input name="registeruserlastname" type="text" id="registeruserlastname" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">Repository credential:</div></td>
<td>
<input name="registeruserrepositorycredential" type="text" id="registeruserrepositorycredential" size="40"/>
* email address is automatically added as a credential
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="registerUser" value="Register User"/>
</td>
</tr>
</table>
</form>
</div>
<xsl:if test="/cdash/canRegister">
<div id="fragment-3" class="tab_content" >
<div class="tab_help"></div>
<form method="post">
<table width="800" border="0">
<tr>
<td><div align="right">User Email:</div></td>
<td>
<input name="registeruseremail" type="text" id="registeruseremail" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">First name:</div></td>
<td>
<input name="registeruserfirstname" type="text" id="registeruserfirstname" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">Last name:</div></td>
<td>
<input name="registeruserlastname" type="text" id="registeruserlastname" size="40"/>
</td>
</tr>
<tr>
<td><div align="right">Repository credential:</div></td>
<td>
<input name="registeruserrepositorycredential" type="text" id="registeruserrepositorycredential" size="40"/>
* email address is automatically added as a credential
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="registerUser" value="Register User"/>
</td>
</tr>
</table>
</form>
</div>
</xsl:if>
<div id="fragment-4" class="tab_content" >
<div class="tab_help"></div>
<table width="800" border="0">
Expand Down
2 changes: 2 additions & 0 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'username_password_authentication_enabled' => env('USERNAME_PASSWORD_AUTHENTICATION_ENABLED', true),
// Whether or not "normal" username+password authentication is enabled
'user_registration_form_enabled' => env('USER_REGISTRATION_FORM_ENABLED', true),
# Whether or not a Project administrator can register a user
'project_admin_registration_form_enabled' => env('PROJECT_ADMIN_REGISTRATION_FORM_ENABLED', true),

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 81ff7a5

Please sign in to comment.