Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
63fa499
Initial Symfony Migration changes
ryanrath Sep 18, 2025
08fbe03
Temporarily Admitting Defeat
ryanrath Oct 6, 2025
35135a1
Removing unneeded files
ryanrath Nov 4, 2025
557df61
Updating logging location
ryanrath Nov 4, 2025
d324ed0
this file was overwriting the log settings
ryanrath Nov 4, 2025
37a77ec
First set of changes per code review @jpwhite
ryanrath Nov 4, 2025
e4d0d69
This test doesn't have anything to test anymore
ryanrath Nov 4, 2025
c66d5d1
Making sure that APP_SECRET is added to .en
ryanrath Nov 4, 2025
6292ec6
Removing unused directory / file
ryanrath Nov 4, 2025
27b7fd4
more updates per @jpwhite4
ryanrath Nov 4, 2025
223f704
Reverting changes to docker-compose
ryanrath Nov 5, 2025
403da7e
CircleCI Updates to install PHP 8.2
ryanrath Nov 5, 2025
64daafd
Only copy the files necessary for playwright
ryanrath Nov 5, 2025
4ba0ad8
Adding a few more dirs for playwright tests
ryanrath Nov 5, 2025
d1cefda
Monolog Updates
ryanrath Nov 5, 2025
08f86f1
Minor updates to `post` tests
ryanrath Nov 5, 2025
b944d9a
Removing Unneeded Code
ryanrath Nov 6, 2025
ab114b2
Removing unused code
ryanrath Nov 6, 2025
c6edef6
removing unused code
ryanrath Nov 6, 2025
2a842a6
Token Helper Updates
ryanrath Nov 6, 2025
e0cf523
Revert "Monolog Updates"
ryanrath Nov 6, 2025
53cd717
Removing a debug artifact
ryanrath Nov 7, 2025
ec41925
reverting previous change to ArrayIngestor
ryanrath Nov 7, 2025
12de03a
Monolog PHP 8.2 Updates
ryanrath Nov 7, 2025
813de9f
This change is no longer necessary
ryanrath Nov 7, 2025
0ce99b0
Changes per code review by @jpwhite4
ryanrath Nov 7, 2025
7405683
Migrating / Removing Error.js.php
ryanrath Nov 7, 2025
4b70102
Leaving xsede things to the xsede module
ryanrath Nov 7, 2025
9a09785
file is no longer needed
ryanrath Nov 7, 2025
0a8cb05
Removing unused classes
ryanrath Nov 7, 2025
a6cc40e
Should have been removed with the refactoring of Error.js.php
ryanrath Nov 7, 2025
83e67cc
Updates to take file removals in to account
ryanrath Nov 7, 2025
615515e
Migrating / Removing code from security.php
ryanrath Nov 10, 2025
a0e133a
Updates to address user logged in related problems
ryanrath Nov 10, 2025
72b5e93
Fix for broken admin dashboard button
ryanrath Nov 10, 2025
bbc8db7
Fix for error viewing logs in internal dashboard
ryanrath Nov 10, 2025
9af8546
updating the user dashboard logic
ryanrath Nov 10, 2025
a77fb6b
ignoring warnings in php_errors.log
ryanrath Nov 11, 2025
25bf911
These headers are no longer necessary
ryanrath Nov 12, 2025
2d72ba7
Update to allow SSO to work locally for dev
ryanrath Nov 12, 2025
5dc1da6
Removing unneccessary code
ryanrath Nov 12, 2025
ce93bf0
Migrating from new code to CCR\ namespace
ryanrath Nov 12, 2025
45f3268
removing unneeded script property
ryanrath Nov 12, 2025
a185a1f
Zero out the php_errors log before main run
ryanrath Nov 12, 2025
6d64d12
mark /config files as config no replace
ryanrath Nov 12, 2025
38e3657
Updating sso logic to match what we had before
ryanrath Nov 13, 2025
1de83f5
Removing APP_SECRET population
ryanrath Nov 14, 2025
2c320c2
Updating .env file generation
ryanrath Nov 14, 2025
d9babc7
Updating console to work w/ source installs
ryanrath Nov 14, 2025
4bddaea
Split out Symfony from XDMoD templates
ryanrath Nov 14, 2025
8055b16
Add DotEnv creation to upgrade path
ryanrath Dec 1, 2025
afb1e7b
updates per code review by @jpwhite4
ryanrath Dec 1, 2025
92773f3
Resolving SonarQube alert for SRI
ryanrath Dec 1, 2025
966128d
Fixing passing null to strpos
ryanrath Dec 1, 2025
0c76371
update linter php version to 8.2
ryanrath Dec 1, 2025
9c05e7a
Removing Doctrine as it's unused (#2131)
ryanrath Dec 4, 2025
a3d522c
Sync changes with upstream/main (#2132)
jpwhite4 Dec 8, 2025
916b42b
Cleaning up config settings
ryanrath Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 26 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,33 @@ jobs:
- setup_remote_docker
- run:
name: Docker Compose corresponding OS file
command: docker compose -f ~/project/tests/playwright/Docker/docker-compose.yml up -d
command: pushd ~/project/tests/playwright/Docker && docker compose up -d; popd
- run:
name: Generate Key for XDMoD
command: docker exec xdmod openssl genrsa -out /etc/pki/tls/private/localhost.key -rand /proc/cpuinfo:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/uptime 2048
- run:
name: Generate Cert for XDMoD
command: docker exec xdmod /usr/bin/openssl req -new -key /etc/pki/tls/private/localhost.key -x509 -sha256 -days 365 -set_serial $RANDOM -extensions v3_req -out /etc/pki/tls/certs/localhost.crt -subj "/C=XX/L=Default City/O=Default Company Ltd"
- run:
name: Update PHP to PHP8.2
command: |
docker exec xdmod dnf module reset -y php
docker exec xdmod dnf module enable -y php:8.2
docker exec xdmod dnf install -y php-devel openssl-devel
docker exec xdmod dnf update -y php php-common php-opcache php-cli php-gd php-curl php-pear php-zip php-gmp php-pdo php-xml php-mbstring php-mysqlnd php-pecl-apcu php-pecl-json php-pear
docker exec xdmod pecl uninstall mongodb-1.18.1
docker exec xdmod pecl install mongodb-1.18.1
docker exec xdmod pecl install zip
docker exec xdmod dnf remove -y php-devel openssl-devel
docker exec xdmod bash -c ">/var/log/php_errors.log"
- run:
name: Copy Files for Playwright and XDMoD containers
command: |
docker cp ~/project xdmod:/root/xdmod
docker cp ~/project playwright:/root/xdmod
docker exec playwright mkdir -p /root/xdmod/tests/ /root/xdmod/tests/artifacts/xdmod/
docker cp ~/project/tests/playwright playwright:/root/xdmod/tests/
docker cp ~/project/tests/ci playwright:/root/xdmod/tests/
docker cp ~/project/tests/artifacts/xdmod/ui playwright:/root/xdmod/tests/artifacts/xdmod/
- run:
name: Create test result directories
command: |
Expand All @@ -56,6 +71,13 @@ jobs:
- run:
name: Install XDMoD Composer Dependencies
command: docker exec -w /root/xdmod xdmod composer install
- run:
name: Fixup php.ini for debugging
command: |
docker exec xdmod bash -c "sed -i 's|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g' /etc/php.ini"
docker exec xdmod bash -c "sed -i 's|display_errors = Off|display_errors = On|g' /etc/php.ini"
docker exec xdmod bash -c "sed -i 's|display_startup_errors = Off|display_startup_errors = On|g' /etc/php.ini"
docker exec xdmod bash -c "sed -i 's|;error_log = php_errors.log|error_log = php_errors.log|g' /etc/php.ini"
- run:
name: Build XDMoD RPM
command: docker exec -w /root/xdmod xdmod /root/bin/buildrpm xdmod
Expand All @@ -78,7 +100,7 @@ jobs:
command: docker exec -w /root/xdmod xdmod composer install
- run:
name: Setup the SimpleSAML server etc. so we can test SSO
command: docker exec xdmod /root/xdmod/tests/ci/samlSetup.sh
command: docker exec xdmod /root/xdmod/tests/ci/samlSetup.sh -t local -h xdmod
- run:
name: Make sure that the Test Dependencies are installed
command: docker exec -w /root/xdmod xdmod composer install --no-progress
Expand Down Expand Up @@ -187,7 +209,7 @@ jobs:
- run:
name: Ensure that no PHP command-line errors were generated
command: |
docker exec xdmod /bin/bash -c "if [ -s /var/log/php_errors.log ]; then cat /var/log/php_errors.log; false; fi"
docker exec xdmod /bin/bash -c "if [ -s /var/log/php_errors.log ]; then cat /var/log/php_errors.log | grep -v 'Warning'; false; fi"
- store_artifacts:
path: /tmp/screenshots
- store_artifacts:
Expand Down
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Default ENV file
DATABASE_URL=
###> google/recaptcha ###
# To use Google Recaptcha, you must register a site on Recaptcha's admin panel:
# https://www.google.com/recaptcha/admin
GOOGLE_RECAPTCHA_SITE_KEY=
GOOGLE_RECAPTCHA_SECRET=
###< google/recaptcha ###
XDMOD_LOG_DIR=/var/log/xdmod
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup php
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
extensions: xml
tools: composer:v2

Expand Down
1 change: 1 addition & 0 deletions bin/acl-config
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ SQL;

$log->debug($query);
$log->debug('', $params);
$log->debug('Params', $params);

if ($dryRun) {
$log->info($successMsg);
Expand Down
39 changes: 39 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env php
<?php

use CCR\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

/* Since we want to be able to use this file in at least the following cases:
* - in the working repository for dev purposes
* - while installed via rpm ( location: /usr/bin/console, in $PATH by default )
* - while installed via source ( location: /usr/local/xdmod/bin, not in $PATH by default )
*
* We need to be able to find the `vendor/autoload_runtime.php` in a couple different places.
* - `'__XDMOD_SHARE_PATH__/vendor/autoload_runtime.php'` is for when XDMoD is installed from source or by RPM
* - `dirname(__DIR__).'/vendor/autoload_runtime.php'` is for when doing dev work in the XDMoD git repo.
*/
$files = [
'__XDMOD_SHARE_PATH__/vendor/autoload_runtime.php',
dirname(__DIR__).'/vendor/autoload_runtime.php'
];

$file = null;
foreach($files as $potentialFile) {
if (is_file($potentialFile)) {
$file = $potentialFile;
break;
}
}

if ($file === null) {
throw new RuntimeException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once $file;

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
19 changes: 12 additions & 7 deletions classes/Authentication/SAML/XDSamlAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
use \Exception;
use CCR\Log;
use Models\Services\Organizations;
use Psr\Log\LoggerInterface;
use SimpleSAML\Auth\Simple;
use SimpleSAML\Auth\Source;
use SimpleSAML\Metadata\MetaDataStorageHandler;
use SimpleSAML\Session;
use XDUser;

class XDSamlAuthentication
{
/**
* The selected auth source
*
* @var \SimpleSAML_Auth_Simple
* @var Simple
*/
protected $_as = null;

Expand Down Expand Up @@ -65,7 +70,7 @@ public function __construct()
)
);

$this->_sources = \SimpleSAML_Auth_Source::getSources();
$this->_sources = Source::getSources();
if ($this->isSamlConfigured()) {
try {
$authSource = \xd_utilities\getConfiguration('authentication', 'source');
Expand Down Expand Up @@ -97,7 +102,7 @@ public function isSamlConfigured()
*/
public function logout(){
if ($this->isSamlConfigured()) {
\SimpleSAML_Session::getSessionFromRequest()->doLogout($this->authSourceName);
Session::getSessionFromRequest()->doLogout($this->authSourceName);
}
}
/**
Expand All @@ -112,7 +117,7 @@ public function getXdmodAccount()
/*
* SimpleSAMLphp uses its own session, this sets it back.
*/
\SimpleSAML_Session::getSessionFromRequest()->cleanup();
Session::getSessionFromRequest()->cleanup();
if ($this->_as->isAuthenticated()) {
$userName = $samlAttrs['username'][0];

Expand Down Expand Up @@ -205,7 +210,7 @@ public function getOrganizationId($samlAttrs, $personId)
*
* @param string $returnTo the URI to redirect to after auth.
*
* @return the login URL or false if no provider is configured
* @return string|bool login URL or false if no provider is configured
*/
public function getLoginURL($returnTo)
{
Expand All @@ -226,8 +231,8 @@ public function getLoginLink()
if (!$this->isSamlConfigured()) {
return false;
}
$idp = \SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler()->getMetadata(
\SimpleSAML_Auth_Source::getById($this->authSourceName)->getMetadata()->toArray()['idp'],
$idp = MetaDataStorageHandler::getMetadataHandler()->getMetaData(
Source::getById($this->authSourceName)->getMetadata()->toArray()['idp'],
'saml20-idp-remote'
);
if (!empty($idp['OrganizationDisplayName'])) {
Expand Down
3 changes: 2 additions & 1 deletion classes/CCR/CCRDBFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CCR;

use Monolog\Formatter\NormalizerFormatter;
use Monolog\LogRecord;

class CCRDBFormatter extends NormalizerFormatter
{
Expand All @@ -12,7 +13,7 @@ class CCRDBFormatter extends NormalizerFormatter
* all of the properties from the context. If the message is an empty
* string the message property is not added.
*/
public function format(array $record)
public function format(LogRecord $record)
{
$vars = parent::format($record);

Expand Down
12 changes: 7 additions & 5 deletions classes/CCR/CCRDBHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use CCR\DB\iDatabase;
use Exception;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Level;
use Monolog\LogRecord;

/**
* This class is meant to provide a means of writing log entries to a database within the Monolog framework.
Expand Down Expand Up @@ -49,7 +51,7 @@ class CCRDBHandler extends AbstractProcessingHandler
*/
public function __construct(iDatabase $db = null, $schema = null, $table = null, $level = Log::DEBUG, $bubble = true)
{
parent::__construct($level, $bubble);
parent::__construct(Level::fromValue(Log::convertToMonologLevel($level)), $bubble);

if (!isset($db)) {
$db = DB::factory('logger');
Expand All @@ -71,16 +73,16 @@ public function __construct(iDatabase $db = null, $schema = null, $table = null,
/**
* @see AbstractProcessingHandler::write()
*/
protected function write(array $record)
protected function write(LogRecord $record): void
{
$sql = sprintf("INSERT INTO %s.%s (id, logtime, ident, priority, message) VALUES(:id, NOW(), :ident, :priority, :message)", $this->schema, $this->table);

$this->db->execute($sql, array(
$params = [
':id' => $this->getNextId(),
':ident' => $record['channel'],
':priority' => Log::convertToCCRLevel($record['level']),
':message' => $record['formatted']
));
];
$this->db->execute($sql, $params);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion classes/CCR/CCRLineFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\NormalizerFormatter;
use Monolog\LogRecord;
use Monolog\Utils;

class CCRLineFormatter extends LineFormatter
Expand Down Expand Up @@ -45,7 +46,7 @@ protected function toJson($data, $ignoreErrors = false): string
* string and context object. If either the context is empty or the message
* is an empty string they are ommitted.
*/
public function format(array $record)
public function format(LogRecord $record): string
{
$vars = NormalizerFormatter::format($record);

Expand Down Expand Up @@ -98,6 +99,11 @@ public function format(array $record)
// remove leftover %extra.xxx% and %context.xxx% if any
if (false !== strpos($output, '%')) {
$output = preg_replace('/%(?:extra|context)\..+?%/', '', $output);
if (null === $output) {
$pcreErrorCode = preg_last_error();

throw new \RuntimeException('Failed to run preg_replace: ' . $pcreErrorCode . ' / ' . preg_last_error_msg());
}
}

return $output;
Expand Down
42 changes: 22 additions & 20 deletions classes/CCR/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Monolog\Handler\NativeMailerHandler;
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Psr\Log\LoggerInterface;

use xd_utilities;

/**
Expand All @@ -32,25 +34,25 @@ class Log
const DEBUG = 7;

private static $logLevels = array(
self::EMERG => \Monolog\Logger::EMERGENCY,
self::ALERT => \Monolog\Logger::ALERT,
self::CRIT => \Monolog\Logger::CRITICAL,
self::ERR => \Monolog\Logger::ERROR,
self::WARNING => \Monolog\Logger::WARNING,
self::NOTICE => \Monolog\Logger::NOTICE,
self::INFO => \Monolog\Logger::INFO,
self::DEBUG => \Monolog\Logger::DEBUG
self::EMERG => \Monolog\Level::Emergency->value,
self::ALERT => \Monolog\Level::Alert->value,
self::CRIT => \Monolog\Level::Critical->value,
self::ERR => \Monolog\Level::Error->value,
self::WARNING => \Monolog\Level::Warning->value,
self::NOTICE => \Monolog\Level::Notice->value,
self::INFO => \Monolog\Level::Info->value,
self::DEBUG => \Monolog\Level::Debug->value
);

private static $flippedLogLevels = array(
\Monolog\Logger::EMERGENCY => self::EMERG,
\Monolog\Logger::ALERT => self::ALERT,
\Monolog\Logger::CRITICAL => self::CRIT,
\Monolog\Logger::ERROR => self::ERR,
\Monolog\Logger::WARNING => self::WARNING,
\Monolog\Logger::NOTICE => self::NOTICE,
\Monolog\Logger::INFO => self::INFO,
\Monolog\Logger::DEBUG => self::DEBUG
\Monolog\Level::Emergency->value => self::EMERG,
\Monolog\Level::Alert->value => self::ALERT,
\Monolog\Level::Critical->value => self::CRIT,
\Monolog\Level::Error->value => self::ERR,
\Monolog\Level::Warning->value => self::WARNING,
\Monolog\Level::Notice->value => self::NOTICE,
\Monolog\Level::Info->value => self::INFO,
\Monolog\Level::Debug->value => self::DEBUG
);

/**
Expand Down Expand Up @@ -165,7 +167,7 @@ protected static function getLogger($ident, array $conf)
'mail'
);

$logger = new Logger($ident);
$logger = new \Monolog\Logger($ident);

// Short circuit the function if 'null' was asked for since this will be the only handler for the logger.
if ($ident === 'null') {
Expand Down Expand Up @@ -262,7 +264,7 @@ protected static function getDbHandler($ident, array $conf)
{
$dbLogLevel = $conf['dbLogLevel'] ?? self::getDefaultLogLevel('db');

$handler = new CCRDBHandler(null, null, null, self::convertToMonologLevel($dbLogLevel));
$handler = new CCRDBHandler(null, null, null, $dbLogLevel);
$handler->setFormatter(new CCRDBFormatter());

return $handler;
Expand Down Expand Up @@ -341,7 +343,7 @@ public static function convertToCCRLevel($monologLevel)
if (array_key_exists($monologLevel, self::$flippedLogLevels)) {
return self::$flippedLogLevels[$monologLevel];
}
throw new Exception('Unknown Log Level');
throw new Exception(sprintf('Unknown Monolog Log Level %s', $monologLevel));
}

/**
Expand All @@ -356,7 +358,7 @@ public static function convertToMonologLevel($ccrLevel)
if (array_key_exists($ccrLevel, self::$logLevels)) {
return self::$logLevels[$ccrLevel];
}
throw new Exception('Unknown Log Level');
throw new Exception(sprintf('Unknown CCR Log Level %s', $ccrLevel));
}

/**
Expand Down
Loading