Skip to content

PHP Warning: Undefined array key REMOTE_USER in ShibbolethAuthenticationService::init() #12

Description

@magicsunday

Description

When a request reaches the TYPO3 backend without a Shibboleth session (e.g. direct backend login, CLI, or any non-Shibboleth request), ShibbolethAuthenticationService::init() triggers a PHP warning:

PHP Warning: Undefined array key "REMOTE_USER" in
Classes/Typo3/Service/ShibbolethAuthenticationService.php line 53

Root Cause

In init() at line 53, $_SERVER[$this->extensionConfiguration['remoteUser']] is accessed without checking if the key exists:

$this->remoteUser = $_SERVER[$this->extensionConfiguration['remoteUser']];

When there is no Shibboleth session active, $_SERVER['REMOTE_USER'] is not set, causing the warning.

Expected Behavior

No PHP warning should be emitted. The $remoteUser property should gracefully default to null when REMOTE_USER is not present in $_SERVER.

Proposed Fix

Use the null coalescing operator:

$this->remoteUser = $_SERVER[$this->extensionConfiguration['remoteUser']] ?? null;

This is safe because the property is already typed as ?string and all usages of $this->remoteUser handle null/empty correctly via empty() checks.

Environment

  • TYPO3 v13.4
  • PHP 8.4
  • shibboleth_auth: dev-main

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions