Skip to content

Bug: Authentication validation fails on IIS/Windows with PHP 8.2 (Missing Authorization Header) #66

@ftjr20

Description

@ftjr20

On Windows Server environments using IIS and PHP 8.2 (NTS), the SDK fails to recognize the Basic Auth credentials even when they are correctly provided in the constructor. The internal validator throws a Missing required header field: Authorization error before the request is even dispatched.

Environment:

OS: Windows Server (IIS)

PHP Version: 8.2.30 (Non-Thread Safe)

SDK Version: 6.8.17

Steps to Reproduce:

  1. Initialize the PagarmeApiSDKClient with standard credentials:
  2. Call any controller method.
    code:$client = new PagarmeApiSDKClient([ 'basicAuthUserName' => 'sk_test_xxx', 'basicAuthPassword' => '', // Empty string as per documentation 'environment' => 'production' ]);
  3. The SDK throws: Following authentication credentials are required: -> Missing required header field: Authorization.

The Discovery (The Fix):
It seems the internal validation considers an empty string '' in basicAuthPassword as a null/missing value.

Workaround found:
By providing a single whitespace ' ' instead of an empty string, the validator is bypassed and the SDK works correctly (especially when combined with manual header injection in additionalHttpHeaders).
// This hack solves the issue: 'basicAuthPassword' => ' ',

Suggested Fix:
Update the credential validator to allow empty strings for the password field, as the Pagar.me API specifically requires the password to be empty when using the Secret Key as the username.

Image
Image
Image
Image

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