simplesamlphp / simplesamlphp-module-statistics

The SimpleSAMLphp statistics module
GNU Lesser General Public License v2.1
2 stars 0 forks source link

SSP v2.0.0 IdP - A problem with v1.1.5 #10

Closed malavolti closed 1 year ago

malavolti commented 1 year ago

Dear @tvdijen,

I've tried to install by composer the v1.1.5 of this module on my SimpleSAMLphp v2.0.0, but I get this error:

root@ssp-idp:/var/simplesamlphp# composer require simplesamlphp/simplesamlphp-module-statistics:v1.1.5
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? 
./composer.json has been updated
Running composer update simplesamlphp/simplesamlphp-module-statistics
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires simplesamlphp/simplesamlphp-module-statistics v1.1.5 -> satisfiable by simplesamlphp/simplesamlphp-module-statistics[v1.1.5].
    - simplesamlphp/simplesamlphp-module-statistics v1.1.5 requires simplesamlphp/assert ^0.2.7 -> found simplesamlphp/assert[v0.2.7, ..., v0.2.13] but the package is fixed to v0.8.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

instead, if I install the same module without specify the version I can install the v1.1.0, but it doesn't work because (I think) that version is not compatible with v2.0.0 of SimpleSAMLphp... Right?

Is there a version compatible with v2.0.0 of SimpleSAMLphp?

Thank you so much!

tvdijen commented 1 year ago

I just tagged v1.1.6 that should fix this dependency-conflict!

malavolti commented 1 year ago

Thank you @tvdijen!

I think there are other 2 problems:

SimpleSAML\Error\Error: UNHANDLEDEXCEPTION
Backtrace:
2 public/_include.php:28 (SimpleSAML_exception_handler)
1 /var/simplesamlphp/vendor/symfony/error-handler/ErrorHandler.php:538 (Symfony\Component\ErrorHandler\ErrorHandler::handleException)
0 [builtin] (N/A)
Caused by: InvalidArgumentException: The controller for URI "/statistics/" is not callable: Controller "SimpleSAML\Module\statistics\Controller\Statistics" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?
Backtrace:
5 /var/simplesamlphp/vendor/symfony/http-kernel/Controller/ControllerResolver.php:88 (Symfony\Component\HttpKernel\Controller\ControllerResolver::getController)
4 /var/simplesamlphp/vendor/symfony/http-kernel/HttpKernel.php:146 (Symfony\Component\HttpKernel\HttpKernel::handleRaw)
3 /var/simplesamlphp/vendor/symfony/http-kernel/HttpKernel.php:75 (Symfony\Component\HttpKernel\HttpKernel::handle)
2 /var/simplesamlphp/vendor/symfony/http-kernel/Kernel.php:202 (Symfony\Component\HttpKernel\Kernel::handle)
1 src/SimpleSAML/Module.php:234 (SimpleSAML\Module::process)
0 public/module.php:14 (N/A)
SimpleSAML\Error\Error: UNHANDLEDEXCEPTION
Backtrace:
2 public/_include.php:28 (SimpleSAML_exception_handler)
1 /var/simplesamlphp/vendor/symfony/error-handler/ErrorHandler.php:538 (Symfony\Component\ErrorHandler\ErrorHandler::handleException)
0 [builtin] (N/A)
Caused by: InvalidArgumentException: The controller for URI "/statistics/metadata" is not callable: Controller "SimpleSAML\Module\statistics\Controller\Statistics" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?
Backtrace:
5 /var/simplesamlphp/vendor/symfony/http-kernel/Controller/ControllerResolver.php:88 (Symfony\Component\HttpKernel\Controller\ControllerResolver::getController)
4 /var/simplesamlphp/vendor/symfony/http-kernel/HttpKernel.php:146 (Symfony\Component\HttpKernel\HttpKernel::handleRaw)
3 /var/simplesamlphp/vendor/symfony/http-kernel/HttpKernel.php:75 (Symfony\Component\HttpKernel\HttpKernel::handle)
2 /var/simplesamlphp/vendor/symfony/http-kernel/Kernel.php:202 (Symfony\Component\HttpKernel\Kernel::handle)
1 src/SimpleSAML/Module.php:234 (SimpleSAML\Module::process)
0 public/module.php:14 (N/A)

Where is the documentation of that module?

I've found this: https://github.com/simplesamlphp/simplesamlphp-module-statistics/blob/master/docs/statistics.md but I think it is relative the previous 1.x versions:

cd modules/cron
touch enable

Thank you so much!

tvdijen commented 1 year ago

Unfortunately there is no documentation for it other than the file you have already found. I will investigate the controller-issue tonight and see if I can update the docs

tvdijen commented 1 year ago

I think somehow something is borked in your install, because I could not reproduce this. I did find two other bugs that are now fixed and v1.1.7 was tagged. Using v2.0.0 with v1.1.7 of the module works for me and I can see my statistics

malavolti commented 1 year ago

Thank you @tvdijen,

My Apache config contains:

     SetEnv SIMPLESAMLPHP_CONFIG_DIR /var/simplesamlphp/config

     Alias /simplesaml /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/public

     RedirectMatch ^/$ /simplesaml

     <Directory /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/public>
        <IfModule mod_authz_core.c>
           Require all granted
        </IfModule>
     </Directory>

And I've install v1.1.7 of simplesamlphp-module-statistics.

I configured my rsyslog service with:

# cat /etc/rsyslog.d/22-ssp-log.conf 
# SimpleSAMLphp logging
local5.*                        /var/log/simplesamlphp.log
# Notice level is reserved for statistics only...
local5.=notice                  /var/log/simplesamlphp.stat

and I collect statistics into:

/var/log/simplesamlphp.stat

I have enabled the module into config/config.php file:

    'module.enable' => [
        'exampleauth' => false,
        'core' => true,
        'admin' => true,
        'saml' => true,
    'consent' => true,
        'ldap' => true,
    'statistics' => true,
    ],

But if I open the location "/statistics" and "/statistics-metadata" through the "admin" panel, I meet the error reported above.

What I missing to see the statistics page?

Thank you for the help!

tvdijen commented 1 year ago

What version of PHP are you running? And what version of Symfony is installed (you can see in the composer.lock file).. Are you installing from tarball or git clone?

I've fixed the docs on how to enable the cron-module

malavolti commented 1 year ago

PHP version: 8.1.2 OS: Ubuntu 22.04 (Jammy)

composer/ca-bundle                            1.3.5   Lets you find a path to the system CA bundle, and includes a fallback to the ...
composer/class-map-generator                  1.0.0   Utilities to scan PHP code and generate class maps.
composer/composer                             2.5.4   Composer helps you declare, manage and install dependencies of PHP projects. ...
composer/metadata-minifier                    1.0.0   Small utility library that handles metadata minification and expansion.
composer/pcre                                 3.1.0   PCRE wrapping library that offers type-safe preg_* replacements.
composer/semver                               3.3.2   Semver library that offers utilities, version constraint parsing and validation.
composer/spdx-licenses                        1.5.7   SPDX licenses list and validation library.
composer/xdebug-handler                       3.0.3   Restarts a process without Xdebug.
gettext/gettext                               v5.7.0  PHP gettext manager
gettext/languages                             2.10.0  gettext languages with plural rules
gettext/translator                            v1.1.1  Gettext translator functions
justinrainbow/json-schema                     5.2.12  A library to validate a json schema.
phpmailer/phpmailer                           v6.7.1  PHPMailer is a full-featured email creation and transfer class for PHP
psr/cache                                     2.0.0   Common interface for caching libraries
psr/container                                 1.1.2   Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                          1.0.0   Standard interfaces for event handling.
psr/log                                       2.0.0   Common interface for logging libraries
react/promise                                 v2.9.0  A lightweight implementation of CommonJS Promises/A for PHP
robrichards/xmlseclibs                        3.1.1   A PHP library for XML Security
seld/jsonlint                                 1.9.0   JSON Linter
seld/phar-utils                               1.2.1   PHAR file format utilities, for when PHP phars you up
seld/signal-handler                           2.0.1   Simple unix signal handler that silently fails where signals are not supporte...
simplesamlphp/assert                          v0.8.0  A wrapper around webmozart/assert to make it useful beyond checking method ar...
simplesamlphp/composer-module-installer       v1.3.3  A Composer plugin that allows installing SimpleSAMLphp modules through Composer.
simplesamlphp/saml2                           v4.6.5  SAML2 PHP library from SimpleSAMLphp
simplesamlphp/simplesamlphp                   v2.0.0  A PHP implementation of a SAML 2.0 service provider and identity provider.
simplesamlphp/simplesamlphp-assets-base       v2.0.4  Assets for the SimpleSAMLphp main repository
simplesamlphp/simplesamlphp-module-consent    v1.2.1  A module that will ask for user consent before releasing attributes
simplesamlphp/simplesamlphp-module-ldap       v2.1.3  A module that provides authentication against LDAP stores
simplesamlphp/simplesamlphp-module-statistics v1.1.7  The SimpleSAMLphp statistics module
symfony/cache                                 v5.4.21 Provides extended PSR-6, PSR-16 (and tags) implementations
symfony/cache-contracts                       v2.5.2  Generic abstractions related to caching
symfony/config                                v5.4.21 Helps you find, load, combine, autofill and validate configuration values of ...
symfony/console                               v5.4.21 Eases the creation of beautiful and testable command line interfaces
symfony/dependency-injection                  v5.4.21 Allows you to standardize and centralize the way objects are constructed in y...
symfony/deprecation-contracts                 v3.2.1  A generic function and convention to trigger deprecation notices
symfony/error-handler                         v6.2.7  Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher                      v6.2.7  Provides tools that allow your application components to communicate with eac...
symfony/event-dispatcher-contracts            v3.2.1  Generic abstractions related to dispatching event
symfony/filesystem                            v5.4.21 Provides basic utilities for the filesystem
symfony/finder                                v5.4.21 Finds files and directories via an intuitive fluent interface
symfony/framework-bundle                      v5.4.21 Provides a tight integration between Symfony components and the Symfony full-...
symfony/http-foundation                       v5.4.21 Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                           v5.4.21 Provides a structured process for converting a Request into a Response
symfony/intl                                  v5.4.21 Provides a PHP replacement layer for the C intl extension that includes addit...
symfony/ldap                                  v6.2.7  Provides a LDAP client for PHP on top of PHP's ldap extension
symfony/options-resolver                      v6.2.7  Provides an improved replacement for the array_replace PHP function
symfony/polyfill-ctype                        v1.27.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme                v1.27.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer              v1.27.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring                     v1.27.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php73                        v1.27.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80                        v1.27.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81                        v1.27.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/process                               v6.2.7  Executes commands in sub-processes
symfony/routing                               v5.4.21 Maps an HTTP request to a set of configuration variables
symfony/service-contracts                     v2.5.2  Generic abstractions related to writing services
symfony/string                                v6.2.7  Provides an object-oriented API to strings and deals with bytes, UTF-8 code p...
symfony/translation-contracts                 v2.5.2  Generic abstractions related to translation
symfony/twig-bridge                           v5.4.21 Provides integration for Twig with various Symfony components
symfony/var-dumper                            v6.2.7  Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter                          v5.4.21 Allows exporting any serializable PHP data structure to plain PHP code
symfony/yaml                                  v5.4.21 Loads and dumps YAML files
twig/intl-extra                               v3.5.1  A Twig extension for Intl
twig/twig                                     v3.5.1  Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                              1.11.0  Assertions to validate method input/output with nice error messages.

I've installed all SSP and modules with Composer. :)

tvdijen commented 1 year ago

I don't know what's wrong with your install, sorry.. I've tried this scenario 3 times now and I cannot reproduce the errors you are encountering.

malavolti commented 1 year ago

Thank you @tvdijen,

I solved the errors by running the "cron" job provided by the module. I don't know why, but I can't use "./loganalyzer.php --debug" directly due the error:

# php loganalyzer.php --debug
PHP Fatal error:  Uncaught SimpleSAML\Error\CriticalConfigurationError: The configuration (config/config.php) is invalid: Missing configuration file in /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Error/CriticalConfigurationError.php:84
Stack trace:
#0 /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Configuration.php(348): SimpleSAML\Error\CriticalConfigurationError::fromException()
#1 /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Utils/Time.php(57): SimpleSAML\Configuration::getInstance()
#2 /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/modules/statistics/bin/loganalyzer.php(17): SimpleSAML\Utils\Time->initTimezone()
#3 {main}
  thrown in /var/simplesamlphp/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Error/CriticalConfigurationError.php on line 84

But, without touch anything, by enabling the cron job ... works. :-O

I found some exceptions during the exploration of the statistics webapp from the admin interface.

Do you want that I report them here?

tvdijen commented 1 year ago

If you want to run the loganalyzer.php from the command line, you have to tell it where the configuration can be found using the SIMPLESAMLPHP_CONFIG_DIR environment variable.

Usually on Linux you can do this like; export SIMPLESAMPHP_CONFIG_DIR=/path/to/config

And yes, of course you can share your experiences here!